diff options
Diffstat (limited to 'tests/cxx/hybrid')
-rw-r--r-- | tests/cxx/hybrid/facets/driver.cxx | 56 | ||||
-rw-r--r-- | tests/cxx/hybrid/facets/makefile | 108 | ||||
-rw-r--r-- | tests/cxx/hybrid/facets/test-000.std | 62 | ||||
-rw-r--r-- | tests/cxx/hybrid/facets/test-000.xml | 97 | ||||
-rw-r--r-- | tests/cxx/hybrid/facets/test.xsd | 180 | ||||
-rw-r--r-- | tests/cxx/hybrid/makefile | 3 |
6 files changed, 505 insertions, 1 deletions
diff --git a/tests/cxx/hybrid/facets/driver.cxx b/tests/cxx/hybrid/facets/driver.cxx new file mode 100644 index 0000000..b46a61c --- /dev/null +++ b/tests/cxx/hybrid/facets/driver.cxx @@ -0,0 +1,56 @@ +// file : tests/cxx/hybrid/facets/driver.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test facets (except pattern) validation. +// + +#include <iostream> + +#include "test.hxx" +#include "test-pimpl.hxx" +#include "test-simpl.hxx" + +using namespace std; +using namespace test; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + // Parse. + // + root_paggr root_p; + + xml_schema::document_pimpl doc_p ( + root_p.root_parser (), + root_p.root_namespace (), + root_p.root_name ()); + + root_p.pre (); + doc_p.parse (argv[1]); + type* r = root_p.post (); + + // Serialize. + // + root_saggr root_s; + + xml_schema::document_simpl doc_s ( + root_s.root_serializer (), + root_s.root_namespace (), + root_s.root_name ()); + + doc_s.add_prefix ("t", "test"); + + root_s.pre (*r); + doc_s.serialize (cout, xml_schema::document_simpl::pretty_print); + root_s.post (); + + delete r; +} diff --git a/tests/cxx/hybrid/facets/makefile b/tests/cxx/hybrid/facets/makefile new file mode 100644 index 0000000..ec749b3 --- /dev/null +++ b/tests/cxx/hybrid/facets/makefile @@ -0,0 +1,108 @@ +# file : tests/cxx/hybrid/facets/makefile +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make + +xsd := test.xsd +cxx := driver.cxx + +obj := $(addprefix $(out_base)/,\ +$(cxx:.cxx=.o) \ +$(xsd:.xsd=.o) \ +$(xsd:.xsd=-pskel.o) \ +$(xsd:.xsd=-pimpl.o) \ +$(xsd:.xsd=-sskel.o) \ +$(xsd:.xsd=-simpl.o)) + +dep := $(obj:.o=.o.d) + +xsde.l := $(out_root)/libxsde/xsde/xsde.l +xsde.l.cpp-options := $(out_root)/libxsde/xsde/xsde.l.cpp-options + +driver := $(out_base)/driver +test := $(out_base)/.test +dist := $(out_base)/.dist +dist-win := $(out_base)/.dist-win +clean := $(out_base)/.clean + + +# Build. +# +$(driver): $(obj) $(xsde.l) + +$(obj) $(dep): $(xsde.l.cpp-options) + +genf := $(xsd:.xsd=.hxx) $(xsd:.xsd=.cxx) \ + $(xsd:.xsd=-pskel.hxx) $(xsd:.xsd=-pskel.cxx) \ + $(xsd:.xsd=-pimpl.hxx) $(xsd:.xsd=-pimpl.cxx) \ + $(xsd:.xsd=-sskel.hxx) $(xsd:.xsd=-sskel.cxx) \ + $(xsd:.xsd=-simpl.hxx) $(xsd:.xsd=-simpl.cxx) + +gen := $(addprefix $(out_base)/,$(genf)) + +$(gen): $(out_root)/xsde/xsde +$(gen): xsde := $(out_root)/xsde/xsde +$(gen) $(dist) $(dist-win): xsde_options += --generate-parser \ +--generate-serializer --generate-aggregate + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +$(out_base)/: $(driver) + + +# Test. +# +$(test): driver := $(driver) +$(test): $(driver) $(src_base)/test-000.xml $(src_base)/test-000.std + $(call message,test $$1,$$1 $(src_base)/test-000.xml | diff -u $(src_base)/test-000.std -,$(driver)) + + +# Dist. +# +$(dist) $(dist-win): opt := -src $(src_base) -cmd cxx-hybrid -xsd "$(xsd)" \ +-cxx "$(cxx)" -gen "$(genf)" -opt "$(xsde_options)" -out $(dist_prefix) + +$(dist): + $(call message,install $(src_base),$(scf_root)/dist $(opt)) + +$(dist-win): + $(call message,install $(src_base),$(scf_root)/dist -win $(opt)) + + +# Clean. +# +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean)) + + +# Generated .gitignore. +# +ifeq ($(out_base),$(src_base)) +$(gen): | $(out_base)/.gitignore +$(driver): | $(out_base)/.gitignore + +$(out_base)/.gitignore: files := driver $(genf) +$(clean): $(out_base)/.gitignore.clean + +$(call include,$(bld_root)/git/gitignore.make) +endif + + +# How to. +# +$(call include,$(bld_root)/cxx/o-e.make) +$(call include,$(bld_root)/cxx/cxx-o.make) +$(call include,$(bld_root)/cxx/cxx-d.make) +$(call include,$(scf_root)/xsde/hybrid/xsd-cxx.make) + + +# Dependencies. +# +$(call import,$(src_root)/xsde/makefile) +$(call import,$(src_root)/libxsde/xsde/makefile) diff --git a/tests/cxx/hybrid/facets/test-000.std b/tests/cxx/hybrid/facets/test-000.std new file mode 100644 index 0000000..e777433 --- /dev/null +++ b/tests/cxx/hybrid/facets/test-000.std @@ -0,0 +1,62 @@ +<t:root xmlns:t="test"> + <byte>10</byte> + <byte>50</byte> + <byte>100</byte> + <ubyte>10</ubyte> + <ubyte>50</ubyte> + <ubyte>100</ubyte> + <short>10</short> + <short>50</short> + <short>100</short> + <ushort>10</ushort> + <ushort>50</ushort> + <ushort>100</ushort> + <int>10</int> + <int>50</int> + <int>100</int> + <uint>10</uint> + <uint>50</uint> + <uint>100</uint> + <long>10</long> + <long>50</long> + <long>100</long> + <ulong>10</ulong> + <ulong>50</ulong> + <ulong>100</ulong> + <integer>10</integer> + <integer>50</integer> + <integer>100</integer> + <ninteger>-100</ninteger> + <ninteger>-50</ninteger> + <ninteger>-10</ninteger> + <npinteger>-100</npinteger> + <npinteger>-50</npinteger> + <npinteger>-10</npinteger> + <pinteger>10</pinteger> + <pinteger>50</pinteger> + <pinteger>100</pinteger> + <nninteger>10</nninteger> + <nninteger>50</nninteger> + <nninteger>100</nninteger> + <float>10.5</float> + <float>50</float> + <float>99.5</float> + <double>10.5</double> + <double>50</double> + <double>99.5</double> + <decimal>10.5</decimal> + <decimal>50</decimal> + <decimal>99.5</decimal> + <string1>12345</string1> + <string2>12345</string2> + <string2>1234567</string2> + <string2>1234567890</string2> + <string3> + +a aa + + </string3> + <string4> a aa </string4> + <string5>a aa</string5> + <token>a aa</token> +</t:root>
\ No newline at end of file diff --git a/tests/cxx/hybrid/facets/test-000.xml b/tests/cxx/hybrid/facets/test-000.xml new file mode 100644 index 0000000..814be66 --- /dev/null +++ b/tests/cxx/hybrid/facets/test-000.xml @@ -0,0 +1,97 @@ +<t:root xmlns:t="test"> + + <byte>10</byte> + <byte>50</byte> + <byte>100</byte> + + <ubyte>10</ubyte> + <ubyte>50</ubyte> + <ubyte>100</ubyte> + + <short>10</short> + <short>50</short> + <short>100</short> + + <ushort>10</ushort> + <ushort>50</ushort> + <ushort>100</ushort> + + <int>10</int> + <int>50</int> + <int>100</int> + + <uint>10</uint> + <uint>50</uint> + <uint>100</uint> + + <long>10</long> + <long>50</long> + <long>100</long> + + <ulong>10</ulong> + <ulong>50</ulong> + <ulong>100</ulong> + + <integer>10</integer> + <integer>50</integer> + <integer>100</integer> + + <ninteger>-100</ninteger> + <ninteger>-50</ninteger> + <ninteger>-10</ninteger> + + <npinteger>-100</npinteger> + <npinteger>-50</npinteger> + <npinteger>-10</npinteger> + + <pinteger>10</pinteger> + <pinteger>50</pinteger> + <pinteger>100</pinteger> + + <nninteger>10</nninteger> + <nninteger>50</nninteger> + <nninteger>100</nninteger> + + <float>10.5</float> + <float>50.0</float> + <float>99.5</float> + + <double>10.5</double> + <double>50.0</double> + <double>99.5</double> + + <decimal>10.5</decimal> + <decimal>50.0</decimal> + <decimal>99.5</decimal> + + <string1>12345</string1> + + <string2>12345</string2> + <string2>1234567</string2> + <string2>1234567890</string2> + + <string3> + +a aa + + </string3> + + <string4> + +a aa + + </string4> + + <string5> + +a aa + + </string5> + + <token> + +a aa + + </token> + +</t:root> diff --git a/tests/cxx/hybrid/facets/test.xsd b/tests/cxx/hybrid/facets/test.xsd new file mode 100644 index 0000000..86c9776 --- /dev/null +++ b/tests/cxx/hybrid/facets/test.xsd @@ -0,0 +1,180 @@ +<?xml version="1.0"?> +<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test"> + + <simpleType name="byte"> + <restriction base="byte"> + <minInclusive value="10"/> + <maxInclusive value="100"/> + </restriction> + </simpleType> + + <simpleType name="ubyte"> + <restriction base="unsignedByte"> + <minInclusive value="10"/> + <maxInclusive value="100"/> + </restriction> + </simpleType> + + <simpleType name="short"> + <restriction base="short"> + <minInclusive value="10"/> + <maxInclusive value="100"/> + </restriction> + </simpleType> + + <simpleType name="ushort"> + <restriction base="unsignedShort"> + <minInclusive value="10"/> + <maxInclusive value="100"/> + </restriction> + </simpleType> + + <simpleType name="int"> + <restriction base="int"> + <minInclusive value="10"/> + <maxInclusive value="100"/> + </restriction> + </simpleType> + + <simpleType name="uint"> + <restriction base="unsignedInt"> + <minInclusive value="10"/> + <maxInclusive value="100"/> + </restriction> + </simpleType> + + <simpleType name="long"> + <restriction base="long"> + <minInclusive value="10"/> + <maxInclusive value="100"/> + </restriction> + </simpleType> + + <simpleType name="ulong"> + <restriction base="unsignedLong"> + <minInclusive value="10"/> + <maxInclusive value="100"/> + </restriction> + </simpleType> + + <simpleType name="integer"> + <restriction base="integer"> + <minInclusive value="10"/> + <maxInclusive value="100"/> + </restriction> + </simpleType> + + <simpleType name="ninteger"> + <restriction base="negativeInteger"> + <minInclusive value="-100"/> + <maxInclusive value="-10"/> + </restriction> + </simpleType> + + <simpleType name="npinteger"> + <restriction base="nonPositiveInteger"> + <minInclusive value="-100"/> + <maxInclusive value="-10"/> + </restriction> + </simpleType> + + <simpleType name="pinteger"> + <restriction base="positiveInteger"> + <minInclusive value="10"/> + <maxInclusive value="100"/> + </restriction> + </simpleType> + + <simpleType name="nninteger"> + <restriction base="nonNegativeInteger"> + <minInclusive value="10"/> + <maxInclusive value="100"/> + </restriction> + </simpleType> + + <simpleType name="float"> + <restriction base="float"> + <minInclusive value="10.0"/> + <maxInclusive value="100"/> + </restriction> + </simpleType> + + <simpleType name="double"> + <restriction base="double"> + <minInclusive value="10.0"/> + <maxInclusive value="100"/> + </restriction> + </simpleType> + + <simpleType name="decimal"> + <restriction base="decimal"> + <minInclusive value="10.0"/> + <maxInclusive value="100"/> + </restriction> + </simpleType> + + <simpleType name="string1"> + <restriction base="string"> + <length value="5"/> + </restriction> + </simpleType> + + <simpleType name="string2"> + <restriction base="string"> + <minLength value="5"/> + <maxLength value="10"/> + </restriction> + </simpleType> + + <simpleType name="string3"> + <restriction base="string"> + <whiteSpace value="preserve"/> + </restriction> + </simpleType> + + <simpleType name="string4"> + <restriction base="string"> + <whiteSpace value="replace"/> + </restriction> + </simpleType> + + <simpleType name="string5"> + <restriction base="string"> + <whiteSpace value="collapse"/> + </restriction> + </simpleType> + + <complexType name="type"> + <sequence> + <element name="byte" type="t:byte" maxOccurs="unbounded"/> + <element name="ubyte" type="t:ubyte" maxOccurs="unbounded"/> + <element name="short" type="t:short" maxOccurs="unbounded"/> + <element name="ushort" type="t:ushort" maxOccurs="unbounded"/> + <element name="int" type="t:int" maxOccurs="unbounded"/> + <element name="uint" type="t:uint" maxOccurs="unbounded"/> + <element name="long" type="t:long" maxOccurs="unbounded"/> + <element name="ulong" type="t:ulong" maxOccurs="unbounded"/> + + <element name="integer" type="t:integer" maxOccurs="unbounded"/> + <element name="ninteger" type="t:ninteger" maxOccurs="unbounded"/> + <element name="npinteger" type="t:npinteger" maxOccurs="unbounded"/> + <element name="pinteger" type="t:pinteger" maxOccurs="unbounded"/> + <element name="nninteger" type="t:nninteger" maxOccurs="unbounded"/> + + <element name="float" type="t:float" maxOccurs="unbounded"/> + <element name="double" type="t:double" maxOccurs="unbounded"/> + <element name="decimal" type="t:decimal" maxOccurs="unbounded"/> + + <element name="string1" type="t:string1" maxOccurs="unbounded"/> + <element name="string2" type="t:string2" maxOccurs="unbounded"/> + <element name="string3" type="t:string3" maxOccurs="unbounded"/> + <element name="string4" type="t:string4" maxOccurs="unbounded"/> + <element name="string5" type="t:string5" maxOccurs="unbounded"/> + + <element name="token" type="token" maxOccurs="unbounded"/> + </sequence> + </complexType> + + <element name="root" type="t:type"/> + +</schema> diff --git a/tests/cxx/hybrid/makefile b/tests/cxx/hybrid/makefile index af610f5..810c9c1 100644 --- a/tests/cxx/hybrid/makefile +++ b/tests/cxx/hybrid/makefile @@ -26,7 +26,8 @@ endif endif ifeq ($(xsde_iostream),y) -build_tests += built-in default enumeration list test-template union pattern +build_tests += built-in default enumeration list test-template union facets \ +pattern ifeq ($(xsde_encoding),iso8859-1) build_tests += iso8859-1 |