diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2009-02-24 15:16:26 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2009-02-24 15:16:26 +0200 |
commit | 707cc94fe52463870a9c6c8e2e66eaaa389e601d (patch) | |
tree | 13e10ff28bf4455d915f9d59b401bdbb62a393cb /tests/cxx/serializer/validation |
Start tracking XSD/e with git after version 3.0.03.0.0
Diffstat (limited to 'tests/cxx/serializer/validation')
32 files changed, 2815 insertions, 0 deletions
diff --git a/tests/cxx/serializer/validation/any/driver.cxx b/tests/cxx/serializer/validation/any/driver.cxx new file mode 100644 index 0000000..ecdf7f8 --- /dev/null +++ b/tests/cxx/serializer/validation/any/driver.cxx @@ -0,0 +1,317 @@ +// file : tests/cxx/serializer/validation/any/driver.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test any validation. +// + +#include <sstream> +#include <iostream> + +#include "test-sskel.hxx" + +using namespace std; +using namespace test; + +struct test_1_simpl: virtual test_1_sskel +{ + virtual bool + any_next () + { + return false; + } + + virtual void +#ifdef XSDE_STL + any (std::string&, std::string&) + { +#else + any (const char*&, const char*&, bool&) + { +#endif + } + + virtual void + serialize_any () + { + } +}; + +// ##any +// +struct test_2_simpl: virtual test_2_sskel +{ + virtual void +#ifdef XSDE_STL + any (std::string& ns, std::string& name) + { +#else + any (const char*& ns, const char*& name, bool& free) + { + free = false; +#endif + ns = "foo"; + name = ""; + } + + virtual void + serialize_any () + { + } +}; + +// ##other +// +struct test_3_simpl: virtual test_3_sskel +{ + test_3_simpl (int state) + : state_ (state) + { + } + + virtual void +#ifdef XSDE_STL + any (std::string& ns, std::string& name) + { +#else + any (const char*& ns, const char*& name, bool& free) + { + free = false; +#endif + switch (state_) + { + case 2: + { + // target + // + ns = "test"; + name = "x"; + break; + } + case 3: + { + // local + // + ns = ""; + name = "x"; + break; + } + } + } + + virtual void + serialize_any () + { + } + +private: + int state_; +}; + +// ##local +// +struct test_4_simpl: virtual test_4_sskel +{ + virtual void +#ifdef XSDE_STL + any (std::string& ns, std::string& name) + { +#else + any (const char*& ns, const char*& name, bool& free) + { + free = false; +#endif + ns = "foo"; + name = "x"; + } + + virtual void + serialize_any () + { + } +}; + +// ##targetNamespace +// +struct test_5_simpl: virtual test_5_sskel +{ + test_5_simpl (int state) + : state_ (state) + { + } + + virtual void +#ifdef XSDE_STL + any (std::string& ns, std::string& name) + { +#else + any (const char*& ns, const char*& name, bool& free) + { + free = false; +#endif + switch (state_++) + { + case 5: + { + // target + // + ns = "foo"; + name = "x"; + break; + } + case 6: + { + // local + // + ns = ""; + name = "x"; + break; + } + } + } + + virtual void + serialize_any () + { + } + +private: + int state_; +}; + +// foo +// +struct test_6_simpl: virtual test_6_sskel +{ + test_6_simpl (int state) + : state_ (state) + { + } + + virtual void +#ifdef XSDE_STL + any (std::string& ns, std::string& name) + { +#else + any (const char*& ns, const char*& name, bool& free) + { + free = false; +#endif + switch (state_++) + { + case 7: + { + // bar + // + ns = "bar"; + name = "x"; + break; + } + case 8: + { + // local + // + ns = ""; + name = "x"; + break; + } + } + } + + virtual void + serialize_any () + { + } + +private: + int state_; +}; + +struct root_simpl: root_sskel +{ + root_simpl (int state) + : state_ (state) + { + } + + virtual choice_arm_tag + choice_arm () + { + switch (state_) + { + case 0: + return test_1_tag; + case 1: + return test_2_tag; + case 2: + case 3: + return test_3_tag; + case 4: + return test_4_tag; + case 5: + case 6: + return test_5_tag; + case 7: + case 8: + return test_5_tag; + default: + return choice_arm_tag (state_); + } + } + +private: + int state_; +}; + +int +main () +{ + for (int i = 0; i < 9; ++i) + { +#ifdef XSDE_EXCEPTIONS + try + { +#endif + test_1_simpl test_1_s; + test_2_simpl test_2_s; + test_3_simpl test_3_s (i); + test_4_simpl test_4_s; + test_5_simpl test_5_s (i); + test_6_simpl test_6_s (i); + root_simpl root_s (i); + + root_s.serializers (test_1_s, test_2_s, test_3_s, test_4_s, + test_5_s, test_6_s); + + xml_schema::document_simpl doc_s (root_s, "test", "root"); + + root_s.pre (); + + ostringstream os; + doc_s.serialize (os); + +#ifndef XSDE_EXCEPTIONS + if (xml_schema::serializer_error e = doc_s._error ()) + { + if (e.type () == xml_schema::serializer_error::schema) + { + cout << "schema: " << e.schema_text () << endl; + continue; + } + } +#endif + + root_s.post (); +#ifdef XSDE_EXCEPTIONS + } + catch (xml_schema::serializer_schema const& e) + { + cout << "schema: " << e.text () << endl; + continue; + } +#endif + + cout << "no error" << endl; + } +} diff --git a/tests/cxx/serializer/validation/any/makefile b/tests/cxx/serializer/validation/any/makefile new file mode 100644 index 0000000..2365ef1 --- /dev/null +++ b/tests/cxx/serializer/validation/any/makefile @@ -0,0 +1,72 @@ +# file : tests/cxx/serializer/validation/any/makefile +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2006-2009 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=-sskel.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 +clean := $(out_base)/.clean + + +# Build. +# +$(driver): $(obj) $(xsde.l) + +$(obj) $(dep): $(xsde.l.cpp-options) + +skel := $(out_base)/$(xsd:.xsd=-sskel.hxx) \ + $(out_base)/$(xsd:.xsd=-sskel.ixx) \ + $(out_base)/$(xsd:.xsd=-sskel.cxx) + +$(skel): xsde := $(out_root)/xsde/xsde +$(skel): $(out_root)/xsde/xsde + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) $(src_base)/output + $(call message,test $$1,$$1 | diff -u $(src_base)/output -,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=-sskel.cxx.xsd.clean)) + + +# 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/serializer/xsd-cxx.make) + + +# Dependencies. +# +$(call import,$(src_root)/xsde/makefile) +$(call import,$(src_root)/libxsde/xsde/makefile) diff --git a/tests/cxx/serializer/validation/any/output b/tests/cxx/serializer/validation/any/output new file mode 100644 index 0000000..cf16193 --- /dev/null +++ b/tests/cxx/serializer/validation/any/output @@ -0,0 +1,9 @@ +schema: expected element not encountered +schema: unexpected element encountered +schema: unexpected element encountered +schema: unexpected element encountered +schema: unexpected element encountered +schema: unexpected element encountered +schema: unexpected element encountered +schema: unexpected element encountered +schema: unexpected element encountered diff --git a/tests/cxx/serializer/validation/any/test.xsd b/tests/cxx/serializer/validation/any/test.xsd new file mode 100644 index 0000000..4457d58 --- /dev/null +++ b/tests/cxx/serializer/validation/any/test.xsd @@ -0,0 +1,53 @@ +<?xml version="1.0"?> +<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test"> + + <complexType name="test-1"> + <sequence> + <any namespace="foo" processContents="skip" maxOccurs="unbounded"/> + </sequence> + </complexType> + + <complexType name="test-2"> + <sequence> + <any namespace="##any" processContents="skip"/> + </sequence> + </complexType> + + <complexType name="test-3"> + <sequence> + <any namespace="##other" processContents="skip"/> + </sequence> + </complexType> + + <complexType name="test-4"> + <sequence> + <any namespace="##local" processContents="skip"/> + </sequence> + </complexType> + + <complexType name="test-5"> + <sequence> + <any namespace="##targetNamespace" processContents="skip"/> + </sequence> + </complexType> + + <complexType name="test-6"> + <sequence> + <any namespace="bar" processContents="skip"/> + </sequence> + </complexType> + + <complexType name="root"> + <choice> + <element name="test-1" type="t:test-1"/> + <element name="test-2" type="t:test-2"/> + <element name="test-3" type="t:test-3"/> + <element name="test-4" type="t:test-4"/> + <element name="test-5" type="t:test-5"/> + <element name="test-6" type="t:test-6"/> + </choice> + </complexType> + + <element name="root" type="t:root"/> + +</schema> diff --git a/tests/cxx/serializer/validation/attribute/driver.cxx b/tests/cxx/serializer/validation/attribute/driver.cxx new file mode 100644 index 0000000..96a4629 --- /dev/null +++ b/tests/cxx/serializer/validation/attribute/driver.cxx @@ -0,0 +1,247 @@ +// file : tests/cxx/serializer/validation/attribute/driver.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test attribute and anyAttribute validation. +// + +#include <sstream> +#include <iostream> + +#include "test-sskel.hxx" + +using namespace std; +using namespace test; + +struct test_1_simpl: virtual test_1_sskel +{ + test_1_simpl (int state) + : state_ (state) + { + } + + virtual int + x () + { + if (state_ == 0) + state_ ++; + + return 123; + } + + // ##any + // + virtual bool + any_attribute_next () + { + return state_ == 1; + } + + virtual void +#ifdef XSDE_STL + any_attribute (std::string& ns, std::string& name) + { +#else + any_attribute (const char*& ns, const char*& name, bool& free) + { + free = false; +#endif + state_++; + ns = "foo"; + name = ""; + } + + // ##other + // + virtual bool + any_attribute1_next () + { + return state_ > 1 && state_ < 4; + } + + virtual void +#ifdef XSDE_STL + any_attribute1 (std::string& ns, std::string& name) + { +#else + any_attribute1 (const char*& ns, const char*& name, bool& free) + { + free = false; +#endif + switch (state_++) + { + case 2: + { + // target + // + ns = "test"; + name = "x"; + break; + } + case 3: + { + // local + // + ns = ""; + name = "x"; + break; + } + } + } + + // ##local + // + virtual bool + any_attribute2_next () + { + return state_ == 4; + } + + virtual void +#ifdef XSDE_STL + any_attribute2 (std::string& ns, std::string& name) + { +#else + any_attribute2 (const char*& ns, const char*& name, bool& free) + { + free = false; +#endif + state_++; + ns = "foo"; + name = "x"; + } + + // ##targetNamespace + // + virtual bool + any_attribute3_next () + { + return state_ > 4 && state_ < 7; + } + + virtual void +#ifdef XSDE_STL + any_attribute3 (std::string& ns, std::string& name) + { +#else + any_attribute3 (const char*& ns, const char*& name, bool& free) + { + free = false; +#endif + switch (state_++) + { + case 5: + { + // target + // + ns = "foo"; + name = "x"; + break; + } + case 6: + { + // local + // + ns = ""; + name = "x"; + break; + } + } + } + + // foo + // + virtual bool + any_attribute4_next () + { + return state_ > 6 && state_ < 9; + } + + virtual void +#ifdef XSDE_STL + any_attribute4 (std::string& ns, std::string& name) + { +#else + any_attribute4 (const char*& ns, const char*& name, bool& free) + { + free = false; +#endif + switch (state_++) + { + case 7: + { + // bar + // + ns = "bar"; + name = "x"; + break; + } + case 8: + { + // local + // + ns = ""; + name = "x"; + break; + } + } + } + +private: + int state_; +}; + +struct root_simpl: root_sskel +{ +}; + +int +main () +{ + for (int i = 0; i < 9; ++i) + { +#ifdef XSDE_EXCEPTIONS + try + { +#endif + xml_schema::int_simpl int_s; + test_1_simpl test_1_s (i); + root_simpl root_s; + + if (i != 0) + test_1_s.serializers (int_s); + + root_s.serializers (test_1_s); + + xml_schema::document_simpl doc_s (root_s, "test", "root"); + + root_s.pre (); + + ostringstream os; + doc_s.serialize (os); + +#ifndef XSDE_EXCEPTIONS + if (xml_schema::serializer_error e = doc_s._error ()) + { + if (e.type () == xml_schema::serializer_error::schema) + { + cout << "schema: " << e.schema_text () << endl; + continue; + } + } +#endif + + root_s.post (); +#ifdef XSDE_EXCEPTIONS + } + catch (xml_schema::serializer_schema const& e) + { + cout << "schema: " << e.text () << endl; + continue; + } +#endif + + cout << "no error" << endl; + } +} diff --git a/tests/cxx/serializer/validation/attribute/makefile b/tests/cxx/serializer/validation/attribute/makefile new file mode 100644 index 0000000..586b957 --- /dev/null +++ b/tests/cxx/serializer/validation/attribute/makefile @@ -0,0 +1,72 @@ +# file : tests/cxx/serializer/validation/attribute/makefile +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2006-2009 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=-sskel.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 +clean := $(out_base)/.clean + + +# Build. +# +$(driver): $(obj) $(xsde.l) + +$(obj) $(dep): $(xsde.l.cpp-options) + +skel := $(out_base)/$(xsd:.xsd=-sskel.hxx) \ + $(out_base)/$(xsd:.xsd=-sskel.ixx) \ + $(out_base)/$(xsd:.xsd=-sskel.cxx) + +$(skel): xsde := $(out_root)/xsde/xsde +$(skel): $(out_root)/xsde/xsde + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) $(src_base)/output + $(call message,test $$1,$$1 | diff -u $(src_base)/output -,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=-sskel.cxx.xsd.clean)) + + +# 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/serializer/xsd-cxx.make) + + +# Dependencies. +# +$(call import,$(src_root)/xsde/makefile) +$(call import,$(src_root)/libxsde/xsde/makefile) diff --git a/tests/cxx/serializer/validation/attribute/output b/tests/cxx/serializer/validation/attribute/output new file mode 100644 index 0000000..2b9de1e --- /dev/null +++ b/tests/cxx/serializer/validation/attribute/output @@ -0,0 +1,9 @@ +schema: expected attribute not encountered +schema: unexpected attribute encountered +schema: unexpected attribute encountered +schema: unexpected attribute encountered +schema: unexpected attribute encountered +schema: unexpected attribute encountered +schema: unexpected attribute encountered +schema: unexpected attribute encountered +schema: unexpected attribute encountered diff --git a/tests/cxx/serializer/validation/attribute/test.xsd b/tests/cxx/serializer/validation/attribute/test.xsd new file mode 100644 index 0000000..deb3f3b --- /dev/null +++ b/tests/cxx/serializer/validation/attribute/test.xsd @@ -0,0 +1,21 @@ +<?xml version="1.0"?> +<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test"> + + <complexType name="test-1"> + <attribute name="x" type="int" use="required"/> + <anyAttribute namespace="##any" processContents="skip"/> + <anyAttribute namespace="##other" processContents="skip"/> + <anyAttribute namespace="##local" processContents="skip"/> + <anyAttribute namespace="##targetNamespace" processContents="skip"/> + <anyAttribute namespace="foo" processContents="skip"/> + </complexType> + + <complexType name="root"> + <sequence> + <element name="test-1" type="t:test-1"/> + </sequence> + </complexType> + + <element name="root" type="t:root"/> + +</schema> diff --git a/tests/cxx/serializer/validation/built-in/date-time/driver.cxx b/tests/cxx/serializer/validation/built-in/date-time/driver.cxx new file mode 100644 index 0000000..bdc196e --- /dev/null +++ b/tests/cxx/serializer/validation/built-in/date-time/driver.cxx @@ -0,0 +1,398 @@ +// file : tests/cxx/serializer/validation/built-in/date-time/driver.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the built-in date and time types validation. +// +#include <cassert> + +#include <xsde/cxx/serializer/validating/xml-schema-simpl.hxx> + +using namespace xsde::cxx; +using namespace xsde::cxx::serializer; +using namespace xsde::cxx::serializer::validating; + +int +main () +{ + using xsde::cxx::time; // Conflicts with system time. + + // gday & time zone + // + { + gday_simpl s; + context c (0); + s.pre (gday (0)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_gday_value); + } + + { + gday_simpl s; + context c (0); + s.pre (gday (32)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_gday_value); + } + + { + gday_simpl s; + context c (0); + s.pre (gday (15, 15, 0)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_gday_value); + } + + { + gday_simpl s; + context c (0); + s.pre (gday (15, 12, 60)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_gday_value); + } + + { + gday_simpl s; + context c (0); + s.pre (gday (15, -12, 30)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_gday_value); + } + + { + gday_simpl s; + context c (0); + s.pre (gday (15, 12, -30)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_gday_value); + } + + { + gday_simpl s; + context c (0); + s.pre (gday (15, 14, 1)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_gday_value); + } + + // gmonth + // + { + gmonth_simpl s; + context c (0); + s.pre (gmonth (0)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_gmonth_value); + } + + { + gmonth_simpl s; + context c (0); + s.pre (gmonth (13)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_gmonth_value); + } + + // gyear + // + { + gyear_simpl s; + context c (0); + s.pre (gyear (0)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_gyear_value); + } + + // gmonth_day + // + { + gmonth_day_simpl s; + context c (0); + s.pre (gmonth_day (0, 15)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_gmonth_day_value); + } + + { + gmonth_day_simpl s; + context c (0); + s.pre (gmonth_day (6, 0)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_gmonth_day_value); + } + + { + gmonth_day_simpl s; + context c (0); + s.pre (gmonth_day (13, 15)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_gmonth_day_value); + } + + { + gmonth_day_simpl s; + context c (0); + s.pre (gmonth_day (6, 32)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_gmonth_day_value); + } + + // gyear_month + // + { + gyear_month_simpl s; + context c (0); + s.pre (gyear_month (0, 6)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_gyear_month_value); + } + + { + gyear_month_simpl s; + context c (0); + s.pre (gyear_month (2007, 0)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_gyear_month_value); + } + + { + gyear_month_simpl s; + context c (0); + s.pre (gyear_month (2007, 32)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_gyear_month_value); + } + + // date + // + { + date_simpl s; + context c (0); + s.pre (date (0, 6, 15)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_date_value); + } + + { + date_simpl s; + context c (0); + s.pre (date (2007, 0, 15)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_date_value); + } + + { + date_simpl s; + context c (0); + s.pre (date (2007, 13, 15)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_date_value); + } + + { + date_simpl s; + context c (0); + s.pre (date (2007, 6, 0)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_date_value); + } + + { + date_simpl s; + context c (0); + s.pre (date (2007, 6, 32)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_date_value); + } + + // time + // + { + time_simpl s; + context c (0); + s.pre (time (25, 30, 30.0)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_time_value); + } + + { + time_simpl s; + context c (0); + s.pre (time (24, 1, 0)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_time_value); + } + + { + time_simpl s; + context c (0); + s.pre (time (24, 0, 0.1)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_time_value); + } + + { + time_simpl s; + context c (0); + s.pre (time (12, 60, 30)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_time_value); + } + + { + time_simpl s; + context c (0); + s.pre (time (12, 30, 60.1)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_time_value); + } + + { + time_simpl s; + context c (0); + s.pre (time (12, 30, -30.0)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_time_value); + } + + // date_time + // + { + date_time_simpl s; + context c (0); + s.pre (date_time (0, 6, 32, 12, 30, 30.0)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_date_time_value); + } + + { + date_time_simpl s; + context c (0); + s.pre (date_time (2007, 0, 32, 12, 30, 30.0)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_date_time_value); + } + + { + date_time_simpl s; + context c (0); + s.pre (date_time (2007, 13, 32, 12, 30, 30.0)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_date_time_value); + } + + { + date_time_simpl s; + context c (0); + s.pre (date_time (2007, 6, 0, 12, 30, 30.0)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_date_time_value); + } + + { + date_time_simpl s; + context c (0); + s.pre (date_time (2007, 6, 32, 12, 30, 30.0)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_date_time_value); + } + + { + date_time_simpl s; + context c (0); + s.pre (date_time (2007, 6, 15, 25, 30, 30.0)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_date_time_value); + } + + { + date_time_simpl s; + context c (0); + s.pre (date_time (2007, 6, 15, 24, 1, 0)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_date_time_value); + } + + { + date_time_simpl s; + context c (0); + s.pre (date_time (2007, 6, 15, 24, 0, 0.1)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_date_time_value); + } + + { + date_time_simpl s; + context c (0); + s.pre (date_time (2007, 6, 15, 12, 60, 30)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_date_time_value); + } + + { + date_time_simpl s; + context c (0); + s.pre (date_time (2007, 6, 15, 12, 30, 60.1)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_date_time_value); + } + + { + date_time_simpl s; + context c (0); + s.pre (date_time (2007, 6, 15, 12, 30, -30.0)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_date_time_value); + } + + // duration + // + { + duration_simpl s; + context c (0); + s.pre (duration (false, 2007, 6, 15, 12, 30, -30.0)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_duration_value); + } +} diff --git a/tests/cxx/serializer/validation/built-in/date-time/makefile b/tests/cxx/serializer/validation/built-in/date-time/makefile new file mode 100644 index 0000000..aa45e21 --- /dev/null +++ b/tests/cxx/serializer/validation/built-in/date-time/makefile @@ -0,0 +1,61 @@ +# file : tests/cxx/serializer/validation/built-in/date-time/makefile +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../../build/bootstrap.make + +cxx := driver.cxx + +obj := $(addprefix $(out_base)/,$(cxx:.cxx=.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 +clean := $(out_base)/.clean + + +# Build. +# +$(driver): $(obj) $(xsde.l) + +$(obj) $(dep): $(xsde.l.cpp-options) + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) + $(call message,test $$1,$$1,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) + + +# 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) + + +# Dependencies. +# +$(call import,$(src_root)/libxsde/xsde/makefile) diff --git a/tests/cxx/serializer/validation/built-in/decimal/driver.cxx b/tests/cxx/serializer/validation/built-in/decimal/driver.cxx new file mode 100644 index 0000000..9349e6b --- /dev/null +++ b/tests/cxx/serializer/validation/built-in/decimal/driver.cxx @@ -0,0 +1,46 @@ +// file : tests/cxx/serializer/validation/built-in/decimal/driver.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the built-in decimal type validation. +// +#include <stdlib.h> // strtod +#include <cassert> + +#include <xsde/cxx/serializer/validating/decimal.hxx> + +using namespace xsde::cxx; +using namespace xsde::cxx::serializer; +using namespace xsde::cxx::serializer::validating; + +int +main () +{ + { + decimal_simpl s; + context c (0); + s.pre (strtod ("NAN", 0)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_decimal_value); + } + + { + decimal_simpl s; + context c (0); + s.pre (strtod ("INF", 0)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_decimal_value); + } + + { + decimal_simpl s; + context c (0); + s.pre (strtod ("-INF", 0)); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_decimal_value); + } +} diff --git a/tests/cxx/serializer/validation/built-in/decimal/makefile b/tests/cxx/serializer/validation/built-in/decimal/makefile new file mode 100644 index 0000000..e4517b6 --- /dev/null +++ b/tests/cxx/serializer/validation/built-in/decimal/makefile @@ -0,0 +1,61 @@ +# file : tests/cxx/serializer/validation/built-in/decimal/makefile +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../../build/bootstrap.make + +cxx := driver.cxx + +obj := $(addprefix $(out_base)/,$(cxx:.cxx=.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 +clean := $(out_base)/.clean + + +# Build. +# +$(driver): $(obj) $(xsde.l) + +$(obj) $(dep): $(xsde.l.cpp-options) + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) + $(call message,test $$1,$$1,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) + + +# 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) + + +# Dependencies. +# +$(call import,$(src_root)/libxsde/xsde/makefile) diff --git a/tests/cxx/serializer/validation/built-in/integer/driver.cxx b/tests/cxx/serializer/validation/built-in/integer/driver.cxx new file mode 100644 index 0000000..e20a561 --- /dev/null +++ b/tests/cxx/serializer/validation/built-in/integer/driver.cxx @@ -0,0 +1,63 @@ +// file : tests/cxx/serializer/validation/built-in/int/driver.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the built-in integer & friends types validation. +// + +#include <cassert> + +#include <xsde/cxx/serializer/validating/negative-integer.hxx> +#include <xsde/cxx/serializer/validating/non-positive-integer.hxx> +#include <xsde/cxx/serializer/validating/positive-integer.hxx> + +using namespace xsde::cxx::serializer; +using namespace xsde::cxx::serializer::validating; +using namespace std; + +int +main () +{ + // negative_integer + // + { + negative_integer_simpl s; + context c (0); + s.pre (0); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error ()); + } + + { + negative_integer_simpl s; + context c (0); + s.pre (1); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error ()); + } + + // non_positive_integer + // + { + non_positive_integer_simpl s; + context c (0); + s.pre (1); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error ()); + } + + // positive_integer + // + { + positive_integer_simpl s; + context c (0); + s.pre (0); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error ()); + } +} diff --git a/tests/cxx/serializer/validation/built-in/integer/makefile b/tests/cxx/serializer/validation/built-in/integer/makefile new file mode 100644 index 0000000..37bd439 --- /dev/null +++ b/tests/cxx/serializer/validation/built-in/integer/makefile @@ -0,0 +1,61 @@ +# file : tests/cxx/serializer/validation/built-in/integer/makefile +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../../build/bootstrap.make + +cxx := driver.cxx + +obj := $(addprefix $(out_base)/,$(cxx:.cxx=.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 +clean := $(out_base)/.clean + + +# Build. +# +$(driver): $(obj) $(xsde.l) + +$(obj) $(dep): $(xsde.l.cpp-options) + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) + $(call message,test $$1,$$1,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) + + +# 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) + + +# Dependencies. +# +$(call import,$(src_root)/libxsde/xsde/makefile) diff --git a/tests/cxx/serializer/validation/built-in/makefile b/tests/cxx/serializer/validation/built-in/makefile new file mode 100644 index 0000000..7fdeec7 --- /dev/null +++ b/tests/cxx/serializer/validation/built-in/makefile @@ -0,0 +1,20 @@ +# file : tests/cxx/serializer/validation/built-in/makefile +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make + +tests := date-time decimal integer qname string + +default := $(out_base)/ +test := $(out_base)/.test +clean := $(out_base)/.clean + +.PHONY: $(default) $(test) $(clean) + +$(default): $(addprefix $(out_base)/,$(addsuffix /,$(tests))) +$(test): $(addprefix $(out_base)/,$(addsuffix /.test,$(tests))) +$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(tests))) + +$(foreach t,$(tests),$(call import,$(src_base)/$t/makefile)) diff --git a/tests/cxx/serializer/validation/built-in/qname/driver.cxx b/tests/cxx/serializer/validation/built-in/qname/driver.cxx new file mode 100644 index 0000000..33ccdc1 --- /dev/null +++ b/tests/cxx/serializer/validation/built-in/qname/driver.cxx @@ -0,0 +1,70 @@ +// file : tests/cxx/serializer/validation/built-in/qname/driver.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the built-in QName type validation. +// +#include <cassert> + +#include <xsde/config.h> + +// Let the runtime header sort out which version (stl/no-stl) to +// include. +// +#include <xsde/cxx/serializer/validating/xml-schema-simpl.hxx> + +using namespace xsde::cxx; +using namespace xsde::cxx::serializer; +using namespace xsde::cxx::serializer::validating; + +int +main () +{ + { + qname_simpl s; + context c (0); +#ifdef XSDE_STL + s.pre (qname ("a b")); +#else + qname qn; + qn.name_copy ("a b"); + s.pre (&qn); +#endif + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_qname_value); + } + + { + qname_simpl s; + context c (0); +#ifdef XSDE_STL + s.pre (qname ("ab", "a b")); +#else + qname qn; + qn.name_copy ("a b"); + qn.prefix_copy ("ab"); + s.pre (&qn); +#endif + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_qname_value); + } + + { + qname_simpl s; + context c (0); +#ifdef XSDE_STL + s.pre (qname ("a b", "ab")); +#else + qname qn; + qn.name_copy ("ab"); + qn.prefix_copy ("a b"); + s.pre (&qn); +#endif + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_qname_value); + } +} diff --git a/tests/cxx/serializer/validation/built-in/qname/makefile b/tests/cxx/serializer/validation/built-in/qname/makefile new file mode 100644 index 0000000..ec2d802 --- /dev/null +++ b/tests/cxx/serializer/validation/built-in/qname/makefile @@ -0,0 +1,61 @@ +# file : tests/cxx/serializer/validation/built-in/qname/makefile +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../../build/bootstrap.make + +cxx := driver.cxx + +obj := $(addprefix $(out_base)/,$(cxx:.cxx=.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 +clean := $(out_base)/.clean + + +# Build. +# +$(driver): $(obj) $(xsde.l) + +$(obj) $(dep): $(xsde.l.cpp-options) + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) + $(call message,test $$1,$$1,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) + + +# 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) + + +# Dependencies. +# +$(call import,$(src_root)/libxsde/xsde/makefile) diff --git a/tests/cxx/serializer/validation/built-in/string/driver.cxx b/tests/cxx/serializer/validation/built-in/string/driver.cxx new file mode 100644 index 0000000..c1cfe21 --- /dev/null +++ b/tests/cxx/serializer/validation/built-in/string/driver.cxx @@ -0,0 +1,485 @@ +// file : tests/cxx/serializer/validation/built-in/string/driver.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the built-in string & friends types validation. +// +#include <string> +#include <cassert> + +#include <xsde/config.h> + +// Let the runtime header sort out which version (stl/no-stl) to +// include. +// +#include <xsde/cxx/serializer/validating/xml-schema-simpl.hxx> + +using namespace xsde::cxx; +using namespace xsde::cxx::serializer; +using namespace xsde::cxx::serializer::validating; + +int +main () +{ + // normalized_string + // + { + normalized_string_simpl s; + context c (0); + s.pre ("aaa\nbbb"); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_normalized_string_value); + } + + { + normalized_string_simpl s; + context c (0); + s.pre ("aaa\tbbb"); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_normalized_string_value); + } + + { + normalized_string_simpl s; + context c (0); + s.pre ("aaa\rbbb"); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_normalized_string_value); + } + + // token + // + { + token_simpl s; + context c (0); + s.pre ("aaa\nbbb"); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_token_value); + } + + { + token_simpl s; + context c (0); + s.pre ("aaa\tbbb"); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_token_value); + } + + { + token_simpl s; + context c (0); + s.pre ("aaa\rbbb"); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_token_value); + } + + { + token_simpl s; + context c (0); + s.pre ("aaa bbb"); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_token_value); + } + + { + token_simpl s; + context c (0); + s.pre (" aaa bbb"); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_token_value); + } + + { + token_simpl s; + context c (0); + s.pre ("aaa bbb "); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_token_value); + } + + // name + // + { + name_simpl s; + context c (0); + s.pre (""); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_name_value); + } + + { + name_simpl s; + context c (0); + s.pre (".a"); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_name_value); + } + + { + name_simpl s; + context c (0); + s.pre ("-a"); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_name_value); + } + + { + name_simpl s; + context c (0); + s.pre ("1a"); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_name_value); + } + + { + name_simpl s; + context c (0); + s.pre (" a"); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_name_value); + } + + { + name_simpl s; + context c (0); + s.pre ("a,b"); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_name_value); + } + + { + name_simpl s; + context c (0); + s.pre ("a b"); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_name_value); + } + + { + name_simpl s; + context c (0); + s.pre ("a<b"); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_name_value); + } + + { + name_simpl s; + context c (0); + s.pre ("a "); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_name_value); + } + + // nmtoken + // + { + nmtoken_simpl s; + context c (0); + s.pre (""); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_nmtoken_value); + } + + { + nmtoken_simpl s; + context c (0); + s.pre (" a"); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_nmtoken_value); + } + + { + nmtoken_simpl s; + context c (0); + s.pre ("a,b"); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_nmtoken_value); + } + + { + nmtoken_simpl s; + context c (0); + s.pre ("a b"); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_nmtoken_value); + } + + { + nmtoken_simpl s; + context c (0); + s.pre ("a<b"); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_nmtoken_value); + } + + { + nmtoken_simpl s; + context c (0); + s.pre ("a "); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_nmtoken_value); + } + + // nmtokens + // + { + nmtokens_simpl s; + context c (0); + string_sequence seq; + s.pre (&seq); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_nmtokens_value); + } + + { + nmtokens_simpl s; + context c (0); + string_sequence seq; +#ifdef XSDE_STL + seq.push_back ("a,b"); + seq.push_back ("ab"); +#else + seq.push_back_copy ("a,b"); + seq.push_back_copy ("ab"); +#endif + s.pre (&seq); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_nmtoken_value); + } + + // ncname + // + { + ncname_simpl s; + context c (0); + s.pre (""); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_ncname_value); + } + + { + ncname_simpl s; + context c (0); + s.pre (" a"); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_ncname_value); + } + + { + ncname_simpl s; + context c (0); + s.pre (".a"); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_ncname_value); + } + + { + ncname_simpl s; + context c (0); + s.pre ("-a"); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_ncname_value); + } + + { + ncname_simpl s; + context c (0); + s.pre (":a"); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_ncname_value); + } + + { + ncname_simpl s; + context c (0); + s.pre ("1a"); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_ncname_value); + } + + { + ncname_simpl s; + context c (0); + s.pre ("a,b"); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_ncname_value); + } + + { + ncname_simpl s; + context c (0); + s.pre ("a b"); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_ncname_value); + } + + { + ncname_simpl s; + context c (0); + s.pre ("a:b"); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_ncname_value); + } + + { + ncname_simpl s; + context c (0); + s.pre ("a<b"); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_ncname_value); + } + + { + ncname_simpl s; + context c (0); + s.pre ("a "); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_ncname_value); + } + + // id + // + { + id_simpl s; + context c (0); + s.pre ("a b"); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_id_value); + } + + // idref + // + { + idref_simpl s; + context c (0); + s.pre ("a b"); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_idref_value); + } + + // idrefs + // + { + idrefs_simpl s; + context c (0); + string_sequence seq; + s.pre (&seq); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_idrefs_value); + } + + { + idrefs_simpl s; + context c (0); + string_sequence seq; +#ifdef XSDE_STL + seq.push_back ("a,b"); + seq.push_back ("ab"); +#else + seq.push_back_copy ("a,b"); + seq.push_back_copy ("ab"); +#endif + s.pre (&seq); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_idref_value); + } + + // language + // + { + language_simpl s; + context c (0); + s.pre (""); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_language_value); + } + + { + language_simpl s; + context c (0); + s.pre (" "); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_language_value); + } + + { + language_simpl s; + context c (0); + s.pre ("en-"); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_language_value); + } + + { + language_simpl s; + context c (0); + s.pre ("a1"); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_language_value); + } + + { + language_simpl s; + context c (0); + s.pre ("en+us"); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_language_value); + } + + { + language_simpl s; + context c (0); + s.pre ("en-nine99999"); + s._pre_impl (c); + s._serialize_content (); + assert (c.schema_error () == schema_error::invalid_language_value); + } +} diff --git a/tests/cxx/serializer/validation/built-in/string/makefile b/tests/cxx/serializer/validation/built-in/string/makefile new file mode 100644 index 0000000..42a7d81 --- /dev/null +++ b/tests/cxx/serializer/validation/built-in/string/makefile @@ -0,0 +1,61 @@ +# file : tests/cxx/serializer/validation/built-in/string/makefile +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../../build/bootstrap.make + +cxx := driver.cxx + +obj := $(addprefix $(out_base)/,$(cxx:.cxx=.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 +clean := $(out_base)/.clean + + +# Build. +# +$(driver): $(obj) $(xsde.l) + +$(obj) $(dep): $(xsde.l.cpp-options) + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) + $(call message,test $$1,$$1,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) + + +# 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) + + +# Dependencies. +# +$(call import,$(src_root)/libxsde/xsde/makefile) diff --git a/tests/cxx/serializer/validation/choice/driver.cxx b/tests/cxx/serializer/validation/choice/driver.cxx new file mode 100644 index 0000000..11e1aaa --- /dev/null +++ b/tests/cxx/serializer/validation/choice/driver.cxx @@ -0,0 +1,114 @@ +// file : tests/cxx/serializer/validation/choice/driver.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test choice validation. +// + +#include <sstream> +#include <iostream> + +#include "test-sskel.hxx" + +using namespace std; +using namespace test; + +struct test_1_simpl: virtual test_1_sskel +{ + test_1_simpl (int state) + : state_ (state) + { + } + + virtual bool + choice_next () + { + return true; + } + + virtual choice_arm_tag + choice_arm () + { + return static_cast<choice_arm_tag> (state_); + } + + // + // + virtual bool + choice1_next () + { + return false; + } + + virtual choice1_arm_tag + choice1_arm () + { + return a_tag; + } + + virtual int + a () + { + return 123; + } + + virtual int + b () + { + return 234; + } + +private: + int state_; +}; + +struct root_simpl: root_sskel +{ +}; + +int +main () +{ + for (int i = 0; i < 2; ++i) + { +#ifdef XSDE_EXCEPTIONS + try + { +#endif + test_1_simpl test_1_s (i); + root_simpl root_s; + + root_s.serializers (test_1_s); + + xml_schema::document_simpl doc_s (root_s, "test", "root"); + + root_s.pre (); + + ostringstream os; + doc_s.serialize (os); + +#ifndef XSDE_EXCEPTIONS + if (xml_schema::serializer_error e = doc_s._error ()) + { + if (e.type () == xml_schema::serializer_error::schema) + { + cout << "schema: " << e.schema_text () << endl; + continue; + } + } +#endif + + root_s.post (); +#ifdef XSDE_EXCEPTIONS + } + catch (xml_schema::serializer_schema const& e) + { + cout << "schema: " << e.text () << endl; + continue; + } +#endif + + cout << "no error" << endl; + } +} diff --git a/tests/cxx/serializer/validation/choice/makefile b/tests/cxx/serializer/validation/choice/makefile new file mode 100644 index 0000000..79d45eb --- /dev/null +++ b/tests/cxx/serializer/validation/choice/makefile @@ -0,0 +1,72 @@ +# file : tests/cxx/serializer/validation/choice/makefile +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2006-2009 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=-sskel.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 +clean := $(out_base)/.clean + + +# Build. +# +$(driver): $(obj) $(xsde.l) + +$(obj) $(dep): $(xsde.l.cpp-options) + +skel := $(out_base)/$(xsd:.xsd=-sskel.hxx) \ + $(out_base)/$(xsd:.xsd=-sskel.ixx) \ + $(out_base)/$(xsd:.xsd=-sskel.cxx) + +$(skel): xsde := $(out_root)/xsde/xsde +$(skel): $(out_root)/xsde/xsde + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) $(src_base)/output + $(call message,test $$1,$$1 | diff -u $(src_base)/output -,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=-sskel.cxx.xsd.clean)) + + +# 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/serializer/xsd-cxx.make) + + +# Dependencies. +# +$(call import,$(src_root)/xsde/makefile) +$(call import,$(src_root)/libxsde/xsde/makefile) diff --git a/tests/cxx/serializer/validation/choice/output b/tests/cxx/serializer/validation/choice/output new file mode 100644 index 0000000..7ec90f4 --- /dev/null +++ b/tests/cxx/serializer/validation/choice/output @@ -0,0 +1,2 @@ +schema: expected element not encountered +schema: unexpected element encountered diff --git a/tests/cxx/serializer/validation/choice/test.xsd b/tests/cxx/serializer/validation/choice/test.xsd new file mode 100644 index 0000000..b87d638 --- /dev/null +++ b/tests/cxx/serializer/validation/choice/test.xsd @@ -0,0 +1,21 @@ +<?xml version="1.0"?> +<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test"> + + <complexType name="test-1"> + <choice maxOccurs="5"> + <choice maxOccurs="unbounded"> <!-- 1..unbounded--> + <element name="a" type="int"/> + <element name="b" type="int"/> + </choice> + </choice> + </complexType> + + <complexType name="root"> + <sequence> + <element name="test-1" type="t:test-1"/> + </sequence> + </complexType> + + <element name="root" type="t:root"/> + +</schema> diff --git a/tests/cxx/serializer/validation/element/driver.cxx b/tests/cxx/serializer/validation/element/driver.cxx new file mode 100644 index 0000000..b0ff7ed --- /dev/null +++ b/tests/cxx/serializer/validation/element/driver.cxx @@ -0,0 +1,106 @@ +// file : tests/cxx/serializer/validation/element/driver.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test element validation. +// + +#include <sstream> +#include <iostream> + +#include "test-sskel.hxx" + +using namespace std; +using namespace test; + +struct test_1_simpl: virtual test_1_sskel +{ + test_1_simpl (int state) + : state_ (state) + { + } + + virtual bool + a_next () + { + if (state_ == 0) + { + state_++; + return true; + } + + return false; + } + + virtual int + a () + { + return 123; + } + + virtual bool + b_next () + { + return false; + } + + virtual int + b () + { + return 234; + } + +private: + int state_; +}; + +struct root_simpl: root_sskel +{ +}; + +int +main () +{ + for (int i = 0; i < 2; ++i) + { +#ifdef XSDE_EXCEPTIONS + try + { +#endif + test_1_simpl test_1_s (i); + root_simpl root_s; + + root_s.serializers (test_1_s); + + xml_schema::document_simpl doc_s (root_s, "test", "root"); + + root_s.pre (); + + ostringstream os; + doc_s.serialize (os); + +#ifndef XSDE_EXCEPTIONS + if (xml_schema::serializer_error e = doc_s._error ()) + { + if (e.type () == xml_schema::serializer_error::schema) + { + cout << "schema: " << e.schema_text () << endl; + continue; + } + } +#endif + + root_s.post (); +#ifdef XSDE_EXCEPTIONS + } + catch (xml_schema::serializer_schema const& e) + { + cout << "schema: " << e.text () << endl; + continue; + } +#endif + + cout << "no error" << endl; + } +} diff --git a/tests/cxx/serializer/validation/element/makefile b/tests/cxx/serializer/validation/element/makefile new file mode 100644 index 0000000..ef916ed --- /dev/null +++ b/tests/cxx/serializer/validation/element/makefile @@ -0,0 +1,72 @@ +# file : tests/cxx/serializer/validation/element/makefile +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2006-2009 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=-sskel.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 +clean := $(out_base)/.clean + + +# Build. +# +$(driver): $(obj) $(xsde.l) + +$(obj) $(dep): $(xsde.l.cpp-options) + +skel := $(out_base)/$(xsd:.xsd=-sskel.hxx) \ + $(out_base)/$(xsd:.xsd=-sskel.ixx) \ + $(out_base)/$(xsd:.xsd=-sskel.cxx) + +$(skel): xsde := $(out_root)/xsde/xsde +$(skel): $(out_root)/xsde/xsde + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) $(src_base)/output + $(call message,test $$1,$$1 | diff -u $(src_base)/output -,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=-sskel.cxx.xsd.clean)) + + +# 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/serializer/xsd-cxx.make) + + +# Dependencies. +# +$(call import,$(src_root)/xsde/makefile) +$(call import,$(src_root)/libxsde/xsde/makefile) diff --git a/tests/cxx/serializer/validation/element/output b/tests/cxx/serializer/validation/element/output new file mode 100644 index 0000000..e8e09d0 --- /dev/null +++ b/tests/cxx/serializer/validation/element/output @@ -0,0 +1,2 @@ +schema: expected element not encountered +schema: expected element not encountered diff --git a/tests/cxx/serializer/validation/element/test.xsd b/tests/cxx/serializer/validation/element/test.xsd new file mode 100644 index 0000000..7f20008 --- /dev/null +++ b/tests/cxx/serializer/validation/element/test.xsd @@ -0,0 +1,19 @@ +<?xml version="1.0"?> +<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test"> + + <complexType name="test-1"> + <sequence> + <element name="a" type="int" minOccurs="0" maxOccurs="5"/> + <element name="b" type="int" maxOccurs="unbounded"/> + </sequence> + </complexType> + + <complexType name="root"> + <sequence> + <element name="test-1" type="t:test-1"/> + </sequence> + </complexType> + + <element name="root" type="t:root"/> + +</schema> diff --git a/tests/cxx/serializer/validation/makefile b/tests/cxx/serializer/validation/makefile new file mode 100644 index 0000000..1304574 --- /dev/null +++ b/tests/cxx/serializer/validation/makefile @@ -0,0 +1,24 @@ +# file : tests/cxx/serializer/validation/makefile +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make + +tests := built-in + +ifeq ($(xsde_iostream),y) +tests += any attribute choice element sequence +endif + +default := $(out_base)/ +test := $(out_base)/.test +clean := $(out_base)/.clean + +.PHONY: $(default) $(test) $(clean) + +$(default): $(addprefix $(out_base)/,$(addsuffix /,$(tests))) +$(test): $(addprefix $(out_base)/,$(addsuffix /.test,$(tests))) +$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(tests))) + +$(foreach t,$(tests),$(call import,$(src_base)/$t/makefile)) diff --git a/tests/cxx/serializer/validation/sequence/driver.cxx b/tests/cxx/serializer/validation/sequence/driver.cxx new file mode 100644 index 0000000..562874c --- /dev/null +++ b/tests/cxx/serializer/validation/sequence/driver.cxx @@ -0,0 +1,102 @@ +// file : tests/cxx/serializer/validation/sequence/driver.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test sequence validation. +// + +#include <sstream> +#include <iostream> + +#include "test-sskel.hxx" + +using namespace std; +using namespace test; + +struct test_1_simpl: virtual test_1_sskel +{ + test_1_simpl (int state) + : state_ (state) + { + } + + virtual bool + sequence_next () + { + return true; + } + + // + // + virtual bool + sequence1_next () + { + return false; + } + + virtual int + a () + { + return 123; + } + + virtual int + b () + { + return 234; + } + +private: + int state_; +}; + +struct root_simpl: root_sskel +{ +}; + +int +main () +{ + for (int i = 0; i < 1; ++i) + { +#ifdef XSDE_EXCEPTIONS + try + { +#endif + test_1_simpl test_1_s (i); + root_simpl root_s; + + root_s.serializers (test_1_s); + + xml_schema::document_simpl doc_s (root_s, "test", "root"); + + root_s.pre (); + + ostringstream os; + doc_s.serialize (os); + +#ifndef XSDE_EXCEPTIONS + if (xml_schema::serializer_error e = doc_s._error ()) + { + if (e.type () == xml_schema::serializer_error::schema) + { + cout << "schema: " << e.schema_text () << endl; + continue; + } + } +#endif + + root_s.post (); +#ifdef XSDE_EXCEPTIONS + } + catch (xml_schema::serializer_schema const& e) + { + cout << "schema: " << e.text () << endl; + continue; + } +#endif + + cout << "no error" << endl; + } +} diff --git a/tests/cxx/serializer/validation/sequence/makefile b/tests/cxx/serializer/validation/sequence/makefile new file mode 100644 index 0000000..e16d8bf --- /dev/null +++ b/tests/cxx/serializer/validation/sequence/makefile @@ -0,0 +1,72 @@ +# file : tests/cxx/serializer/validation/sequence/makefile +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2006-2009 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=-sskel.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 +clean := $(out_base)/.clean + + +# Build. +# +$(driver): $(obj) $(xsde.l) + +$(obj) $(dep): $(xsde.l.cpp-options) + +skel := $(out_base)/$(xsd:.xsd=-sskel.hxx) \ + $(out_base)/$(xsd:.xsd=-sskel.ixx) \ + $(out_base)/$(xsd:.xsd=-sskel.cxx) + +$(skel): xsde := $(out_root)/xsde/xsde +$(skel): $(out_root)/xsde/xsde + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) $(src_base)/output + $(call message,test $$1,$$1 | diff -u $(src_base)/output -,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=-sskel.cxx.xsd.clean)) + + +# 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/serializer/xsd-cxx.make) + + +# Dependencies. +# +$(call import,$(src_root)/xsde/makefile) +$(call import,$(src_root)/libxsde/xsde/makefile) diff --git a/tests/cxx/serializer/validation/sequence/output b/tests/cxx/serializer/validation/sequence/output new file mode 100644 index 0000000..3333a0c --- /dev/null +++ b/tests/cxx/serializer/validation/sequence/output @@ -0,0 +1 @@ +schema: expected element not encountered diff --git a/tests/cxx/serializer/validation/sequence/test.xsd b/tests/cxx/serializer/validation/sequence/test.xsd new file mode 100644 index 0000000..d7b2517 --- /dev/null +++ b/tests/cxx/serializer/validation/sequence/test.xsd @@ -0,0 +1,21 @@ +<?xml version="1.0"?> +<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test"> + + <complexType name="test-1"> + <sequence maxOccurs="5"> + <sequence maxOccurs="unbounded"> <!-- 1..unbounded--> + <element name="a" type="int"/> + <element name="b" type="int"/> + </sequence> + </sequence> + </complexType> + + <complexType name="root"> + <sequence> + <element name="test-1" type="t:test-1"/> + </sequence> + </complexType> + + <element name="root" type="t:root"/> + +</schema> |