aboutsummaryrefslogtreecommitdiff
path: root/tests/cxx/parser/validation
diff options
context:
space:
mode:
Diffstat (limited to 'tests/cxx/parser/validation')
-rw-r--r--tests/cxx/parser/validation/all/driver.cxx121
-rw-r--r--tests/cxx/parser/validation/all/makefile82
-rw-r--r--tests/cxx/parser/validation/all/test-000.std46
-rw-r--r--tests/cxx/parser/validation/all/test-000.xml53
-rw-r--r--tests/cxx/parser/validation/all/test-001.std6
-rw-r--r--tests/cxx/parser/validation/all/test-001.xml11
-rw-r--r--tests/cxx/parser/validation/all/test-002.std4
-rw-r--r--tests/cxx/parser/validation/all/test-002.xml9
-rw-r--r--tests/cxx/parser/validation/all/test-003.std6
-rw-r--r--tests/cxx/parser/validation/all/test-003.xml12
-rw-r--r--tests/cxx/parser/validation/all/test.xsd20
-rw-r--r--tests/cxx/parser/validation/any/driver.cxx139
-rw-r--r--tests/cxx/parser/validation/any/makefile82
-rw-r--r--tests/cxx/parser/validation/any/test-000.std29
-rw-r--r--tests/cxx/parser/validation/any/test-000.xml21
-rw-r--r--tests/cxx/parser/validation/any/test.xsd20
-rw-r--r--tests/cxx/parser/validation/attribute/driver.cxx275
-rw-r--r--tests/cxx/parser/validation/attribute/makefile72
-rw-r--r--tests/cxx/parser/validation/attribute/output24
-rw-r--r--tests/cxx/parser/validation/attribute/test.xml10
-rw-r--r--tests/cxx/parser/validation/attribute/test.xsd71
-rw-r--r--tests/cxx/parser/validation/built-in/any-type/driver.cxx187
-rw-r--r--tests/cxx/parser/validation/built-in/any-type/makefile82
-rw-r--r--tests/cxx/parser/validation/built-in/any-type/test-000.std113
-rw-r--r--tests/cxx/parser/validation/built-in/any-type/test-000.xml41
-rw-r--r--tests/cxx/parser/validation/built-in/any-type/test.xsd31
-rw-r--r--tests/cxx/parser/validation/built-in/binary/driver.cxx176
-rw-r--r--tests/cxx/parser/validation/built-in/binary/makefile61
-rw-r--r--tests/cxx/parser/validation/built-in/boolean/driver.cxx150
-rw-r--r--tests/cxx/parser/validation/built-in/boolean/makefile61
-rw-r--r--tests/cxx/parser/validation/built-in/byte/driver.cxx280
-rw-r--r--tests/cxx/parser/validation/built-in/byte/makefile61
-rw-r--r--tests/cxx/parser/validation/built-in/date-time/driver.cxx1833
-rw-r--r--tests/cxx/parser/validation/built-in/date-time/makefile61
-rw-r--r--tests/cxx/parser/validation/built-in/float/driver.cxx309
-rw-r--r--tests/cxx/parser/validation/built-in/float/makefile61
-rw-r--r--tests/cxx/parser/validation/built-in/int/driver.cxx116
-rw-r--r--tests/cxx/parser/validation/built-in/int/makefile61
-rw-r--r--tests/cxx/parser/validation/built-in/integer/driver.cxx317
-rw-r--r--tests/cxx/parser/validation/built-in/integer/makefile61
-rw-r--r--tests/cxx/parser/validation/built-in/long-long/driver.cxx118
-rw-r--r--tests/cxx/parser/validation/built-in/long-long/makefile61
-rw-r--r--tests/cxx/parser/validation/built-in/long/driver.cxx106
-rw-r--r--tests/cxx/parser/validation/built-in/long/makefile61
-rw-r--r--tests/cxx/parser/validation/built-in/makefile35
-rw-r--r--tests/cxx/parser/validation/built-in/qname/driver.cxx132
-rw-r--r--tests/cxx/parser/validation/built-in/qname/makefile61
-rw-r--r--tests/cxx/parser/validation/built-in/short/driver.cxx116
-rw-r--r--tests/cxx/parser/validation/built-in/short/makefile61
-rw-r--r--tests/cxx/parser/validation/built-in/string/driver.cxx613
-rw-r--r--tests/cxx/parser/validation/built-in/string/makefile61
-rw-r--r--tests/cxx/parser/validation/built-in/uri/driver.cxx66
-rw-r--r--tests/cxx/parser/validation/built-in/uri/makefile61
-rw-r--r--tests/cxx/parser/validation/choice/driver.cxx158
-rw-r--r--tests/cxx/parser/validation/choice/makefile81
-rw-r--r--tests/cxx/parser/validation/choice/test-000.std22
-rw-r--r--tests/cxx/parser/validation/choice/test-000.xml30
-rw-r--r--tests/cxx/parser/validation/choice/test-001.std4
-rw-r--r--tests/cxx/parser/validation/choice/test-001.xml10
-rw-r--r--tests/cxx/parser/validation/choice/test-002.std11
-rw-r--r--tests/cxx/parser/validation/choice/test-002.xml17
-rw-r--r--tests/cxx/parser/validation/choice/test-003.std5
-rw-r--r--tests/cxx/parser/validation/choice/test-003.xml11
-rw-r--r--tests/cxx/parser/validation/choice/test-004.std4
-rw-r--r--tests/cxx/parser/validation/choice/test-004.xml11
-rw-r--r--tests/cxx/parser/validation/choice/test.xsd24
-rw-r--r--tests/cxx/parser/validation/makefile26
-rw-r--r--tests/cxx/parser/validation/restriction/driver.cxx122
-rw-r--r--tests/cxx/parser/validation/restriction/makefile81
-rw-r--r--tests/cxx/parser/validation/restriction/test-000.std0
-rw-r--r--tests/cxx/parser/validation/restriction/test-000.xml31
-rw-r--r--tests/cxx/parser/validation/restriction/test-001.std1
-rw-r--r--tests/cxx/parser/validation/restriction/test-001.xml11
-rw-r--r--tests/cxx/parser/validation/restriction/test-002.std1
-rw-r--r--tests/cxx/parser/validation/restriction/test-002.xml12
-rw-r--r--tests/cxx/parser/validation/restriction/test-003.std1
-rw-r--r--tests/cxx/parser/validation/restriction/test-003.xml16
-rw-r--r--tests/cxx/parser/validation/restriction/test-004.std1
-rw-r--r--tests/cxx/parser/validation/restriction/test-004.xml10
-rw-r--r--tests/cxx/parser/validation/restriction/test-005.std1
-rw-r--r--tests/cxx/parser/validation/restriction/test-005.xml11
-rw-r--r--tests/cxx/parser/validation/restriction/test.xsd82
-rw-r--r--tests/cxx/parser/validation/sequence/driver.cxx185
-rw-r--r--tests/cxx/parser/validation/sequence/makefile81
-rw-r--r--tests/cxx/parser/validation/sequence/test-000.std56
-rw-r--r--tests/cxx/parser/validation/sequence/test-000.xml46
-rw-r--r--tests/cxx/parser/validation/sequence/test-001.std4
-rw-r--r--tests/cxx/parser/validation/sequence/test-001.xml10
-rw-r--r--tests/cxx/parser/validation/sequence/test-002.std20
-rw-r--r--tests/cxx/parser/validation/sequence/test-002.xml27
-rw-r--r--tests/cxx/parser/validation/sequence/test-003.std5
-rw-r--r--tests/cxx/parser/validation/sequence/test-003.xml17
-rw-r--r--tests/cxx/parser/validation/sequence/test-004.std4
-rw-r--r--tests/cxx/parser/validation/sequence/test-004.xml14
-rw-r--r--tests/cxx/parser/validation/sequence/test-005.std6
-rw-r--r--tests/cxx/parser/validation/sequence/test-005.xml15
-rw-r--r--tests/cxx/parser/validation/sequence/test-006.std13
-rw-r--r--tests/cxx/parser/validation/sequence/test-006.xml17
-rw-r--r--tests/cxx/parser/validation/sequence/test.xsd28
99 files changed, 8070 insertions, 0 deletions
diff --git a/tests/cxx/parser/validation/all/driver.cxx b/tests/cxx/parser/validation/all/driver.cxx
new file mode 100644
index 0000000..7498465
--- /dev/null
+++ b/tests/cxx/parser/validation/all/driver.cxx
@@ -0,0 +1,121 @@
+// file : tests/cxx/parser/validation/all/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 all compositor validation.
+//
+
+#include <string>
+#include <iostream>
+
+#include "test-pskel.hxx"
+
+using namespace std;
+using namespace test;
+
+struct all_pimpl: all_pskel
+{
+ virtual void
+ pre ()
+ {
+ cout << "{" << endl;
+ }
+
+#ifdef XSDE_STL
+ virtual void
+ a (string const& v)
+ {
+ cout << " a = " << v << endl;
+ }
+
+ virtual void
+ b (string const& v)
+ {
+ cout << " b = " << v << endl;
+ }
+
+ virtual void
+ c (string const& v)
+ {
+ cout << " c = " << v << endl;
+ }
+#else
+ virtual void
+ a (char* v)
+ {
+ cout << " a = " << v << endl;
+ delete[] v;
+ }
+
+ virtual void
+ b (char* v)
+ {
+ cout << " b = " << v << endl;
+ delete[] v;
+ }
+
+ virtual void
+ c (char* v)
+ {
+ cout << " c = " << v << endl;
+ delete[] v;
+ }
+#endif
+
+ virtual void
+ post_all ()
+ {
+ cout << "}" << endl
+ << endl;
+ }
+};
+
+struct type_pimpl: type_pskel
+{
+};
+
+int
+main (int argc, char* argv[])
+{
+ if (argc != 2)
+ {
+ cerr << "usage: " << argv[0] << " test.xml" << endl;
+ return 1;
+ }
+
+ try
+ {
+ xml_schema::string_pimpl string_p;
+ all_pimpl all_p;
+ type_pimpl type_p;
+
+ all_p.parsers (string_p, string_p, string_p);
+ type_p.parsers (all_p);
+
+ xml_schema::document_pimpl doc_p (type_p, "test", "root");
+
+ try
+ {
+ type_p.pre ();
+ doc_p.parse (argv[1]);
+ type_p.post_type ();
+ }
+ catch (xml_schema::parser_exception const& e)
+ {
+ cout << " " << e.line () << ":" << e.column () << " " << e << endl
+ << "}" << endl
+ << endl;
+ }
+ }
+ catch (xml_schema::parser_exception const& e)
+ {
+ cerr << e << endl;
+ return 1;
+ }
+ catch (ios_base::failure const&)
+ {
+ cerr << "io failure" << endl;
+ return 1;
+ }
+}
diff --git a/tests/cxx/parser/validation/all/makefile b/tests/cxx/parser/validation/all/makefile
new file mode 100644
index 0000000..75990e2
--- /dev/null
+++ b/tests/cxx/parser/validation/all/makefile
@@ -0,0 +1,82 @@
+# file : tests/cxx/parser/validation/all/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
+
+tests := 000 001 002 003
+
+obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=-pskel.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=-pskel.hxx) \
+ $(out_base)/$(xsd:.xsd=-pskel.ixx) \
+ $(out_base)/$(xsd:.xsd=-pskel.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.
+#
+test_targets := $(addprefix $(out_base)/.test-,$(tests))
+
+.PHONY: $(test)
+$(test): $(test_targets)
+
+
+$(test_targets): driver := $(driver)
+
+.PHONY: $(out_base)/.test-%
+$(out_base)/.test-%: $(driver) $(src_base)/test.xsd $(src_base)/test-%.xml $(src_base)/test-%.std
+ $(call message,test $(out_base)/$*,$(driver) $(src_base)/test-$*.xml | diff -u $(src_base)/test-$*.std -)
+
+
+# Clean.
+#
+.PHONY: $(clean)
+
+$(clean): $(driver).o.clean \
+ $(addsuffix .cxx.clean,$(obj)) \
+ $(addsuffix .cxx.clean,$(dep)) \
+ $(addprefix $(out_base)/,$(xsd:.xsd=-pskel.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/parser/xsd-cxx.make)
+
+
+# Dependencies.
+#
+$(call import,$(src_root)/xsde/makefile)
+$(call import,$(src_root)/libxsde/xsde/makefile)
diff --git a/tests/cxx/parser/validation/all/test-000.std b/tests/cxx/parser/validation/all/test-000.std
new file mode 100644
index 0000000..b4445f2
--- /dev/null
+++ b/tests/cxx/parser/validation/all/test-000.std
@@ -0,0 +1,46 @@
+{
+ a = a
+ b = b
+ c = c
+}
+
+{
+ a = a
+ c = c
+ b = b
+}
+
+{
+ b = b
+ a = a
+ c = c
+}
+
+{
+ b = b
+ c = c
+ a = a
+}
+
+{
+ c = c
+ a = a
+ b = b
+}
+
+{
+ c = c
+ b = b
+ a = a
+}
+
+{
+ a = a
+ b = b
+}
+
+{
+ a = a
+ b = b
+}
+
diff --git a/tests/cxx/parser/validation/all/test-000.xml b/tests/cxx/parser/validation/all/test-000.xml
new file mode 100644
index 0000000..6e46fae
--- /dev/null
+++ b/tests/cxx/parser/validation/all/test-000.xml
@@ -0,0 +1,53 @@
+<t:root xmlns:t="test"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- all combinations -->
+ <all>
+ <a>a</a>
+ <b>b</b>
+ <c>c</c>
+ </all>
+
+ <all>
+ <a>a</a>
+ <c>c</c>
+ <b>b</b>
+ </all>
+
+ <all>
+ <b>b</b>
+ <a>a</a>
+ <c>c</c>
+ </all>
+
+ <all>
+ <b>b</b>
+ <c>c</c>
+ <a>a</a>
+ </all>
+
+ <all>
+ <c>c</c>
+ <a>a</a>
+ <b>b</b>
+ </all>
+
+ <all>
+ <c>c</c>
+ <b>b</b>
+ <a>a</a>
+ </all>
+
+ <!-- optional c is not present -->
+ <all>
+ <a>a</a>
+ <b>b</b>
+ </all>
+
+ <all>
+ <a>a</a>
+ <b>b</b>
+ </all>
+
+</t:root>
diff --git a/tests/cxx/parser/validation/all/test-001.std b/tests/cxx/parser/validation/all/test-001.std
new file mode 100644
index 0000000..921402a
--- /dev/null
+++ b/tests/cxx/parser/validation/all/test-001.std
@@ -0,0 +1,6 @@
+{
+ a = a
+ c = c
+ 9:8 expected element not encountered
+}
+
diff --git a/tests/cxx/parser/validation/all/test-001.xml b/tests/cxx/parser/validation/all/test-001.xml
new file mode 100644
index 0000000..3df5600
--- /dev/null
+++ b/tests/cxx/parser/validation/all/test-001.xml
@@ -0,0 +1,11 @@
+<t:root xmlns:t="test"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- required b is not present (invalid) -->
+ <all>
+ <a>a</a>
+ <c>c</c>
+ </all>
+
+</t:root>
diff --git a/tests/cxx/parser/validation/all/test-002.std b/tests/cxx/parser/validation/all/test-002.std
new file mode 100644
index 0000000..55d65b3
--- /dev/null
+++ b/tests/cxx/parser/validation/all/test-002.std
@@ -0,0 +1,4 @@
+{
+ 7:8 expected element not encountered
+}
+
diff --git a/tests/cxx/parser/validation/all/test-002.xml b/tests/cxx/parser/validation/all/test-002.xml
new file mode 100644
index 0000000..aed0c0c
--- /dev/null
+++ b/tests/cxx/parser/validation/all/test-002.xml
@@ -0,0 +1,9 @@
+<t:root xmlns:t="test"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- invalid -->
+ <all>
+ </all>
+
+</t:root>
diff --git a/tests/cxx/parser/validation/all/test-003.std b/tests/cxx/parser/validation/all/test-003.std
new file mode 100644
index 0000000..1d22181
--- /dev/null
+++ b/tests/cxx/parser/validation/all/test-003.std
@@ -0,0 +1,6 @@
+{
+ a = a
+ b = b
+ 9:6 unexpected element encountered
+}
+
diff --git a/tests/cxx/parser/validation/all/test-003.xml b/tests/cxx/parser/validation/all/test-003.xml
new file mode 100644
index 0000000..b147cba
--- /dev/null
+++ b/tests/cxx/parser/validation/all/test-003.xml
@@ -0,0 +1,12 @@
+<t:root xmlns:t="test"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- invalid -->
+ <all>
+ <a>a</a>
+ <b>b</b>
+ <a>a</a>
+ </all>
+
+</t:root>
diff --git a/tests/cxx/parser/validation/all/test.xsd b/tests/cxx/parser/validation/all/test.xsd
new file mode 100644
index 0000000..1f670e3
--- /dev/null
+++ b/tests/cxx/parser/validation/all/test.xsd
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
+
+ <complexType name="all">
+ <all minOccurs="1">
+ <element name="a" type="string"/>
+ <element name="b" type="string"/>
+ <element name="c" type="string" minOccurs="0"/>
+ </all>
+ </complexType>
+
+ <complexType name="type">
+ <sequence>
+ <element name="all" type="t:all" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+
+ <element name="root" type="t:type"/>
+
+</schema>
diff --git a/tests/cxx/parser/validation/any/driver.cxx b/tests/cxx/parser/validation/any/driver.cxx
new file mode 100644
index 0000000..827cbf8
--- /dev/null
+++ b/tests/cxx/parser/validation/any/driver.cxx
@@ -0,0 +1,139 @@
+// file : tests/cxx/parser/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 the any particle validation.
+//
+
+#include <string>
+#include <iostream>
+
+#include "test-pskel.hxx"
+
+using namespace std;
+using namespace test;
+using xml_schema::ro_string;
+
+struct any_a_pimpl: any_a_pskel
+{
+ virtual void
+ pre ()
+ {
+ cout << "{" << endl;
+ }
+
+#ifdef XSDE_STL
+ virtual void
+ a (string const& v)
+ {
+ cout << " a = " << v << endl;
+ }
+
+ virtual void
+ x (string const& v)
+ {
+ cout << " x = " << v << endl;
+ }
+#else
+ virtual void
+ a (char* v)
+ {
+ cout << " a = " << v << endl;
+ delete[] v;
+ }
+
+ virtual void
+ x (char* v)
+ {
+ cout << " x = " << v << endl;
+ delete[] v;
+ }
+#endif
+
+ virtual void
+#ifndef XSDE_POLYMORPHIC
+ _start_any_element (ro_string const&, ro_string const& n)
+#else
+ _start_any_element (ro_string const&, ro_string const& n, const char*)
+#endif
+ {
+ cout << " start any element '" << n << "'" << endl;
+ }
+
+ virtual void
+ _end_any_element (ro_string const&, ro_string const& n)
+ {
+ cout << " end any element '" << n << "'" << endl;
+ }
+
+ virtual void
+ _any_attribute (ro_string const&,
+ ro_string const& n,
+ ro_string const& v)
+ {
+ cout << " any attribute " << n << " = '" << v << "'" << endl;
+ }
+
+ virtual void
+ _any_characters (ro_string const& s)
+ {
+ cout << " any text: '" << s << "'" << endl;
+ }
+
+ virtual void
+ post_any_a ()
+ {
+ cout << "}" << endl
+ << endl;
+ }
+};
+
+struct type_pimpl: type_pskel
+{
+};
+
+int
+main (int argc, char* argv[])
+{
+ if (argc != 2)
+ {
+ cerr << "usage: " << argv[0] << " test.xml" << endl;
+ return 1;
+ }
+
+ try
+ {
+ xml_schema::string_pimpl string_p;
+ any_a_pimpl any_a_p;
+ type_pimpl type_p;
+
+ any_a_p.parsers (string_p, string_p);
+ type_p.parsers (any_a_p);
+
+ xml_schema::document_pimpl doc_p (type_p, "test", "root");
+
+ try
+ {
+ type_p.pre ();
+ doc_p.parse (argv[1]);
+ type_p.post_type ();
+ }
+ catch (xml_schema::parser_exception const& e)
+ {
+ cout << " " << e.line () << ":" << e.column () << " " << e << endl
+ << "}" << endl
+ << endl;
+ }
+ }
+ catch (xml_schema::parser_exception const& e)
+ {
+ cerr << e << endl;
+ return 1;
+ }
+ catch (ios_base::failure const&)
+ {
+ cerr << "io failure" << endl;
+ return 1;
+ }
+}
diff --git a/tests/cxx/parser/validation/any/makefile b/tests/cxx/parser/validation/any/makefile
new file mode 100644
index 0000000..dfc1c21
--- /dev/null
+++ b/tests/cxx/parser/validation/any/makefile
@@ -0,0 +1,82 @@
+# file : tests/cxx/parser/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
+
+tests := 000
+
+obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=-pskel.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=-pskel.hxx) \
+ $(out_base)/$(xsd:.xsd=-pskel.ixx) \
+ $(out_base)/$(xsd:.xsd=-pskel.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.
+#
+test_targets := $(addprefix $(out_base)/.test-,$(tests))
+
+.PHONY: $(test)
+$(test): $(test_targets)
+
+
+$(test_targets): driver := $(driver)
+
+.PHONY: $(out_base)/.test-%
+$(out_base)/.test-%: $(driver) $(src_base)/test.xsd $(src_base)/test-%.xml $(src_base)/test-%.std
+ $(call message,test $(out_base)/$*,$(driver) $(src_base)/test-$*.xml | diff -u $(src_base)/test-$*.std -)
+
+
+# Clean.
+#
+.PHONY: $(clean)
+
+$(clean): $(driver).o.clean \
+ $(addsuffix .cxx.clean,$(obj)) \
+ $(addsuffix .cxx.clean,$(dep)) \
+ $(addprefix $(out_base)/,$(xsd:.xsd=-pskel.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/parser/xsd-cxx.make)
+
+
+# Dependencies.
+#
+$(call import,$(src_root)/xsde/makefile)
+$(call import,$(src_root)/libxsde/xsde/makefile) \ No newline at end of file
diff --git a/tests/cxx/parser/validation/any/test-000.std b/tests/cxx/parser/validation/any/test-000.std
new file mode 100644
index 0000000..a1cc6e3
--- /dev/null
+++ b/tests/cxx/parser/validation/any/test-000.std
@@ -0,0 +1,29 @@
+{
+ start any element 'any'
+ end any element 'any'
+}
+
+{
+ start any element 'any'
+ any attribute x = 'xxx'
+ any text: 'aaa'
+ start any element 'a'
+ any text: 'bbb'
+ end any element 'a'
+ any text: 'ccc'
+ end any element 'any'
+}
+
+{
+ x = x
+ a = a
+ start any element 'any'
+ any attribute x = 'xxx'
+ any text: 'aaa'
+ start any element 'a'
+ any text: 'bbb'
+ end any element 'a'
+ any text: 'ccc'
+ end any element 'any'
+}
+
diff --git a/tests/cxx/parser/validation/any/test-000.xml b/tests/cxx/parser/validation/any/test-000.xml
new file mode 100644
index 0000000..f1a0c83
--- /dev/null
+++ b/tests/cxx/parser/validation/any/test-000.xml
@@ -0,0 +1,21 @@
+<t:root xmlns:t="test"
+ xmlns:o="other"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- test dispatching of any-nested elements and attributes -->
+
+ <any-a>
+ <o:any/>
+ </any-a>
+
+ <any-a>
+ <o:any x="xxx">aaa<a>bbb</a>ccc</o:any>
+ </any-a>
+
+ <any-a x="x">
+ <a>a</a>
+ <o:any x="xxx">aaa<a>bbb</a>ccc</o:any>
+ </any-a>
+
+</t:root>
diff --git a/tests/cxx/parser/validation/any/test.xsd b/tests/cxx/parser/validation/any/test.xsd
new file mode 100644
index 0000000..c05aeb5
--- /dev/null
+++ b/tests/cxx/parser/validation/any/test.xsd
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
+
+ <complexType name="any-a">
+ <sequence>
+ <element name="a" type="string" minOccurs="0"/>
+ <any namespace="other" processContents="skip" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="x" type="string"/>
+ </complexType>
+
+ <complexType name="type">
+ <choice maxOccurs="unbounded">
+ <element name="any-a" type="t:any-a"/>
+ </choice>
+ </complexType>
+
+ <element name="root" type="t:type"/>
+
+</schema>
diff --git a/tests/cxx/parser/validation/attribute/driver.cxx b/tests/cxx/parser/validation/attribute/driver.cxx
new file mode 100644
index 0000000..935d2eb
--- /dev/null
+++ b/tests/cxx/parser/validation/attribute/driver.cxx
@@ -0,0 +1,275 @@
+// file : tests/cxx/parser/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 attribute wildcard (anyAttribute) validation.
+//
+
+#include <string>
+#include <iostream>
+
+#include "test-pskel.hxx"
+
+using namespace std;
+using namespace test;
+using xml_schema::ro_string;
+
+struct pass_a_pimpl: pass_a_pskel
+{
+ virtual void
+ pre ()
+ {
+ cout << "pass-a" << endl
+ << "{" << endl;
+ }
+
+#ifdef XSDE_STL
+ virtual void
+ a (string const& v)
+ {
+ cout << " a = " << v << endl;
+ }
+
+ virtual void
+ b (string const& v)
+ {
+ cout << " b = " << v << endl;
+ }
+#else
+ virtual void
+ a (char* v)
+ {
+ cout << " a = " << v << endl;
+ delete[] v;
+ }
+
+ virtual void
+ b (char* v)
+ {
+ cout << " b = " << v << endl;
+ delete[] v;
+ }
+#endif
+
+ virtual void
+ _any_attribute (ro_string const& ns,
+ ro_string const& name,
+ ro_string const& value)
+ {
+ cout << " any: " << ns << "#" << name << " = " << value << endl;
+ }
+
+ virtual void
+ post_pass_a ()
+ {
+ cout << "}" << endl
+ << endl;
+ }
+};
+
+struct pass_b_pimpl: pass_b_pskel
+{
+ pass_b_pimpl ()
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ : pass_b_pskel (0)
+#endif
+ {
+ }
+
+ virtual void
+ pre ()
+ {
+ cout << "pass-b" << endl
+ << "{" << endl;
+ }
+
+#ifdef XSDE_STL
+ virtual void
+ a (string const& v)
+ {
+ cout << " a = " << v << endl;
+ }
+
+ virtual void
+ b (string const& v)
+ {
+ cout << " b = " << v << endl;
+ }
+#else
+ virtual void
+ a (char* v)
+ {
+ cout << " a = " << v << endl;
+ delete[] v;
+ }
+
+ virtual void
+ b (char* v)
+ {
+ cout << " b = " << v << endl;
+ delete[] v;
+ }
+#endif
+
+ virtual void
+ _any_attribute (ro_string const& ns,
+ ro_string const& name,
+ ro_string const& value)
+ {
+ cout << " any: " << ns << "#" << name << " = " << value << endl;
+ }
+
+ virtual void
+ post_pass_b ()
+ {
+ cout << "}" << endl
+ << endl;
+ }
+};
+
+struct pass_c_pimpl: pass_c_pskel
+{
+ pass_c_pimpl ()
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ : pass_c_pskel (0)
+#endif
+ {
+ }
+
+ virtual void
+ pre ()
+ {
+ cout << "pass-c" << endl
+ << "{" << endl;
+ }
+
+#ifdef XSDE_STL
+ virtual void
+ a (string const& v)
+ {
+ cout << " a = " << v << endl;
+ }
+
+ virtual void
+ b (string const& v)
+ {
+ cout << " b = " << v << endl;
+ }
+#else
+ virtual void
+ a (char* v)
+ {
+ cout << " a = " << v << endl;
+ delete[] v;
+ }
+
+ virtual void
+ b (char* v)
+ {
+ cout << " b = " << v << endl;
+ delete[] v;
+ }
+#endif
+
+ virtual void
+ post_pass_c ()
+ {
+ cout << "}" << endl
+ << endl;
+ }
+};
+
+struct fail_pimpl: fail_pskel
+{
+ fail_pimpl ()
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ : fail_pskel (0)
+#endif
+ {
+ }
+
+ virtual void
+ pre ()
+ {
+ cout << "fail" << endl
+ << "{" << endl;
+ }
+
+#ifdef XSDE_STL
+ virtual void
+ a (string const& v)
+ {
+ cout << " a = " << v << endl;
+ }
+#else
+ virtual void
+ a (char* v)
+ {
+ cout << " a = " << v << endl;
+ delete[] v;
+ }
+#endif
+
+ virtual void
+ post_fail ()
+ {
+ cout << "}" << endl
+ << endl;
+ }
+};
+
+struct type_pimpl: type_pskel
+{
+};
+
+int
+main (int argc, char* argv[])
+{
+ if (argc != 2)
+ {
+ cerr << "usage: " << argv[0] << " test.xml" << endl;
+ return 1;
+ }
+
+ try
+ {
+ xml_schema::string_pimpl string_p;
+ pass_a_pimpl pass_a_p;
+ pass_b_pimpl pass_b_p;
+ pass_c_pimpl pass_c_p;
+ fail_pimpl fail_p;
+ type_pimpl type_p;
+
+ pass_a_p.parsers (string_p, string_p);
+ pass_b_p.parsers (string_p, string_p);
+ pass_c_p.parsers (string_p, string_p);
+ fail_p.parsers (string_p);
+ type_p.parsers (pass_a_p, pass_b_p, pass_c_p, fail_p);
+
+ xml_schema::document_pimpl doc_p (type_p, "test", "root");
+
+ try
+ {
+ type_p.pre ();
+ doc_p.parse (argv[1]);
+ type_p.post_type ();
+ }
+ catch (xml_schema::parser_exception const& e)
+ {
+ cout << " " << e.line () << ":" << e.column () << " " << e << endl
+ << "}" << endl
+ << endl;
+ }
+ }
+ catch (xml_schema::parser_exception const& e)
+ {
+ cerr << e << endl;
+ return 1;
+ }
+ catch (ios_base::failure const&)
+ {
+ cerr << "io failure" << endl;
+ return 1;
+ }
+}
diff --git a/tests/cxx/parser/validation/attribute/makefile b/tests/cxx/parser/validation/attribute/makefile
new file mode 100644
index 0000000..d037791
--- /dev/null
+++ b/tests/cxx/parser/validation/attribute/makefile
@@ -0,0 +1,72 @@
+# file : tests/cxx/parser/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=-pskel.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=-pskel.hxx) \
+ $(out_base)/$(xsd:.xsd=-pskel.ixx) \
+ $(out_base)/$(xsd:.xsd=-pskel.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)/test.xml $(src_base)/output
+ $(call message,test $$1,$$1 $(src_base)/test.xml | 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=-pskel.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/parser/xsd-cxx.make)
+
+
+# Dependencies.
+#
+$(call import,$(src_root)/xsde/makefile)
+$(call import,$(src_root)/libxsde/xsde/makefile)
diff --git a/tests/cxx/parser/validation/attribute/output b/tests/cxx/parser/validation/attribute/output
new file mode 100644
index 0000000..990f995
--- /dev/null
+++ b/tests/cxx/parser/validation/attribute/output
@@ -0,0 +1,24 @@
+pass-a
+{
+ b = b
+ any: test#foo = foo
+ any: test#bar = bar
+}
+
+pass-b
+{
+ a = a
+ b = b
+}
+
+pass-c
+{
+ a = a
+ b = b
+}
+
+fail
+{
+ 8:9 expected attribute not encountered
+}
+
diff --git a/tests/cxx/parser/validation/attribute/test.xml b/tests/cxx/parser/validation/attribute/test.xml
new file mode 100644
index 0000000..b994d1a
--- /dev/null
+++ b/tests/cxx/parser/validation/attribute/test.xml
@@ -0,0 +1,10 @@
+<t:root xmlns:t="test"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <pass-a b="b" t:foo="foo" t:bar="bar"/>
+ <pass-b a="a" b="b"/>
+ <pass-c a="a" b="b"/>
+ <fail/>
+
+</t:root>
diff --git a/tests/cxx/parser/validation/attribute/test.xsd b/tests/cxx/parser/validation/attribute/test.xsd
new file mode 100644
index 0000000..833eb8e
--- /dev/null
+++ b/tests/cxx/parser/validation/attribute/test.xsd
@@ -0,0 +1,71 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
+
+
+ <!-- Test optional and required attributes as well as a wildcard. -->
+ <complexType name="pass-a">
+ <attribute name="a" type="string" use="optional"/>
+ <attribute name="b" type="string" use="required"/>
+ <anyAttribute namespace="##targetNamespace" processContents="skip"/>
+ </complexType>
+
+
+ <!-- Test that in inheritance attributes are checked before wildcards. -->
+ <complexType name="pass-b-base">
+ <attribute name="a" type="string"/>
+ <anyAttribute namespace="#any" processContents="skip"/>
+ </complexType>
+
+ <complexType name="pass-b">
+ <complexContent>
+ <extension base="t:pass-b-base">
+ <attribute name="b" type="string"/>
+ <anyAttribute namespace="#any" processContents="skip"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+
+ <!-- Test that in inheritance by restriction required attribute is
+ checked for even though it is not explicitly mentioned in
+ derived. -->
+ <complexType name="pass-c-base">
+ <attribute name="a" type="string" use="required"/>
+ <attribute name="b" type="string" use="optional"/>
+ </complexType>
+
+ <complexType name="pass-c">
+ <complexContent>
+ <restriction base="t:pass-c-base">
+ <attribute name="b" type="string" use="required"/>
+ </restriction>
+ </complexContent>
+ </complexType>
+
+
+ <!-- Test detection of missing required attribute. -->
+ <complexType name="fail-base">
+ <attribute name="a" type="string" use="optional"/>
+ </complexType>
+
+ <complexType name="fail">
+ <complexContent>
+ <restriction base="t:fail-base">
+ <attribute name="a" type="string" use="required"/>
+ </restriction>
+ </complexContent>
+ </complexType>
+
+
+ <complexType name="type">
+ <sequence>
+ <element name="pass-a" type="t:pass-a"/>
+ <element name="pass-b" type="t:pass-b"/>
+ <element name="pass-c" type="t:pass-c"/>
+ <element name="fail" type="t:fail"/>
+ </sequence>
+ </complexType>
+
+ <element name="root" type="t:type"/>
+
+</schema>
diff --git a/tests/cxx/parser/validation/built-in/any-type/driver.cxx b/tests/cxx/parser/validation/built-in/any-type/driver.cxx
new file mode 100644
index 0000000..6aadd78
--- /dev/null
+++ b/tests/cxx/parser/validation/built-in/any-type/driver.cxx
@@ -0,0 +1,187 @@
+// file : tests/cxx/parser/validation/built-in/any-type/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 anyType and anySimpleType validation.
+//
+
+#include <string>
+#include <iostream>
+
+#include "test-pskel.hxx"
+
+using namespace std;
+using namespace test;
+using xml_schema::ro_string;
+
+struct any_type_pimpl: xml_schema::any_type_pimpl
+{
+ virtual void
+ pre ()
+ {
+ cout << "{" << endl;
+ }
+
+ virtual void
+#ifndef XSDE_POLYMORPHIC
+ _start_any_element (ro_string const&, ro_string const& n)
+#else
+ _start_any_element (ro_string const&, ro_string const& n, const char*)
+#endif
+ {
+ cout << " start any element '" << n << "'" << endl;
+ }
+
+ virtual void
+ _end_any_element (ro_string const&, ro_string const& n)
+ {
+ cout << " end any element '" << n << "'" << endl;
+ }
+
+ virtual void
+ _any_attribute (ro_string const&,
+ ro_string const& n,
+ ro_string const& v)
+ {
+ cout << " any attribute " << n << " = '" << v << "'" << endl;
+ }
+
+ virtual void
+ _any_characters (ro_string const& s)
+ {
+ cout << " any text: '" << s << "'" << endl;
+ }
+
+ virtual void
+ post_any_type ()
+ {
+ cout << "}" << endl
+ << endl;
+ }
+};
+
+struct any_simple_type_pimpl: xml_schema::any_simple_type_pimpl
+{
+ virtual void
+ pre ()
+ {
+ cout << "{" << endl;
+ }
+
+ virtual void
+ _any_characters (ro_string const& s)
+ {
+ cout << " any text: '" << s << "'" << endl;
+ }
+
+ virtual void
+ post_any_simple_type ()
+ {
+ cout << "}" << endl
+ << endl;
+ }
+};
+
+struct any_extension_pimpl: any_extension_pskel
+{
+ any_extension_pimpl ()
+ : any_extension_pskel (&base_impl_)
+ {
+ }
+
+#ifdef XSDE_STL
+ virtual void
+ x (const string& v)
+ {
+ cout << " x = " << v << endl;
+ }
+#else
+ virtual void
+ x (char* v)
+ {
+ cout << " x = " << v << endl;
+ delete[] v;
+ }
+#endif
+
+private:
+ any_type_pimpl base_impl_;
+};
+
+struct any_simple_extension_pimpl: any_simple_extension_pskel
+{
+ any_simple_extension_pimpl ()
+ : any_simple_extension_pskel (&base_impl_)
+ {
+ }
+
+#ifdef XSDE_STL
+ virtual void
+ x (const string& v)
+ {
+ cout << " x = " << v << endl;
+ }
+#else
+ virtual void
+ x (char* v)
+ {
+ cout << " x = " << v << endl;
+ delete[] v;
+ }
+#endif
+
+private:
+ any_simple_type_pimpl base_impl_;
+};
+
+struct type_pimpl: type_pskel
+{
+};
+
+int
+main (int argc, char* argv[])
+{
+ if (argc != 2)
+ {
+ cerr << "usage: " << argv[0] << " test.xml" << endl;
+ return 1;
+ }
+
+ try
+ {
+ xml_schema::string_pimpl string_p;
+
+ any_type_pimpl any_type_p;
+ any_simple_type_pimpl any_simple_type_p;
+
+ any_extension_pimpl any_extension_p;
+ any_simple_extension_pimpl any_simple_extension_p;
+
+ type_pimpl type_p;
+
+ any_extension_p.parsers (string_p);
+ any_simple_extension_p.parsers (string_p);
+
+ type_p.parsers (any_simple_type_p,
+ any_type_p,
+ any_extension_p,
+ any_simple_extension_p);
+
+ xml_schema::document_pimpl doc_p (type_p, "test", "root");
+
+ type_p.pre ();
+ doc_p.parse (argv[1]);
+ type_p.post_type ();
+ }
+ catch (xml_schema::parser_exception const& e)
+ {
+ cerr << e << endl;
+ return 1;
+ }
+ catch (ios_base::failure const&)
+ {
+ cerr << "io failure" << endl;
+ return 1;
+ }
+}
diff --git a/tests/cxx/parser/validation/built-in/any-type/makefile b/tests/cxx/parser/validation/built-in/any-type/makefile
new file mode 100644
index 0000000..951454e
--- /dev/null
+++ b/tests/cxx/parser/validation/built-in/any-type/makefile
@@ -0,0 +1,82 @@
+# file : tests/cxx/parser/validation/built-in/any-type/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
+
+tests := 000
+
+obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=-pskel.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=-pskel.hxx) \
+ $(out_base)/$(xsd:.xsd=-pskel.ixx) \
+ $(out_base)/$(xsd:.xsd=-pskel.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.
+#
+test_targets := $(addprefix $(out_base)/.test-,$(tests))
+
+.PHONY: $(test)
+$(test): $(test_targets)
+
+
+$(test_targets): driver := $(driver)
+
+.PHONY: $(out_base)/.test-%
+$(out_base)/.test-%: $(driver) $(src_base)/test.xsd $(src_base)/test-%.xml $(src_base)/test-%.std
+ $(call message,test $(out_base)/$*,$(driver) $(src_base)/test-$*.xml | diff -u $(src_base)/test-$*.std -)
+
+
+# Clean.
+#
+.PHONY: $(clean)
+
+$(clean): $(driver).o.clean \
+ $(addsuffix .cxx.clean,$(obj)) \
+ $(addsuffix .cxx.clean,$(dep)) \
+ $(addprefix $(out_base)/,$(xsd:.xsd=-pskel.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/parser/xsd-cxx.make)
+
+
+# Dependencies.
+#
+$(call import,$(src_root)/xsde/makefile)
+$(call import,$(src_root)/libxsde/xsde/makefile)
diff --git a/tests/cxx/parser/validation/built-in/any-type/test-000.std b/tests/cxx/parser/validation/built-in/any-type/test-000.std
new file mode 100644
index 0000000..9e263c0
--- /dev/null
+++ b/tests/cxx/parser/validation/built-in/any-type/test-000.std
@@ -0,0 +1,113 @@
+{
+ any text: '123abc'
+}
+
+{
+ any text: '
+'
+ any text: ' '
+ start any element 'any'
+ end any element 'any'
+ any text: '
+'
+ any text: ' '
+}
+
+{
+ any text: '
+'
+ any text: ' '
+ start any element 'any'
+ any attribute x = 'xxx'
+ any text: 'aaa'
+ start any element 'a'
+ any text: 'bbb'
+ end any element 'a'
+ any text: 'ccc'
+ end any element 'any'
+ any text: '
+'
+ any text: ' '
+}
+
+{
+ any attribute x = 'x'
+ any text: '
+'
+ any text: ' '
+ start any element 'a'
+ any text: 'a'
+ end any element 'a'
+ any text: '
+'
+ any text: ' '
+ start any element 'any'
+ any attribute x = 'xxx'
+ any text: 'aaa'
+ start any element 'a'
+ any text: 'bbb'
+ end any element 'a'
+ any text: 'ccc'
+ end any element 'any'
+ any text: '
+'
+ any text: ' '
+}
+
+{
+ any text: '
+'
+ any text: ' '
+ start any element 'any'
+ end any element 'any'
+ any text: '
+'
+ any text: ' '
+}
+
+{
+ any text: '
+'
+ any text: ' '
+ start any element 'any'
+ any attribute x = 'xxx'
+ any text: 'aaa'
+ start any element 'a'
+ any text: 'bbb'
+ end any element 'a'
+ any text: 'ccc'
+ end any element 'any'
+ any text: '
+'
+ any text: ' '
+}
+
+{
+ x = x
+ any text: '
+'
+ any text: ' '
+ start any element 'a'
+ any text: 'a'
+ end any element 'a'
+ any text: '
+'
+ any text: ' '
+ start any element 'any'
+ any attribute x = 'xxx'
+ any text: 'aaa'
+ start any element 'a'
+ any text: 'bbb'
+ end any element 'a'
+ any text: 'ccc'
+ end any element 'any'
+ any text: '
+'
+ any text: ' '
+}
+
+{
+ x = x
+ any text: 'abc123'
+}
+
diff --git a/tests/cxx/parser/validation/built-in/any-type/test-000.xml b/tests/cxx/parser/validation/built-in/any-type/test-000.xml
new file mode 100644
index 0000000..7875b7e
--- /dev/null
+++ b/tests/cxx/parser/validation/built-in/any-type/test-000.xml
@@ -0,0 +1,41 @@
+<t:root xmlns:t="test"
+ xmlns:o="other"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd"
+ as="123abc">
+
+ <!-- test dispatching of anyType nested elements and attributes -->
+
+ <a>
+ <o:any/>
+ </a>
+
+ <a>
+ <o:any x="xxx">aaa<a>bbb</a>ccc</o:any>
+ </a>
+
+ <a x="x">
+ <a>a</a>
+ <o:any x="xxx">aaa<a>bbb</a>ccc</o:any>
+ </a>
+
+ <!-- anyType extension -->
+
+ <a-extension>
+ <o:any/>
+ </a-extension>
+
+ <a-extension>
+ <o:any x="xxx">aaa<a>bbb</a>ccc</o:any>
+ </a-extension>
+
+ <a-extension x="x">
+ <a>a</a>
+ <o:any x="xxx">aaa<a>bbb</a>ccc</o:any>
+ </a-extension>
+
+ <!-- anySimpleType extension -->
+
+ <as-extension x="x">abc123</as-extension>
+
+</t:root>
diff --git a/tests/cxx/parser/validation/built-in/any-type/test.xsd b/tests/cxx/parser/validation/built-in/any-type/test.xsd
new file mode 100644
index 0000000..86a4e13
--- /dev/null
+++ b/tests/cxx/parser/validation/built-in/any-type/test.xsd
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
+
+ <complexType name="any-extension">
+ <complexContent mixed="true">
+ <extension base="anyType">
+ <attribute name="x" type="string"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="any-simple-extension">
+ <simpleContent>
+ <extension base="anySimpleType">
+ <attribute name="x" type="string"/>
+ </extension>
+ </simpleContent>
+ </complexType>
+
+ <complexType name="type">
+ <choice maxOccurs="unbounded">
+ <element name="a" type="anyType"/>
+ <element name="a-extension" type="t:any-extension"/>
+ <element name="as-extension" type="t:any-simple-extension"/>
+ </choice>
+ <attribute name="as" type="anySimpleType"/>
+ </complexType>
+
+ <element name="root" type="t:type"/>
+
+</schema>
diff --git a/tests/cxx/parser/validation/built-in/binary/driver.cxx b/tests/cxx/parser/validation/built-in/binary/driver.cxx
new file mode 100644
index 0000000..23dbf45
--- /dev/null
+++ b/tests/cxx/parser/validation/built-in/binary/driver.cxx
@@ -0,0 +1,176 @@
+// file : tests/cxx/parser/validation/built-in/binary/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 base64Binary and hexBinary types validation.
+//
+#include <cassert>
+#include <string.h> // memcpy
+
+#include <xsde/cxx/parser/validating/base64-binary.hxx>
+#include <xsde/cxx/parser/validating/hex-binary.hxx>
+
+using namespace xsde::cxx;
+using namespace xsde::cxx::parser;
+using namespace xsde::cxx::parser::validating;
+
+bool
+compare (buffer* x, const char* p, size_t n)
+{
+ buffer b;
+ b.size (n);
+ memcpy (b.data (), p, n);
+
+ bool r = *x == b;
+ delete x;
+ return r;
+}
+
+int
+main ()
+{
+ // Good.
+ //
+
+ // hexBinary
+ //
+ {
+ context c (0);
+ hex_binary_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (" \t\n ");
+ p._characters (" ");
+ p._post ();
+ assert (!c.error_type () &&
+ compare (p.post_hex_binary (), "", 0));
+ }
+
+ {
+ context c (0);
+ hex_binary_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (" \t\n313");
+ p._characters ("23334356162636a6b ");
+ p._post ();
+ assert (!c.error_type () &&
+ compare (p.post_hex_binary (), "12345abcjk", 10));
+ }
+
+ // base64Binary
+ //
+ {
+ context c (0);
+ base64_binary_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (" \t\n ");
+ p._characters ("MTIzND ");
+ p._characters ("VhYmNqaw = = ");
+ p._post ();
+ assert (!c.error_type () &&
+ compare (p.post_base64_binary (), "12345abcjk", 10));
+ }
+
+ {
+ context c (0);
+ base64_binary_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("YQ==");
+ p._post ();
+ assert (!c.error_type () &&
+ compare (p.post_base64_binary (), "a", 1));
+ }
+
+ {
+ context c (0);
+ base64_binary_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("YWI=");
+ p._post ();
+ assert (!c.error_type () &&
+ compare (p.post_base64_binary (), "ab", 2));
+ }
+
+ {
+ context c (0);
+ base64_binary_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("YWJj");
+ p._post ();
+ assert (!c.error_type () &&
+ compare (p.post_base64_binary (), "abc", 3));
+ }
+
+ // Bad
+ //
+
+ // hexBinary
+ //
+ {
+ context c (0);
+ hex_binary_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("313");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_hex_binary_value);
+ }
+
+ {
+ context c (0);
+ hex_binary_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("313233343X6162636a6b");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_hex_binary_value);
+ }
+
+ // base64Binary
+ //
+ {
+ context c (0);
+ base64_binary_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ // p._characters ("");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_base64_binary_value);
+ }
+
+ {
+ context c (0);
+ base64_binary_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("YQ");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_base64_binary_value);
+ }
+
+ {
+ context c (0);
+ base64_binary_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("==");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_base64_binary_value);
+ }
+
+ {
+ context c (0);
+ base64_binary_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("MTIzNDVhYmNqaw=A");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_base64_binary_value);
+ }
+}
diff --git a/tests/cxx/parser/validation/built-in/binary/makefile b/tests/cxx/parser/validation/built-in/binary/makefile
new file mode 100644
index 0000000..5a07676
--- /dev/null
+++ b/tests/cxx/parser/validation/built-in/binary/makefile
@@ -0,0 +1,61 @@
+# file : tests/cxx/parser/validation/built-in/binary/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/parser/validation/built-in/boolean/driver.cxx b/tests/cxx/parser/validation/built-in/boolean/driver.cxx
new file mode 100644
index 0000000..7f08ed6
--- /dev/null
+++ b/tests/cxx/parser/validation/built-in/boolean/driver.cxx
@@ -0,0 +1,150 @@
+// file : tests/cxx/parser/validation/built-in/boolean/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 boolean type validation.
+//
+#include <cassert>
+
+#include <xsde/cxx/parser/validating/boolean.hxx>
+
+using namespace xsde::cxx::parser;
+using namespace xsde::cxx::parser::validating;
+
+int
+main ()
+{
+ // Good.
+ //
+ {
+ context c (0);
+ boolean_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("true");
+ p._post ();
+ assert (!c.error_type () && p.post_boolean ());
+ }
+
+ {
+ context c (0);
+ boolean_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("1");
+ p._post ();
+ assert (!c.error_type () && p.post_boolean ());
+ }
+
+ {
+ context c (0);
+ boolean_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("false");
+ p._post ();
+ assert (!c.error_type () && !p.post_boolean ());
+ }
+
+ {
+ context c (0);
+ boolean_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("0");
+ p._post ();
+ assert (!c.error_type () && !p.post_boolean ());
+ }
+
+
+ {
+ context c (0);
+ boolean_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (" true ");
+ p._post ();
+ assert (!c.error_type () && p.post_boolean ());
+ }
+
+ {
+ context c (0);
+ boolean_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (" ");
+ p._characters (" \n ");
+ p._characters (" fa");
+ p._characters ("l");
+ p._characters ("se ");
+ p._characters (" \n ");
+ p._characters (" ");
+ p._post ();
+ assert (!c.error_type () && !p.post_boolean ());
+ }
+
+ // Bad
+ //
+ {
+ context c (0);
+ boolean_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ //p._characters ("");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ boolean_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ boolean_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (" ");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ boolean_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (" ");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ boolean_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("fal");
+ p._characters ("s ");
+ p._characters ("e");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ boolean_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("01");
+ p._post ();
+ assert (c.schema_error ());
+ }
+}
diff --git a/tests/cxx/parser/validation/built-in/boolean/makefile b/tests/cxx/parser/validation/built-in/boolean/makefile
new file mode 100644
index 0000000..b844e00
--- /dev/null
+++ b/tests/cxx/parser/validation/built-in/boolean/makefile
@@ -0,0 +1,61 @@
+# file : tests/cxx/parser/validation/built-in/boolean/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/parser/validation/built-in/byte/driver.cxx b/tests/cxx/parser/validation/built-in/byte/driver.cxx
new file mode 100644
index 0000000..26f5a12
--- /dev/null
+++ b/tests/cxx/parser/validation/built-in/byte/driver.cxx
@@ -0,0 +1,280 @@
+// file : tests/cxx/parser/validation/built-in/byte/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 byte and unsigned byte types validation.
+//
+#include <cassert>
+
+#include <xsde/cxx/parser/validating/byte.hxx>
+#include <xsde/cxx/parser/validating/unsigned-byte.hxx>
+
+using namespace xsde::cxx::parser;
+using namespace xsde::cxx::parser::validating;
+
+int
+main ()
+{
+ // Good.
+ //
+ {
+ context c (0);
+ byte_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("123");
+ p._post ();
+ assert (!c.error_type () && p.post_byte () == 123);
+ }
+
+ {
+ context c (0);
+ byte_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("\t +123 \n ");
+ p._post ();
+ assert (!c.error_type () && p.post_byte () == 123);
+ }
+
+ {
+ context c (0);
+ byte_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-123");
+ p._post ();
+ assert (!c.error_type () && p.post_byte () == -123);
+ }
+
+ {
+ context c (0);
+ byte_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("+123");
+ p._post ();
+ assert (!c.error_type () && p.post_byte () == 123);
+ }
+
+ {
+ context c (0);
+ byte_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("0000000000000000123");
+ p._post ();
+ assert (!c.error_type () && p.post_byte () == 123);
+ }
+
+ {
+ context c (0);
+ byte_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("+0000000000000000123");
+ p._post ();
+ assert (!c.error_type () && p.post_byte () == 123);
+ }
+
+ {
+ context c (0);
+ byte_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-0000000000000000123");
+ p._post ();
+ assert (!c.error_type () && p.post_byte () == -123);
+ }
+
+ {
+ context c (0);
+ byte_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("\t \n");
+ p._characters (" -");
+ p._characters ("00000");
+ p._characters ("001");
+ p._characters ("23 \n\t");
+ p._post ();
+ assert (!c.error_type () && p.post_byte () == -123);
+ }
+
+ {
+ context c (0);
+ byte_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-128");
+ p._post ();
+ assert (!c.error_type () && p.post_byte () == -128);
+ }
+
+ {
+ context c (0);
+ byte_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("127");
+ p._post ();
+ assert (!c.error_type () && p.post_byte () == 127);
+ }
+
+ {
+ context c (0);
+ unsigned_byte_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("+123");
+ p._post ();
+ assert (!c.error_type () && p.post_unsigned_byte () == 123);
+ }
+
+ {
+ context c (0);
+ unsigned_byte_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("0");
+ p._post ();
+ assert (!c.error_type () && p.post_unsigned_byte () == 0);
+ }
+
+ {
+ context c (0);
+ unsigned_byte_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("255");
+ p._post ();
+ assert (!c.error_type () && p.post_unsigned_byte () == 255);
+ }
+
+ // Bad
+ //
+ {
+ context c (0);
+ byte_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ // p._characters ("");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ byte_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ byte_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (" \n \t ");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ byte_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("+");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ byte_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ byte_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("++01");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ byte_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("--01");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ byte_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-01");
+ p._characters (" ");
+ p._characters ("23 ");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ unsigned_byte_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-123");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ // Ranges
+ //
+ {
+ context c (0);
+ byte_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-129");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ byte_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("128");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ unsigned_byte_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("256");
+ p._post ();
+ assert (c.schema_error ());
+ }
+}
diff --git a/tests/cxx/parser/validation/built-in/byte/makefile b/tests/cxx/parser/validation/built-in/byte/makefile
new file mode 100644
index 0000000..855095f
--- /dev/null
+++ b/tests/cxx/parser/validation/built-in/byte/makefile
@@ -0,0 +1,61 @@
+# file : tests/cxx/parser/validation/built-in/byte/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/parser/validation/built-in/date-time/driver.cxx b/tests/cxx/parser/validation/built-in/date-time/driver.cxx
new file mode 100644
index 0000000..43b23f3
--- /dev/null
+++ b/tests/cxx/parser/validation/built-in/date-time/driver.cxx
@@ -0,0 +1,1833 @@
+// file : tests/cxx/parser/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/parser/validating/xml-schema-pimpl.hxx>
+
+using namespace xsde::cxx;
+using namespace xsde::cxx::parser;
+using namespace xsde::cxx::parser::validating;
+
+int
+main ()
+{
+ using xsde::cxx::time;
+
+ // Good.
+ //
+
+ // gday & time zone parsing
+ //
+ {
+ context c (0);
+ gday_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (" \t\n ");
+ p._characters ("---1");
+ p._characters ("2+12:00");
+ p._post ();
+ assert (p.post_gday () == gday (12, 12, 0));
+ }
+
+ {
+ context c (0);
+ gday_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("---01");
+ p._post ();
+ assert (p.post_gday () == gday (1));
+ }
+
+ {
+ context c (0);
+ gday_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("---31");
+ p._post ();
+ assert (p.post_gday () == gday (31));
+ }
+
+ {
+ context c (0);
+ gday_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("---15Z");
+ p._post ();
+ assert (p.post_gday () == gday (15, 0, 0));
+ }
+
+ {
+ context c (0);
+ gday_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("---15-14:00");
+ p._post ();
+ assert (p.post_gday () == gday (15, -14, -0));
+ }
+
+ {
+ context c (0);
+ gday_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("---15-12:59");
+ p._post ();
+ assert (p.post_gday () == gday (15, -12, -59));
+ }
+
+ // gmonth
+ //
+ {
+ context c (0);
+ gmonth_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (" \t\n ");
+ p._characters ("--1");
+ p._characters ("0+12:00");
+ p._post ();
+ assert (p.post_gmonth () == gmonth (10, 12, 0));
+ }
+
+ {
+ context c (0);
+ gmonth_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("--01");
+ p._post ();
+ assert (p.post_gmonth () == gmonth (1));
+ }
+
+ {
+ context c (0);
+ gmonth_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("--12Z");
+ p._post ();
+ assert (p.post_gmonth () == gmonth (12, 0, 0));
+ }
+
+ // gyear
+ //
+ {
+ context c (0);
+ gyear_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (" \t\n ");
+ p._characters ("20");
+ p._characters ("07+12:00");
+ p._post ();
+ assert (p.post_gyear () == gyear (2007, 12, 0));
+ }
+
+ {
+ context c (0);
+ gyear_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("0001");
+ p._post ();
+ assert (p.post_gyear () == gyear (1));
+ }
+
+ {
+ context c (0);
+ gyear_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-20000Z");
+ p._post ();
+ assert (p.post_gyear () == gyear (-20000, 0, 0));
+ }
+
+ // gmonth_day
+ //
+ {
+ context c (0);
+ gmonth_day_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (" \t\n ");
+ p._characters ("--1");
+ p._characters ("0-28+12:00 ");
+ p._post ();
+ assert (p.post_gmonth_day () == gmonth_day (10, 28, 12, 00));
+ }
+
+ {
+ context c (0);
+ gmonth_day_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("--12-31");
+ p._post ();
+ assert (p.post_gmonth_day () == gmonth_day (12, 31));
+ }
+
+ {
+ context c (0);
+ gmonth_day_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("--01-01Z");
+ p._post ();
+ assert (p.post_gmonth_day () == gmonth_day (1, 1, 0, 0));
+ }
+
+ // gyear_month
+ //
+ {
+ context c (0);
+ gyear_month_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (" \t\n ");
+ p._characters ("200");
+ p._characters ("7-12+12:00 ");
+ p._post ();
+ assert (p.post_gyear_month () == gyear_month (2007, 12, 12, 0));
+ }
+
+ {
+ context c (0);
+ gyear_month_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-2007-10");
+ p._post ();
+ assert (p.post_gyear_month () == gyear_month (-2007, 10));
+ }
+
+ {
+ context c (0);
+ gyear_month_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("20007-10Z");
+ p._post ();
+ assert (p.post_gyear_month () == gyear_month (20007, 10, 0, 0));
+ }
+
+ {
+ context c (0);
+ gyear_month_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-20007-01");
+ p._post ();
+ assert (p.post_gyear_month () == gyear_month (-20007, 1));
+ }
+
+ // date
+ //
+ {
+ context c (0);
+ date_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (" \t\n ");
+ p._characters ("200");
+ p._characters ("7-12-26+12:00 ");
+ p._post ();
+ assert (p.post_date () == date (2007, 12, 26, 12, 0));
+ }
+
+ {
+ context c (0);
+ date_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-2007-10-15");
+ p._post ();
+ assert (p.post_date () == date (-2007, 10, 15));
+ }
+
+ {
+ context c (0);
+ date_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("20007-12-31Z");
+ p._post ();
+ assert (p.post_date () == date (20007, 12, 31, 0, 0));
+ }
+
+ {
+ context c (0);
+ date_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-20007-01-01");
+ p._post ();
+ assert (p.post_date () == date (-20007, 1, 1));
+ }
+
+ // time
+ //
+ {
+ context c (0);
+ time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (" \t\n ");
+ p._characters ("12:");
+ p._characters ("46:23.456+12:00 ");
+ p._post ();
+ assert (p.post_time () == time (12, 46, 23.456, 12, 0));
+ }
+
+ {
+ context c (0);
+ time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("12:13:14");
+ p._post ();
+ assert (p.post_time () == time (12, 13, 14.0));
+ }
+
+ {
+ context c (0);
+ time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("12:13:14Z");
+ p._post ();
+ assert (p.post_time () == time (12, 13, 14.0, 0, 0));
+ }
+
+ // date_time
+ //
+ {
+ context c (0);
+ date_time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (" \t\n ");
+ p._characters ("200");
+ p._characters ("7-12-26T12:13:14.123+12:00 ");
+ p._post ();
+ assert (p.post_date_time () ==
+ date_time (2007, 12, 26, 12, 13, 14.123, 12, 0));
+ }
+
+ {
+ context c (0);
+ date_time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-2007-10-15T12:13:14");
+ p._post ();
+ assert (p.post_date_time () == date_time (-2007, 10, 15, 12, 13, 14.0));
+ }
+
+ {
+ context c (0);
+ date_time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("20007-12-31T12:13:14Z");
+ p._post ();
+ assert (p.post_date_time () ==
+ date_time (20007, 12, 31, 12, 13, 14.0, 0, 0));
+ }
+
+ {
+ context c (0);
+ date_time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-20007-01-01T12:13:14");
+ p._post ();
+ assert (p.post_date_time () == date_time (-20007, 1, 1, 12, 13, 14.0));
+ }
+
+ // duration
+ //
+ {
+ context c (0);
+ duration_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (" \t\n ");
+ p._characters ("-P200");
+ p._characters ("7Y13M32DT25H61M61.123S ");
+ p._post ();
+ assert (p.post_duration () ==
+ duration (true, 2007, 13, 32, 25, 61, 61.123));
+ }
+
+ {
+ context c (0);
+ duration_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("P1Y");
+ p._post ();
+ assert (p.post_duration () == duration (false, 1, 0, 0, 0, 0, 0.0));
+ }
+
+ {
+ context c (0);
+ duration_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("P1M");
+ p._post ();
+ assert (p.post_duration () == duration (false, 0, 1, 0, 0, 0, 0.0));
+ }
+
+ {
+ context c (0);
+ duration_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("P1D");
+ p._post ();
+ assert (p.post_duration () == duration (false, 0, 0, 1, 0, 0, 0.0));
+ }
+
+ {
+ context c (0);
+ duration_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("PT1H");
+ p._post ();
+ assert (p.post_duration () == duration (false, 0, 0, 0, 1, 0, 0.0));
+ }
+
+ {
+ context c (0);
+ duration_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("PT1M");
+ p._post ();
+ assert (p.post_duration () == duration (false, 0, 0, 0, 0, 1, 0.0));
+ }
+
+ {
+ context c (0);
+ duration_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("PT1.1S");
+ p._post ();
+ assert (p.post_duration () == duration (false, 0, 0, 0, 0, 0, 1.1));
+ }
+
+ {
+ context c (0);
+ duration_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("P1YT1S");
+ p._post ();
+ assert (p.post_duration () == duration (false, 1, 0, 0, 0, 0, 1.0));
+ }
+
+ // Bad
+ //
+
+ // gday & time zone parsing
+ //
+ {
+ context c (0);
+ gday_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ // p._characters ("");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gday_value);
+ }
+
+ {
+ context c (0);
+ gday_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("--12");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gday_value);
+ }
+
+ {
+ context c (0);
+ gday_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("---1");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gday_value);
+ }
+
+ {
+ context c (0);
+ gday_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("---00");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gday_value);
+ }
+
+ {
+ context c (0);
+ gday_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("---32");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gday_value);
+ }
+
+ {
+ context c (0);
+ gday_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("---2X");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gday_value);
+ }
+
+ {
+ context c (0);
+ gday_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("---12asd");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gday_value);
+ }
+
+ {
+ context c (0);
+ gday_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("---12X");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gday_value);
+ }
+
+ {
+ context c (0);
+ gday_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("---1212:00");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gday_value);
+ }
+
+ {
+ context c (0);
+ gday_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("---12+2:00");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gday_value);
+ }
+
+ {
+ context c (0);
+ gday_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("---12+1200");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gday_value);
+ }
+
+ {
+ context c (0);
+ gday_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("---12+15:00");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gday_value);
+ }
+
+ {
+ context c (0);
+ gday_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("---12+12:60");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gday_value);
+ }
+
+ {
+ context c (0);
+ gday_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("---12+14:01");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gday_value);
+ }
+
+ // gmonth
+ //
+ {
+ context c (0);
+ gmonth_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ // p._characters ("");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gmonth_value);
+ }
+
+ {
+ context c (0);
+ gmonth_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-12");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gmonth_value);
+ }
+
+ {
+ context c (0);
+ gmonth_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("--00");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gmonth_value);
+ }
+
+ {
+ context c (0);
+ gmonth_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("--13");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gmonth_value);
+ }
+
+ {
+ context c (0);
+ gmonth_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("--1X");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gmonth_value);
+ }
+
+ {
+ context c (0);
+ gmonth_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("--11+12:3o");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gmonth_value);
+ }
+
+ // gyear
+ //
+ {
+ context c (0);
+ gyear_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ // p._characters ("");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gyear_value);
+ }
+
+ {
+ context c (0);
+ gyear_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("207");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gyear_value);
+ }
+
+ {
+ context c (0);
+ gyear_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-207");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gyear_value);
+ }
+
+ {
+ context c (0);
+ gyear_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-0000");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gyear_value);
+ }
+
+ {
+ context c (0);
+ gyear_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("20X7");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gyear_value);
+ }
+
+ {
+ context c (0);
+ gyear_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007+12:3o");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gyear_value);
+ }
+
+ // gmonth_day
+ //
+ {
+ context c (0);
+ gmonth_day_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ // p._characters ("");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gmonth_day_value);
+ }
+
+ {
+ context c (0);
+ gmonth_day_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-12-12");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gmonth_day_value);
+ }
+
+ {
+ context c (0);
+ gmonth_day_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("--1212");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gmonth_day_value);
+ }
+
+ {
+ context c (0);
+ gmonth_day_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("--12?12");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gmonth_day_value);
+ }
+
+ {
+ context c (0);
+ gmonth_day_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("--00-12");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gmonth_day_value);
+ }
+
+ {
+ context c (0);
+ gmonth_day_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("--12-00");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gmonth_day_value);
+ }
+
+ {
+ context c (0);
+ gmonth_day_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("--13-23");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gmonth_day_value);
+ }
+
+ {
+ context c (0);
+ gmonth_day_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("--12-32");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gmonth_day_value);
+ }
+
+ {
+ context c (0);
+ gmonth_day_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("--1X-12");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gmonth_day_value);
+ }
+
+ {
+ context c (0);
+ gmonth_day_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("--12-2X");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gmonth_day_value);
+ }
+
+ {
+ context c (0);
+ gmonth_day_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("--11-11+12:3o");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gmonth_day_value);
+ }
+
+ // gyear_month
+ //
+ {
+ context c (0);
+ gyear_month_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ // p._characters ("");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gyear_month_value);
+ }
+
+ {
+ context c (0);
+ gyear_month_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("207-01");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gyear_month_value);
+ }
+
+ {
+ context c (0);
+ gyear_month_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-207-01");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gyear_month_value);
+ }
+
+ {
+ context c (0);
+ gyear_month_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("0000-01");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gyear_month_value);
+ }
+
+ {
+ context c (0);
+ gyear_month_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("20X7-01");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gyear_month_value);
+ }
+
+ {
+ context c (0);
+ gyear_month_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gyear_month_value);
+ }
+
+ {
+ context c (0);
+ gyear_month_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007?12");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gyear_month_value);
+ }
+
+ {
+ context c (0);
+ gyear_month_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-0");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gyear_month_value);
+ }
+
+ {
+ context c (0);
+ gyear_month_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-00");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gyear_month_value);
+ }
+
+ {
+ context c (0);
+ gyear_month_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-13");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gyear_month_value);
+ }
+
+ {
+ context c (0);
+ gyear_month_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-1X");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gyear_month_value);
+ }
+
+ {
+ context c (0);
+ gyear_month_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-01+12:3o");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_gyear_month_value);
+ }
+
+ // date
+ //
+ {
+ context c (0);
+ date_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ // p._characters ("");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_value);
+ }
+
+ {
+ context c (0);
+ date_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("207-01-01");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_value);
+ }
+
+ {
+ context c (0);
+ date_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-207-01-01");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_value);
+ }
+
+ {
+ context c (0);
+ date_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("0000-01-01");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_value);
+ }
+
+ {
+ context c (0);
+ date_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("20X7-01-01");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_value);
+ }
+
+ {
+ context c (0);
+ date_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_value);
+ }
+
+ {
+ context c (0);
+ date_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007?01-01");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_value);
+ }
+
+ {
+ context c (0);
+ date_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-0-01");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_value);
+ }
+
+ {
+ context c (0);
+ date_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-00-01");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_value);
+ }
+
+ {
+ context c (0);
+ date_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-13-01");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_value);
+ }
+
+ {
+ context c (0);
+ date_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-1X-01");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_value);
+ }
+
+ {
+ context c (0);
+ date_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-10");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_value);
+ }
+
+ {
+ context c (0);
+ date_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-10?12");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_value);
+ }
+
+ {
+ context c (0);
+ date_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-10-");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_value);
+ }
+
+ {
+ context c (0);
+ date_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-10-0");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_value);
+ }
+
+ {
+ context c (0);
+ date_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-10-00");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_value);
+ }
+
+ {
+ context c (0);
+ date_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-10-32");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_value);
+ }
+
+ {
+ context c (0);
+ date_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-10-2X");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_value);
+ }
+
+ {
+ context c (0);
+ date_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-01-01+12:3o");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_value);
+ }
+
+ // time
+ //
+ {
+ context c (0);
+ time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ // p._characters ("");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_time_value);
+ }
+
+ {
+ context c (0);
+ time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("1:01:01");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_time_value);
+ }
+
+ {
+ context c (0);
+ time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2X:01:01");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_time_value);
+ }
+
+ {
+ context c (0);
+ time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("23");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_time_value);
+ }
+
+ {
+ context c (0);
+ time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("23?01:01");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_time_value);
+ }
+
+ {
+ context c (0);
+ time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("23:0:01");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_time_value);
+ }
+
+ {
+ context c (0);
+ time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("23:60:01");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_time_value);
+ }
+
+ {
+ context c (0);
+ time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("23:4X:01");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_time_value);
+ }
+
+ {
+ context c (0);
+ time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("23:10");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_time_value);
+ }
+
+ {
+ context c (0);
+ time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("23:10?12");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_time_value);
+ }
+
+ {
+ context c (0);
+ time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("23:10:");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_time_value);
+ }
+
+ {
+ context c (0);
+ time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("23:10:0");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_time_value);
+ }
+
+ {
+ context c (0);
+ time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("23:10:01.");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_time_value);
+ }
+
+ {
+ context c (0);
+ time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("23:10:60");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_time_value);
+ }
+
+ {
+ context c (0);
+ time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("23:10:2X");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_time_value);
+ }
+
+ {
+ context c (0);
+ time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("24:01:00");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_time_value);
+ }
+
+ {
+ context c (0);
+ time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("24:00:01");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_time_value);
+ }
+
+ {
+ context c (0);
+ time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("23:01:01+12:3o");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_time_value);
+ }
+
+ // date_time
+ //
+ {
+ context c (0);
+ date_time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ // p._characters ("");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ context c (0);
+ date_time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("207-01-01T12:13:14");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ context c (0);
+ date_time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-207-01-01T12:13:14");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ context c (0);
+ date_time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("0000-01-01T12:13:14");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ context c (0);
+ date_time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("20X7-01-01T12:13:14");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ context c (0);
+ date_time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ context c (0);
+ date_time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007?01-01T12:13:14");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ context c (0);
+ date_time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-0-01T12:13:14");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ context c (0);
+ date_time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-00-01T12:13:14");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ context c (0);
+ date_time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-13-01T12:13:14");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ context c (0);
+ date_time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-1X-01T12:13:14");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ context c (0);
+ date_time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-10");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ context c (0);
+ date_time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-10?12T12:13:14");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ context c (0);
+ date_time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-10-T12:13:14");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ context c (0);
+ date_time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-10-0T12:13:14");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ context c (0);
+ date_time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-10-00T12:13:14");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ context c (0);
+ date_time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-10-32T12:13:14");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ context c (0);
+ date_time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-10-2XT12:13:14");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ context c (0);
+ date_time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-01-01T1:01:01");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ context c (0);
+ date_time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-01-01T2X:01:01");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ context c (0);
+ date_time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-01-01T23");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ context c (0);
+ date_time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-01-01T23?01:01");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ context c (0);
+ date_time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-01-01T23:0:01");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ context c (0);
+ date_time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-01-01T23:60:01");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ context c (0);
+ date_time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-01-01T23:4X:01");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ context c (0);
+ date_time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-01-01T23:10");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ context c (0);
+ date_time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-01-01T23:10?12");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ context c (0);
+ date_time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-01-01T23:10:");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ context c (0);
+ date_time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-01-01T23:10:0");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ context c (0);
+ date_time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-01-01T23:10:01.");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ context c (0);
+ date_time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-01-01T23:10:60");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ context c (0);
+ date_time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-01-01T23:10:2X");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ context c (0);
+ date_time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-01-01T24:01:00");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ context c (0);
+ date_time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-01-01T24:00:01");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ context c (0);
+ date_time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("23:01:01+12:3o");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ context c (0);
+ date_time_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007-01-01T12:13:14+12:3o");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ // duration
+ //
+ {
+ context c (0);
+ duration_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ // p._characters ("");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_duration_value);
+ }
+
+ {
+ context c (0);
+ duration_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2007Y");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_duration_value);
+ }
+
+ {
+ context c (0);
+ duration_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-2007Y");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_duration_value);
+ }
+
+ {
+ context c (0);
+ duration_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("P-2007Y");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_duration_value);
+ }
+
+ {
+ context c (0);
+ duration_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("P-1M");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_duration_value);
+ }
+
+ {
+ context c (0);
+ duration_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("P-1D");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_duration_value);
+ }
+
+ {
+ context c (0);
+ duration_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("PT-1H");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_duration_value);
+ }
+
+ {
+ context c (0);
+ duration_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("PT-1M");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_duration_value);
+ }
+
+ {
+ context c (0);
+ duration_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("PT-1.1S");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_duration_value);
+ }
+
+ {
+ context c (0);
+ duration_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("P1H1M1S");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_duration_value);
+ }
+
+ {
+ context c (0);
+ duration_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("P1M1Y");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_duration_value);
+ }
+
+ {
+ context c (0);
+ duration_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("PT1S1H");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_duration_value);
+ }
+
+ {
+ context c (0);
+ duration_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("PT1H1Y");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_duration_value);
+ }
+
+ {
+ context c (0);
+ duration_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("P1Ygarbage");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_duration_value);
+ }
+
+ {
+ context c (0);
+ duration_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("P1YT");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_duration_value);
+ }
+}
diff --git a/tests/cxx/parser/validation/built-in/date-time/makefile b/tests/cxx/parser/validation/built-in/date-time/makefile
new file mode 100644
index 0000000..7e0b597
--- /dev/null
+++ b/tests/cxx/parser/validation/built-in/date-time/makefile
@@ -0,0 +1,61 @@
+# file : tests/cxx/parser/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/parser/validation/built-in/float/driver.cxx b/tests/cxx/parser/validation/built-in/float/driver.cxx
new file mode 100644
index 0000000..852d158
--- /dev/null
+++ b/tests/cxx/parser/validation/built-in/float/driver.cxx
@@ -0,0 +1,309 @@
+// file : tests/cxx/parser/validation/built-in/float/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 float, double, and decimal types validation.
+//
+#include <math.h>
+#include <cassert>
+
+#include <xsde/cxx/parser/validating/float.hxx>
+#include <xsde/cxx/parser/validating/double.hxx>
+#include <xsde/cxx/parser/validating/decimal.hxx>
+
+using namespace xsde::cxx::parser;
+using namespace xsde::cxx::parser::validating;
+
+int
+main ()
+{
+ // Good.
+ //
+
+ // float
+ //
+ {
+ context c (0);
+ float_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (" 0000123.456 ");
+ p._post ();
+ assert (!c.error_type () && p.post_float () == 123.456F);
+ }
+
+ {
+ context c (0);
+ float_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-12.345E2");
+ p._post ();
+ assert (!c.error_type () && p.post_float () == -12.345E2F);
+ }
+
+ {
+ context c (0);
+ float_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("0");
+ p._post ();
+ assert (!c.error_type () && p.post_float () == 0.0F);
+ }
+
+ {
+ context c (0);
+ float_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-0");
+ p._post ();
+ assert (!c.error_type () && p.post_float () == -0.0F);
+ }
+
+ {
+ context c (0);
+ float_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("INF");
+ p._post ();
+ assert (!c.error_type () && isinf (p.post_float ()));
+ }
+
+ {
+ context c (0);
+ float_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-INF");
+ p._post ();
+ assert (!c.error_type () && isinf (p.post_float ()));
+ }
+
+ {
+ context c (0);
+ float_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("NaN");
+ p._post ();
+ assert (!c.error_type () && isnan (p.post_float ()));
+ }
+
+ // double
+ //
+ {
+ context c (0);
+ double_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (" 0000123.456789 ");
+ p._post ();
+ assert (!c.error_type () && p.post_double () == 123.456789);
+ }
+
+ {
+ context c (0);
+ double_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-12.3456789E2");
+ p._post ();
+ assert (!c.error_type () && p.post_double () == -12.3456789E2);
+ }
+
+ {
+ context c (0);
+ double_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("0");
+ p._post ();
+ assert (!c.error_type () && p.post_double () == 0.0);
+ }
+
+ {
+ context c (0);
+ double_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-0");
+ p._post ();
+ assert (!c.error_type () && p.post_double () == -0.0);
+ }
+
+ {
+ context c (0);
+ double_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("INF");
+ p._post ();
+ assert (!c.error_type () && isinf (p.post_double ()));
+ }
+
+ {
+ context c (0);
+ double_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-INF");
+ p._post ();
+ assert (!c.error_type () && isinf (p.post_double ()));
+ }
+
+ {
+ context c (0);
+ double_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("NaN");
+ p._post ();
+ assert (!c.error_type () && isnan (p.post_double ()));
+ }
+
+ // decimal
+ //
+ {
+ context c (0);
+ decimal_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (" 0000123.456789 ");
+ p._post ();
+ assert (!c.error_type () && p.post_decimal () == 123.456789);
+ }
+
+ {
+ context c (0);
+ decimal_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-123.45678912345");
+ p._post ();
+ assert (!c.error_type () && p.post_decimal () == -123.45678912345);
+ }
+
+ {
+ context c (0);
+ decimal_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("0");
+ p._post ();
+ assert (!c.error_type () && p.post_decimal () == 0.0);
+ }
+
+ {
+ context c (0);
+ decimal_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-0");
+ p._post ();
+ assert (!c.error_type () && p.post_decimal () == -0.0);
+ }
+
+
+ // Bad
+ //
+
+ // float
+ //
+ {
+ context c (0);
+ float_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("+INF");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ float_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("1.45 E2");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ // double
+ //
+ {
+ context c (0);
+ double_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("+INF");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ double_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("1.45 E2");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ // decimal
+ //
+ {
+ context c (0);
+ decimal_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("INF");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ decimal_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("+INF");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ decimal_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-INF");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ decimal_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("NaN");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ decimal_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("1.45 2");
+ p._post ();
+ assert (c.schema_error ());
+ }
+}
diff --git a/tests/cxx/parser/validation/built-in/float/makefile b/tests/cxx/parser/validation/built-in/float/makefile
new file mode 100644
index 0000000..0e5231e
--- /dev/null
+++ b/tests/cxx/parser/validation/built-in/float/makefile
@@ -0,0 +1,61 @@
+# file : tests/cxx/parser/validation/built-in/float/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/parser/validation/built-in/int/driver.cxx b/tests/cxx/parser/validation/built-in/int/driver.cxx
new file mode 100644
index 0000000..2395b04
--- /dev/null
+++ b/tests/cxx/parser/validation/built-in/int/driver.cxx
@@ -0,0 +1,116 @@
+// file : tests/cxx/parser/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 int and unsigned int types validation.
+//
+#include <cassert>
+
+#include <xsde/cxx/parser/validating/int.hxx>
+#include <xsde/cxx/parser/validating/unsigned-int.hxx>
+
+using namespace xsde::cxx::parser;
+using namespace xsde::cxx::parser::validating;
+
+int
+main ()
+{
+ // Good.
+ //
+ {
+ context c (0);
+ int_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-2147483648");
+ p._post ();
+ assert (!c.error_type () && p.post_int () == -2147483648);
+ }
+
+ {
+ context c (0);
+ int_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("0");
+ p._post ();
+ assert (!c.error_type () && p.post_int () == 0);
+ }
+
+ {
+ context c (0);
+ int_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2147483647");
+ p._post ();
+ assert (!c.error_type () && p.post_int () == 2147483647);
+ }
+
+ {
+ context c (0);
+ unsigned_int_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("0");
+ p._post ();
+ assert (!c.error_type () && p.post_unsigned_int () == 0);
+ }
+
+ {
+ context c (0);
+ unsigned_int_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("4294967295");
+ p._post ();
+ assert (!c.error_type () && p.post_unsigned_int () == 4294967295);
+ }
+
+ // Bad
+ //
+
+ {
+ context c (0);
+ unsigned_int_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-123");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+
+ // Ranges
+ //
+ {
+ context c (0);
+ int_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-2147483649");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ int_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2147483648");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ unsigned_int_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("4294967296");
+ p._post ();
+ assert (c.schema_error ());
+ }
+}
diff --git a/tests/cxx/parser/validation/built-in/int/makefile b/tests/cxx/parser/validation/built-in/int/makefile
new file mode 100644
index 0000000..0fc4608
--- /dev/null
+++ b/tests/cxx/parser/validation/built-in/int/makefile
@@ -0,0 +1,61 @@
+# file : tests/cxx/parser/validation/built-in/int/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/parser/validation/built-in/integer/driver.cxx b/tests/cxx/parser/validation/built-in/integer/driver.cxx
new file mode 100644
index 0000000..9676046
--- /dev/null
+++ b/tests/cxx/parser/validation/built-in/integer/driver.cxx
@@ -0,0 +1,317 @@
+// file : tests/cxx/parser/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 <limits.h>
+
+#include <string>
+#include <sstream>
+#include <cassert>
+
+#include <xsde/cxx/parser/validating/integer.hxx>
+#include <xsde/cxx/parser/validating/negative-integer.hxx>
+#include <xsde/cxx/parser/validating/non-positive-integer.hxx>
+#include <xsde/cxx/parser/validating/positive-integer.hxx>
+#include <xsde/cxx/parser/validating/non-negative-integer.hxx>
+
+using namespace std;
+using namespace xsde::cxx::parser;
+using namespace xsde::cxx::parser::validating;
+
+int
+main ()
+{
+ // Good.
+ //
+
+ std::string min;
+ std::string max;
+ std::string umax;
+
+ {
+ ostringstream ostr;
+ ostr << LONG_MIN;
+ min = ostr.str ();
+ }
+
+ {
+ ostringstream ostr;
+ ostr << LONG_MAX;
+ max = ostr.str ();
+ }
+
+ {
+ ostringstream ostr;
+ ostr << ULONG_MAX;
+ umax = ostr.str ();
+ }
+
+ // integer
+ //
+ {
+ context c (0);
+ integer_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (min.c_str ());
+ p._post ();
+ assert (!c.error_type () && p.post_integer () == LONG_MIN);
+ }
+
+ {
+ context c (0);
+ integer_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("0");
+ p._post ();
+ assert (!c.error_type () && p.post_integer () == 0);
+ }
+
+ {
+ context c (0);
+ integer_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (max.c_str ());
+ p._post ();
+ assert (!c.error_type () && p.post_integer () == LONG_MAX);
+ }
+
+ // negative_integer
+ //
+ {
+ context c (0);
+ negative_integer_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (min.c_str ());
+ p._post ();
+ assert (!c.error_type () && p.post_negative_integer () == LONG_MIN);
+ }
+
+ {
+ context c (0);
+ negative_integer_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-1");
+ p._post ();
+ assert (!c.error_type () && p.post_negative_integer () == -1);
+ }
+
+ // non_positive_integer
+ //
+ {
+ context c (0);
+ non_positive_integer_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (min.c_str ());
+ p._post ();
+ assert (!c.error_type () && p.post_non_positive_integer () == LONG_MIN);
+ }
+
+ {
+ context c (0);
+ non_positive_integer_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("+0");
+ p._post ();
+ assert (!c.error_type () && p.post_non_positive_integer () == 0);
+ }
+
+ // positive_integer
+ //
+ {
+ context c (0);
+ positive_integer_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("1");
+ p._post ();
+ assert (!c.error_type () && p.post_positive_integer () == 1);
+ }
+
+ {
+ context c (0);
+ positive_integer_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (umax.c_str ());
+ p._post ();
+ assert (!c.error_type () && p.post_positive_integer () == ULONG_MAX);
+ }
+
+ // non_negative_integer
+ //
+ {
+ context c (0);
+ non_negative_integer_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-0");
+ p._post ();
+ assert (!c.error_type () && p.post_non_negative_integer () == 0);
+ }
+
+ {
+ context c (0);
+ non_negative_integer_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (umax.c_str ());
+ p._post ();
+ assert (!c.error_type () && p.post_non_negative_integer () == ULONG_MAX);
+ }
+
+
+ // Bad
+ //
+
+ std::string past_min (min);
+ std::string past_max (max);
+ std::string past_umax (umax);
+
+ assert (*past_min.rbegin () != '9');
+ assert (*past_max.rbegin () != '9');
+ assert (*past_umax.rbegin () != '9');
+
+ (*past_min.rbegin ())++;
+ (*past_max.rbegin ())++;
+ (*past_umax.rbegin ())++;
+
+ // integer
+ //
+ {
+ context c (0);
+ integer_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (past_min.c_str ());
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ integer_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (past_max.c_str ());
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ // negative_integer
+ //
+ {
+ context c (0);
+ negative_integer_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (past_min.c_str ());
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ negative_integer_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-0");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ negative_integer_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("1");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ // non_positive_integer
+ //
+ {
+ context c (0);
+ non_positive_integer_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (past_min.c_str ());
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ non_positive_integer_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("1");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ // positive_integer
+ //
+ {
+ context c (0);
+ positive_integer_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-1");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ positive_integer_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("+0");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ positive_integer_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (past_umax.c_str ());
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ // non_negative_integer
+ //
+ {
+ context c (0);
+ non_negative_integer_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-1");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ non_negative_integer_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (past_umax.c_str ());
+ p._post ();
+ assert (c.schema_error ());
+ }
+}
diff --git a/tests/cxx/parser/validation/built-in/integer/makefile b/tests/cxx/parser/validation/built-in/integer/makefile
new file mode 100644
index 0000000..8e5fa68
--- /dev/null
+++ b/tests/cxx/parser/validation/built-in/integer/makefile
@@ -0,0 +1,61 @@
+# file : tests/cxx/parser/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/parser/validation/built-in/long-long/driver.cxx b/tests/cxx/parser/validation/built-in/long-long/driver.cxx
new file mode 100644
index 0000000..3ddf6d9
--- /dev/null
+++ b/tests/cxx/parser/validation/built-in/long-long/driver.cxx
@@ -0,0 +1,118 @@
+// file : tests/cxx/parser/validation/built-in/long-long/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 long and unsigned long types validation.
+//
+#include <cassert>
+
+#include <xsde/cxx/parser/validating/long-long.hxx>
+#include <xsde/cxx/parser/validating/unsigned-long-long.hxx>
+
+using namespace xsde::cxx::parser;
+using namespace xsde::cxx::parser::validating;
+
+int
+main ()
+{
+ // Good.
+ //
+ {
+ context c (0);
+ long_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-9223372036854775808");
+ p._post ();
+ assert (!c.error_type () &&
+ p.post_long () == (-9223372036854775807LL - 1));
+ }
+
+ {
+ context c (0);
+ long_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("0");
+ p._post ();
+ assert (!c.error_type () && p.post_long () == 0);
+ }
+
+ {
+ context c (0);
+ long_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("9223372036854775807");
+ p._post ();
+ assert (!c.error_type () && p.post_long () == 9223372036854775807LL);
+ }
+
+ {
+ context c (0);
+ unsigned_long_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("0");
+ p._post ();
+ assert (!c.error_type () && p.post_unsigned_long () == 0);
+ }
+
+ {
+ context c (0);
+ unsigned_long_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("18446744073709551615");
+ p._post ();
+ assert (!c.error_type () &&
+ p.post_unsigned_long () == 18446744073709551615ULL);
+ }
+
+ // Bad
+ //
+
+ {
+ context c (0);
+ unsigned_long_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-123");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+
+ // Ranges
+ //
+ {
+ context c (0);
+ long_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-9223372036854775809");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ long_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("9223372036854775808");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ unsigned_long_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("18446744073709551616");
+ p._post ();
+ assert (c.schema_error ());
+ }
+}
diff --git a/tests/cxx/parser/validation/built-in/long-long/makefile b/tests/cxx/parser/validation/built-in/long-long/makefile
new file mode 100644
index 0000000..948c89a
--- /dev/null
+++ b/tests/cxx/parser/validation/built-in/long-long/makefile
@@ -0,0 +1,61 @@
+# file : tests/cxx/parser/validation/built-in/long-long/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/parser/validation/built-in/long/driver.cxx b/tests/cxx/parser/validation/built-in/long/driver.cxx
new file mode 100644
index 0000000..0312b3b
--- /dev/null
+++ b/tests/cxx/parser/validation/built-in/long/driver.cxx
@@ -0,0 +1,106 @@
+// file : tests/cxx/parser/validation/built-in/long/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 built-in long and unsigned long types validation (32 bit fall-back).
+//
+#include <cassert>
+
+#include <xsde/cxx/parser/validating/long.hxx>
+#include <xsde/cxx/parser/validating/unsigned-long.hxx>
+
+using namespace xsde::cxx::parser;
+using namespace xsde::cxx::parser::validating;
+
+int
+main (int argc, char* argv[])
+{
+ // Good.
+ //
+ {
+ context c (0);
+ long_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-2147483648");
+ p._post ();
+ assert (!c.error_type () && p.post_long () == -2147483648);
+ }
+
+ {
+ context c (0);
+ long_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("0");
+ p._post ();
+ assert (!c.error_type () && p.post_long () == 0);
+ }
+
+ {
+ context c (0);
+ long_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2147483647");
+ p._post ();
+ assert (!c.error_type () && p.post_long () == 2147483647);
+ }
+
+ {
+ context c (0);
+ unsigned_long_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("0");
+ p._post ();
+ assert (!c.error_type () && p.post_unsigned_long () == 0);
+ }
+
+ {
+ context c (0);
+ unsigned_long_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("4294967295");
+ p._post ();
+ assert (!c.error_type () && p.post_unsigned_long () == 4294967295);
+ }
+
+ // Bad
+ //
+
+ {
+ context c (0);
+ unsigned_long_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-123");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+
+ // Ranges
+ //
+ {
+ context c (0);
+ long_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-2147483649");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ long_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("2147483648");
+ p._post ();
+ assert (c.schema_error ());
+ }
+}
diff --git a/tests/cxx/parser/validation/built-in/long/makefile b/tests/cxx/parser/validation/built-in/long/makefile
new file mode 100644
index 0000000..e050feb
--- /dev/null
+++ b/tests/cxx/parser/validation/built-in/long/makefile
@@ -0,0 +1,61 @@
+# file : tests/cxx/parser/validation/built-in/long/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/parser/validation/built-in/makefile b/tests/cxx/parser/validation/built-in/makefile
new file mode 100644
index 0000000..0e6b3aa
--- /dev/null
+++ b/tests/cxx/parser/validation/built-in/makefile
@@ -0,0 +1,35 @@
+# file : tests/cxx/parser/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 := binary boolean byte date-time float int integer qname short \
+string uri
+
+ifeq ($(xsde_iostream),y)
+ifeq ($(xsde_exceptions),y)
+ifeq ($(xsde_reuse_style),tiein)
+tests += any-type
+endif
+endif
+endif
+
+ifeq ($(xsde_longlong),y)
+tests += long-long
+else
+tests += long
+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/parser/validation/built-in/qname/driver.cxx b/tests/cxx/parser/validation/built-in/qname/driver.cxx
new file mode 100644
index 0000000..f3acc6b
--- /dev/null
+++ b/tests/cxx/parser/validation/built-in/qname/driver.cxx
@@ -0,0 +1,132 @@
+// file : tests/cxx/parser/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/parser/validating/xml-schema-pimpl.hxx>
+
+using namespace xsde::cxx;
+using namespace xsde::cxx::parser;
+using namespace xsde::cxx::parser::validating;
+
+#ifdef XSDE_STL
+bool
+compare (const qname& x, const char* p, const char* n)
+{
+ return x == qname (p, n);
+}
+#else
+bool
+compare (qname* x, const char* p, const char* n)
+{
+ qname y;
+ y.prefix_copy (p);
+ y.name_copy (n);
+
+ bool r = *x == y;
+ delete x;
+ return r;
+}
+#endif
+
+int
+main ()
+{
+ // Good.
+ //
+ {
+ context c (0);
+ qname_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (" xsi");
+ p._characters (":");
+ p._characters ("schemaLocation");
+ p._post ();
+ assert (!c.error_type () &&
+ compare (p.post_qname (), "xsi", "schemaLocation"));
+ }
+
+ {
+ context c (0);
+ qname_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("schemaLocation");
+ p._post ();
+ assert (!c.error_type () &&
+ compare (p.post_qname (), "", "schemaLocation"));
+ }
+
+
+ // Bad
+ //
+ {
+ context c (0);
+ qname_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ //p._characters ("");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_qname_value);
+ }
+
+ {
+ context c (0);
+ qname_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (":");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_qname_value);
+ }
+
+ {
+ context c (0);
+ qname_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("xsi:");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_qname_value);
+ }
+
+ {
+ context c (0);
+ qname_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (":schemaLocation");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_qname_value);
+ }
+
+ {
+ context c (0);
+ qname_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("x?i:schemaLocation");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_qname_value);
+ }
+
+ {
+ context c (0);
+ qname_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("xsi:schema Location");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_qname_value);
+ }
+}
diff --git a/tests/cxx/parser/validation/built-in/qname/makefile b/tests/cxx/parser/validation/built-in/qname/makefile
new file mode 100644
index 0000000..eed5151
--- /dev/null
+++ b/tests/cxx/parser/validation/built-in/qname/makefile
@@ -0,0 +1,61 @@
+# file : tests/cxx/parser/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/parser/validation/built-in/short/driver.cxx b/tests/cxx/parser/validation/built-in/short/driver.cxx
new file mode 100644
index 0000000..6822f61
--- /dev/null
+++ b/tests/cxx/parser/validation/built-in/short/driver.cxx
@@ -0,0 +1,116 @@
+// file : tests/cxx/parser/validation/built-in/short/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 short and unsigned short types validation.
+//
+#include <cassert>
+
+#include <xsde/cxx/parser/validating/short.hxx>
+#include <xsde/cxx/parser/validating/unsigned-short.hxx>
+
+using namespace xsde::cxx::parser;
+using namespace xsde::cxx::parser::validating;
+
+int
+main ()
+{
+ // Good.
+ //
+ {
+ context c (0);
+ short_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-32768");
+ p._post ();
+ assert (!c.error_type () && p.post_short () == -32768);
+ }
+
+ {
+ context c (0);
+ short_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("0");
+ p._post ();
+ assert (!c.error_type () && p.post_short () == 0);
+ }
+
+ {
+ context c (0);
+ short_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("32767");
+ p._post ();
+ assert (!c.error_type () && p.post_short () == 32767);
+ }
+
+ {
+ context c (0);
+ unsigned_short_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("0");
+ p._post ();
+ assert (!c.error_type () && p.post_unsigned_short () == 0);
+ }
+
+ {
+ context c (0);
+ unsigned_short_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("65535");
+ p._post ();
+ assert (!c.error_type () && p.post_unsigned_short () == 65535);
+ }
+
+ // Bad
+ //
+
+ {
+ context c (0);
+ unsigned_short_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-1234");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+
+ // Ranges
+ //
+ {
+ context c (0);
+ short_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-32769");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ short_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("32768");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ unsigned_short_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("65536");
+ p._post ();
+ assert (c.schema_error ());
+ }
+}
diff --git a/tests/cxx/parser/validation/built-in/short/makefile b/tests/cxx/parser/validation/built-in/short/makefile
new file mode 100644
index 0000000..d82fc91
--- /dev/null
+++ b/tests/cxx/parser/validation/built-in/short/makefile
@@ -0,0 +1,61 @@
+# file : tests/cxx/parser/validation/built-in/short/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/parser/validation/built-in/string/driver.cxx b/tests/cxx/parser/validation/built-in/string/driver.cxx
new file mode 100644
index 0000000..06a4708
--- /dev/null
+++ b/tests/cxx/parser/validation/built-in/string/driver.cxx
@@ -0,0 +1,613 @@
+// file : tests/cxx/parser/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/parser/validating/xml-schema-pimpl.hxx>
+
+using namespace xsde::cxx;
+using namespace xsde::cxx::parser;
+using namespace xsde::cxx::parser::validating;
+
+bool
+compare (const string_sequence* x, const string_sequence& y)
+{
+ bool r = *x == y;
+ delete x;
+ return r;
+}
+
+int
+main ()
+{
+ // We are going to leak a bit of memory in the no-STL case.
+ //
+ using std::string;
+
+ // Good.
+ //
+
+ // string
+ //
+ {
+ context c (0);
+ string_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (" \n\t");
+ p._characters (" aaa ");
+ p._characters ("bbb");
+ p._characters (" ");
+ p._post ();
+ assert (!c.error_type () &&
+ p.post_string () == string (" \n\t aaa bbb "));
+ }
+
+ // normalized_string
+ //
+ {
+ context c (0);
+ normalized_string_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (" \n\t");
+ p._characters (" aaa \n\t ");
+ p._characters (" bbb");
+ p._characters (" ");
+ p._post ();
+ assert (!c.error_type () &&
+ p.post_normalized_string () == string (" aaa bbb "));
+ }
+
+ // token
+ //
+ {
+ context c (0);
+ token_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (" \n\t");
+ p._characters (" aaa \n\t ");
+ p._characters (" bbb \n\t");
+ p._characters (" ");
+ p._post ();
+ assert (!c.error_type () &&
+ p.post_token () == string ("aaa bbb"));
+ }
+
+ // name
+ //
+ {
+ context c (0);
+ name_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (" \n\t");
+ p._characters (" a:b-c_d123 ");
+ p._characters (" ");
+ p._post ();
+ assert (!c.error_type () &&
+ p.post_name () == string ("a:b-c_d123"));
+ }
+
+ {
+ context c (0);
+ name_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (" \n\t");
+ p._characters (" _12 ");
+ p._characters (" ");
+ p._post ();
+ assert (!c.error_type () &&
+ p.post_name () == string ("_12"));
+ }
+
+ {
+ context c (0);
+ name_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (" \n\t");
+ p._characters (" :12 ");
+ p._characters (" ");
+ p._post ();
+ assert (!c.error_type () &&
+ p.post_name () == string (":12"));
+ }
+
+ // nmtoken
+ //
+ {
+ context c (0);
+ nmtoken_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (" \n\t");
+ p._characters (" 123a:b-c_d123 ");
+ p._characters (" \n\t");
+ p._characters (" ");
+ p._post ();
+ assert (!c.error_type () &&
+ p.post_nmtoken () == string ("123a:b-c_d123"));
+ }
+
+ // nmtokens
+ //
+ {
+ context c (0);
+ string_sequence s;
+#ifdef XSDE_STL
+ s.push_back ("123");
+ s.push_back ("abc");
+#else
+ s.push_back_copy ("123");
+ s.push_back_copy ("abc");
+#endif
+
+ nmtokens_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (" \n\t");
+ p._characters (" 123 ");
+ p._characters (" \n\t abc ");
+ p._characters (" ");
+ p._post ();
+ assert (!c.error_type () && compare (p.post_nmtokens (), s));
+ }
+
+ // ncname
+ //
+ {
+ context c (0);
+ ncname_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (" \n\t");
+ p._characters (" a.b-c_d123 ");
+ p._characters (" ");
+ p._post ();
+ assert (!c.error_type () &&
+ p.post_ncname () == string ("a.b-c_d123"));
+ }
+
+ // id
+ //
+ {
+ context c (0);
+ id_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (" \n\t");
+ p._characters (" a.b-c_d123 ");
+ p._characters (" ");
+ p._post ();
+ assert (!c.error_type () &&
+ p.post_id () == string ("a.b-c_d123"));
+ }
+
+ // idref
+ //
+ {
+ context c (0);
+ idref_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (" \n\t");
+ p._characters (" a.b-c_d123 ");
+ p._characters (" ");
+ p._post ();
+ assert (!c.error_type () &&
+ p.post_idref () == string ("a.b-c_d123"));
+ }
+
+ // idrefs
+ //
+ {
+ context c (0);
+ string_sequence s;
+#ifdef XSDE_STL
+ s.push_back ("a123");
+ s.push_back ("abc");
+#else
+ s.push_back_copy ("a123");
+ s.push_back_copy ("abc");
+#endif
+
+ idrefs_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (" \n\t");
+ p._characters (" a123 ");
+ p._characters (" \n\t abc ");
+ p._characters (" ");
+ p._post ();
+ assert (!c.error_type () && compare (p.post_idrefs (), s));
+ }
+
+ // language
+ //
+ {
+ context c (0);
+ language_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (" x ");
+ p._post ();
+ assert (!c.error_type () && p.post_language () == string ("x"));
+ }
+
+ {
+ context c (0);
+ language_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (" en ");
+ p._post ();
+ assert (!c.error_type () && p.post_language () == string ("en"));
+ }
+
+ {
+ context c (0);
+ language_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (" en");
+ p._characters ("-us ");
+ p._post ();
+ assert (!c.error_type () && p.post_language () == string ("en-us"));
+ }
+
+ {
+ context c (0);
+ language_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("one-two-three-four44-seven77-eight888");
+ p._post ();
+ assert (!c.error_type () &&
+ p.post_language () ==
+ string ("one-two-three-four44-seven77-eight888"));
+ }
+
+ // Bad
+ //
+
+ // name
+ //
+ {
+ context c (0);
+ name_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ name_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (".a");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ name_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-a");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ name_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("1a");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ name_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("a,b");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ name_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("a b");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ name_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("a<b");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ // nmtoken
+ //
+ {
+ context c (0);
+ nmtoken_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ nmtoken_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("a,b");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ nmtoken_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("a b");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ nmtoken_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("a<b");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ // nmtokens
+ //
+ {
+ context c (0);
+ nmtokens_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (" ");
+ p._characters (" \t\n ");
+ p._post_impl ();
+ assert (c.schema_error () == schema_error::invalid_nmtokens_value);
+ }
+
+ {
+ context c (0);
+ nmtokens_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("ab a,b");
+ p._post_impl ();
+ assert (c.schema_error () == schema_error::invalid_nmtoken_value);
+ }
+
+ // ncname
+ //
+ {
+ context c (0);
+ ncname_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ ncname_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (".a");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ ncname_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("-a");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ ncname_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (":a");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ ncname_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("1a");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ ncname_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("a:b");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ ncname_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("a,b");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ ncname_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("a b");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ {
+ context c (0);
+ ncname_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("a<b");
+ p._post ();
+ assert (c.schema_error ());
+ }
+
+ // id
+ //
+ {
+ context c (0);
+ id_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("a b");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_id_value);
+ }
+
+ // idref
+ //
+ {
+ context c (0);
+ idref_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("a b");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_idref_value);
+ }
+
+ // idrefs
+ //
+ {
+ context c (0);
+ idrefs_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (" ");
+ p._characters (" \t\n ");
+ p._post_impl ();
+ assert (c.schema_error () == schema_error::invalid_idrefs_value);
+ }
+
+ {
+ context c (0);
+ idrefs_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("ab a<b");
+ p._post_impl ();
+ assert (c.schema_error () == schema_error::invalid_idref_value);
+ }
+
+ // language
+ //
+ {
+ context c (0);
+ language_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (" ");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_language_value);
+ }
+
+ {
+ context c (0);
+ language_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("en-");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_language_value);
+ }
+
+ {
+ context c (0);
+ language_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("a1");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_language_value);
+ }
+
+ {
+ context c (0);
+ language_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("en+us");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_language_value);
+ }
+
+ {
+ context c (0);
+ language_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("en-nine99999");
+ p._post ();
+ assert (c.schema_error () == schema_error::invalid_language_value);
+ }
+}
diff --git a/tests/cxx/parser/validation/built-in/string/makefile b/tests/cxx/parser/validation/built-in/string/makefile
new file mode 100644
index 0000000..27fc822
--- /dev/null
+++ b/tests/cxx/parser/validation/built-in/string/makefile
@@ -0,0 +1,61 @@
+# file : tests/cxx/parser/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/parser/validation/built-in/uri/driver.cxx b/tests/cxx/parser/validation/built-in/uri/driver.cxx
new file mode 100644
index 0000000..5d1f91a
--- /dev/null
+++ b/tests/cxx/parser/validation/built-in/uri/driver.cxx
@@ -0,0 +1,66 @@
+// file : tests/cxx/parser/validation/built-in/uri/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 anyURI type validation.
+//
+#include <string>
+#include <cassert>
+
+// Let the runtime header sort out which version (stl/no-stl) to
+// include.
+//
+#include <xsde/cxx/parser/validating/xml-schema-pimpl.hxx>
+
+using namespace xsde::cxx::parser;
+using namespace xsde::cxx::parser::validating;
+
+int
+main ()
+{
+ using std::string;
+
+ // Good.
+ //
+ {
+ context c (0);
+ uri_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters (" ");
+ p._post ();
+ assert (!c.error_type () && p.post_uri () == string (""));
+ }
+
+ {
+ context c (0);
+ uri_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("relative");
+ p._post ();
+ assert (!c.error_type () && p.post_uri () == string ("relative"));
+ }
+
+ {
+ context c (0);
+ uri_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("#id");
+ p._post ();
+ assert (!c.error_type () && p.post_uri () == string ("#id"));
+ }
+
+ {
+ context c (0);
+ uri_pimpl p;
+ p.pre ();
+ p._pre_impl (c);
+ p._characters ("http://www.example.com/foo#bar");
+ p._post ();
+ assert (!c.error_type () &&
+ p.post_uri () == string ("http://www.example.com/foo#bar"));
+ }
+}
diff --git a/tests/cxx/parser/validation/built-in/uri/makefile b/tests/cxx/parser/validation/built-in/uri/makefile
new file mode 100644
index 0000000..09da436
--- /dev/null
+++ b/tests/cxx/parser/validation/built-in/uri/makefile
@@ -0,0 +1,61 @@
+# file : tests/cxx/parser/validation/built-in/uri/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/parser/validation/choice/driver.cxx b/tests/cxx/parser/validation/choice/driver.cxx
new file mode 100644
index 0000000..e49539a
--- /dev/null
+++ b/tests/cxx/parser/validation/choice/driver.cxx
@@ -0,0 +1,158 @@
+// file : tests/cxx/parser/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 the choice compositor validation.
+//
+
+#include <string>
+#include <iostream>
+
+#include "test-pskel.hxx"
+
+using namespace std;
+using namespace test;
+using xml_schema::ro_string;
+
+struct choice_pimpl: choice_pskel
+{
+ virtual void
+ pre ()
+ {
+ cout << "{" << endl;
+ }
+
+#ifdef XSDE_STL
+ virtual void
+ a (string const& v)
+ {
+ cout << " a = " << v << endl;
+ }
+
+ virtual void
+ b (string const& v)
+ {
+ cout << " b = " << v << endl;
+ }
+
+ virtual void
+ c (string const& v)
+ {
+ cout << " c = " << v << endl;
+ }
+
+ virtual void
+ d (string const& v)
+ {
+ cout << " d = " << v << endl;
+ }
+#else
+ virtual void
+ a (char* v)
+ {
+ cout << " a = " << v << endl;
+ delete[] v;
+ }
+
+ virtual void
+ b (char* v)
+ {
+ cout << " b = " << v << endl;
+ delete[] v;
+ }
+
+ virtual void
+ c (char* v)
+ {
+ cout << " c = " << v << endl;
+ delete[] v;
+ }
+
+ virtual void
+ d (char* v)
+ {
+ cout << " d = " << v << endl;
+ delete[] v;
+ }
+#endif
+
+ virtual void
+#ifndef XSDE_POLYMORPHIC
+ _start_any_element (ro_string const& ns, ro_string const& name)
+#else
+ _start_any_element (ro_string const& ns, ro_string const& name, const char*)
+#endif
+ {
+ cout << " any: " << ns << "#" << name << endl
+ << " {" << endl;
+ }
+
+ virtual void
+ _any_characters (ro_string const& v)
+ {
+ cout << " chars = " << v << endl;
+ }
+
+ virtual void
+ _end_any_element (ro_string const&, ro_string const&)
+ {
+ cout << " }" << endl;
+ }
+
+ virtual void
+ post_choice ()
+ {
+ cout << "}" << endl
+ << endl;
+ }
+};
+
+struct type_pimpl: type_pskel
+{
+};
+
+int
+main (int argc, char* argv[])
+{
+ if (argc != 2)
+ {
+ cerr << "usage: " << argv[0] << " test.xml" << endl;
+ return 1;
+ }
+
+ try
+ {
+ xml_schema::string_pimpl string_p;
+ choice_pimpl choice_p;
+ type_pimpl type_p;
+
+ choice_p.parsers (string_p, string_p, string_p, string_p);
+ type_p.parsers (choice_p);
+
+ xml_schema::document_pimpl doc_p (type_p, "test", "root");
+
+ try
+ {
+ type_p.pre ();
+ doc_p.parse (argv[1]);
+ type_p.post_type ();
+ }
+ catch (xml_schema::parser_exception const& e)
+ {
+ cout << " " << e.line () << ":" << e.column () << " " << e << endl
+ << "}" << endl
+ << endl;
+ }
+ }
+ catch (xml_schema::parser_exception const& e)
+ {
+ cerr << e << endl;
+ return 1;
+ }
+ catch (ios_base::failure const&)
+ {
+ cerr << "io failure" << endl;
+ return 1;
+ }
+}
diff --git a/tests/cxx/parser/validation/choice/makefile b/tests/cxx/parser/validation/choice/makefile
new file mode 100644
index 0000000..0df0020
--- /dev/null
+++ b/tests/cxx/parser/validation/choice/makefile
@@ -0,0 +1,81 @@
+# file : tests/cxx/parser/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
+
+tests := 000 001 002 003 004
+
+obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=-pskel.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=-pskel.hxx) \
+ $(out_base)/$(xsd:.xsd=-pskel.ixx) \
+ $(out_base)/$(xsd:.xsd=-pskel.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.
+#
+test_targets := $(addprefix $(out_base)/.test-,$(tests))
+
+.PHONY: $(test)
+$(test): $(test_targets)
+
+
+$(test_targets): driver := $(driver)
+
+.PHONY: $(out_base)/.test-%
+$(out_base)/.test-%: $(driver) $(src_base)/test.xsd $(src_base)/test-%.xml $(src_base)/test-%.std
+ $(call message,test $(out_base)/$*,$(driver) $(src_base)/test-$*.xml | diff -u $(src_base)/test-$*.std -)
+
+
+# Clean.
+#
+.PHONY: $(clean)
+
+$(clean): $(driver).o.clean \
+ $(addsuffix .cxx.clean,$(obj)) \
+ $(addsuffix .cxx.clean,$(dep)) \
+ $(addprefix $(out_base)/,$(xsd:.xsd=-pskel.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/parser/xsd-cxx.make)
+
+
+# Dependencies.
+#
+$(call import,$(src_root)/xsde/makefile)
+$(call import,$(src_root)/libxsde/xsde/makefile) \ No newline at end of file
diff --git a/tests/cxx/parser/validation/choice/test-000.std b/tests/cxx/parser/validation/choice/test-000.std
new file mode 100644
index 0000000..856b7f5
--- /dev/null
+++ b/tests/cxx/parser/validation/choice/test-000.std
@@ -0,0 +1,22 @@
+{
+ a = a
+ b = b
+}
+
+{
+ c = c
+ d = d
+ any: other#any
+ {
+ chars = any
+ }
+ a = a
+}
+
+{
+ c = c
+ d = d
+ d = d
+ a = a
+}
+
diff --git a/tests/cxx/parser/validation/choice/test-000.xml b/tests/cxx/parser/validation/choice/test-000.xml
new file mode 100644
index 0000000..39b9614
--- /dev/null
+++ b/tests/cxx/parser/validation/choice/test-000.xml
@@ -0,0 +1,30 @@
+<t:root xmlns:t="test"
+ xmlns:o="other"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <choice>
+ <a>a</a>
+
+ <b>b</b>
+ </choice>
+
+ <choice>
+ <c>c</c>
+ <d>d</d>
+
+ <o:any>any</o:any>
+
+ <a>a</a>
+ </choice>
+
+ <choice>
+ <c>c</c>
+ <d>d</d>
+
+ <d>d</d>
+
+ <a>a</a>
+ </choice>
+
+</t:root>
diff --git a/tests/cxx/parser/validation/choice/test-001.std b/tests/cxx/parser/validation/choice/test-001.std
new file mode 100644
index 0000000..3be2413
--- /dev/null
+++ b/tests/cxx/parser/validation/choice/test-001.std
@@ -0,0 +1,4 @@
+{
+ 8:11 expected element not encountered
+}
+
diff --git a/tests/cxx/parser/validation/choice/test-001.xml b/tests/cxx/parser/validation/choice/test-001.xml
new file mode 100644
index 0000000..c509e0d
--- /dev/null
+++ b/tests/cxx/parser/validation/choice/test-001.xml
@@ -0,0 +1,10 @@
+<t:root xmlns:t="test"
+ xmlns:o="other"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- invalid -->
+ <choice>
+ </choice>
+
+</t:root>
diff --git a/tests/cxx/parser/validation/choice/test-002.std b/tests/cxx/parser/validation/choice/test-002.std
new file mode 100644
index 0000000..0de284d
--- /dev/null
+++ b/tests/cxx/parser/validation/choice/test-002.std
@@ -0,0 +1,11 @@
+{
+ c = c
+ d = d
+ any: other#any
+ {
+ chars = any
+ }
+ a = a
+ 14:7 unexpected element encountered
+}
+
diff --git a/tests/cxx/parser/validation/choice/test-002.xml b/tests/cxx/parser/validation/choice/test-002.xml
new file mode 100644
index 0000000..3b7e663
--- /dev/null
+++ b/tests/cxx/parser/validation/choice/test-002.xml
@@ -0,0 +1,17 @@
+<t:root xmlns:t="test"
+ xmlns:o="other"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- invalid -->
+ <choice>
+ <c>c</c>
+ <d>d</d>
+
+ <o:any>any</o:any>
+
+ <a>a</a>
+ <b>b</b>
+ </choice>
+
+</t:root>
diff --git a/tests/cxx/parser/validation/choice/test-003.std b/tests/cxx/parser/validation/choice/test-003.std
new file mode 100644
index 0000000..8ecfdc2
--- /dev/null
+++ b/tests/cxx/parser/validation/choice/test-003.std
@@ -0,0 +1,5 @@
+{
+ c = c
+ 9:11 expected element not encountered
+}
+
diff --git a/tests/cxx/parser/validation/choice/test-003.xml b/tests/cxx/parser/validation/choice/test-003.xml
new file mode 100644
index 0000000..ba15c7e
--- /dev/null
+++ b/tests/cxx/parser/validation/choice/test-003.xml
@@ -0,0 +1,11 @@
+<t:root xmlns:t="test"
+ xmlns:o="other"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- invalid -->
+ <choice>
+ <c>c</c>
+ </choice>
+
+</t:root>
diff --git a/tests/cxx/parser/validation/choice/test-004.std b/tests/cxx/parser/validation/choice/test-004.std
new file mode 100644
index 0000000..400577a
--- /dev/null
+++ b/tests/cxx/parser/validation/choice/test-004.std
@@ -0,0 +1,4 @@
+{
+ 8:7 expected element not encountered
+}
+
diff --git a/tests/cxx/parser/validation/choice/test-004.xml b/tests/cxx/parser/validation/choice/test-004.xml
new file mode 100644
index 0000000..f6960dd
--- /dev/null
+++ b/tests/cxx/parser/validation/choice/test-004.xml
@@ -0,0 +1,11 @@
+<t:root xmlns:t="test"
+ xmlns:o="other"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- invalid -->
+ <choice>
+ <x>x</x>
+ </choice>
+
+</t:root>
diff --git a/tests/cxx/parser/validation/choice/test.xsd b/tests/cxx/parser/validation/choice/test.xsd
new file mode 100644
index 0000000..8132bbb
--- /dev/null
+++ b/tests/cxx/parser/validation/choice/test.xsd
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
+
+ <complexType name="choice">
+ <choice maxOccurs="3">
+ <element name="a" type="string"/>
+ <element name="b" type="string" maxOccurs="unbounded"/>
+ <sequence>
+ <element name="c" type="string" minOccurs="0"/>
+ <element name="d" type="string"/>
+ </sequence>
+ <any namespace="other" maxOccurs="unbounded"/>
+ </choice>
+ </complexType>
+
+ <complexType name="type">
+ <sequence>
+ <element name="choice" type="t:choice" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+
+ <element name="root" type="t:type"/>
+
+</schema>
diff --git a/tests/cxx/parser/validation/makefile b/tests/cxx/parser/validation/makefile
new file mode 100644
index 0000000..e2f798c
--- /dev/null
+++ b/tests/cxx/parser/validation/makefile
@@ -0,0 +1,26 @@
+# file : tests/cxx/parser/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)
+ifeq ($(xsde_exceptions),y)
+tests += all any attribute choice restriction sequence
+endif
+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/parser/validation/restriction/driver.cxx b/tests/cxx/parser/validation/restriction/driver.cxx
new file mode 100644
index 0000000..0088893
--- /dev/null
+++ b/tests/cxx/parser/validation/restriction/driver.cxx
@@ -0,0 +1,122 @@
+// file : tests/cxx/parser/validation/restriction/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 restriction compositor validation.
+//
+
+#include <string>
+#include <iostream>
+
+#include "test-pskel.hxx"
+
+using namespace std;
+using namespace test;
+
+struct base_a_pimpl: base_a_pskel
+{
+};
+
+struct restriction_a_pimpl: restriction_a_pskel
+{
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ restriction_a_pimpl ()
+ : restriction_a_pskel (0)
+ {
+ }
+#endif
+};
+
+struct extension_b_pimpl: extension_b_pskel
+{
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ extension_b_pimpl ()
+ : extension_b_pskel (0)
+ {
+ }
+#endif
+};
+
+struct restriction_b_pimpl: restriction_b_pskel
+{
+#ifdef XSDE_REUSE_STYLE_TIEIN
+ restriction_b_pimpl ()
+ : restriction_b_pskel (0)
+ {
+ }
+#endif
+};
+
+struct type_b_pimpl: type_b_pskel
+{
+};
+
+struct type_r_pimpl: type_r_pskel
+{
+};
+
+
+int
+main (int argc, char* argv[])
+{
+ if (argc != 2)
+ {
+ cerr << "usage: " << argv[0] << " test.xml" << endl;
+ return 1;
+ }
+
+ try
+ {
+ xml_schema::string_pimpl string_p;
+ base_a_pimpl base_a_p;
+ restriction_a_pimpl restriction_a_p;
+ extension_b_pimpl extension_b_p;
+ restriction_b_pimpl restriction_b_p;
+ type_b_pimpl type_b_p;
+ type_r_pimpl type_r_p;
+
+ base_a_p.parsers (string_p, string_p, string_p,
+ string_p, string_p, string_p);
+
+ restriction_a_p.parsers (string_p, string_p, string_p,
+ string_p, string_p, string_p);
+
+ extension_b_p.parsers (string_p, string_p, string_p,
+ string_p, string_p);
+
+ restriction_b_p.parsers (string_p, string_p, string_p,
+ string_p, string_p);
+
+ type_b_p.parsers (base_a_p, extension_b_p);
+ type_r_p.parsers (restriction_a_p, restriction_b_p);
+
+ xml_schema::document_pimpl doc_b_p (type_b_p, "test", "root");
+ xml_schema::document_pimpl doc_r_p (type_r_p, "test", "root");
+
+ type_b_p.pre ();
+ doc_b_p.parse (argv[1]);
+ type_b_p.post_type_b ();
+
+ try
+ {
+ type_r_p.pre ();
+ doc_r_p.parse (argv[1]);
+ type_r_p.post_type_r ();
+ }
+ catch (xml_schema::parser_exception const& e)
+ {
+ cout << e.line () << ":" << e.column () << " " << e << endl;
+ }
+ }
+ catch (xml_schema::parser_exception const& e)
+ {
+ cerr << e << endl;
+ return 1;
+ }
+ catch (ios_base::failure const&)
+ {
+ cerr << "io failure" << endl;
+ return 1;
+ }
+}
diff --git a/tests/cxx/parser/validation/restriction/makefile b/tests/cxx/parser/validation/restriction/makefile
new file mode 100644
index 0000000..ba9dcff
--- /dev/null
+++ b/tests/cxx/parser/validation/restriction/makefile
@@ -0,0 +1,81 @@
+# file : tests/cxx/parser/validation/restriction/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
+
+tests := 000 001 002 003 004 005
+
+obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=-pskel.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=-pskel.hxx) \
+ $(out_base)/$(xsd:.xsd=-pskel.ixx) \
+ $(out_base)/$(xsd:.xsd=-pskel.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.
+#
+test_targets := $(addprefix $(out_base)/.test-,$(tests))
+
+.PHONY: $(test)
+$(test): $(test_targets)
+
+
+$(test_targets): driver := $(driver)
+
+.PHONY: $(out_base)/.test-%
+$(out_base)/.test-%: $(driver) $(src_base)/test.xsd $(src_base)/test-%.xml $(src_base)/test-%.std
+ $(call message,test $(out_base)/$*,$(driver) $(src_base)/test-$*.xml | diff -u $(src_base)/test-$*.std -)
+
+
+# Clean.
+#
+.PHONY: $(clean)
+
+$(clean): $(driver).o.clean \
+ $(addsuffix .cxx.clean,$(obj)) \
+ $(addsuffix .cxx.clean,$(dep)) \
+ $(addprefix $(out_base)/,$(xsd:.xsd=-pskel.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/parser/xsd-cxx.make)
+
+
+# Dependencies.
+#
+$(call import,$(src_root)/xsde/makefile)
+$(call import,$(src_root)/libxsde/xsde/makefile) \ No newline at end of file
diff --git a/tests/cxx/parser/validation/restriction/test-000.std b/tests/cxx/parser/validation/restriction/test-000.std
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/cxx/parser/validation/restriction/test-000.std
diff --git a/tests/cxx/parser/validation/restriction/test-000.xml b/tests/cxx/parser/validation/restriction/test-000.xml
new file mode 100644
index 0000000..21402b4
--- /dev/null
+++ b/tests/cxx/parser/validation/restriction/test-000.xml
@@ -0,0 +1,31 @@
+<t:root xmlns:t="test"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <restriction-a z="z">
+ <a>a</a>
+ <b>b</b>
+ <c>c</c>
+ </restriction-a>
+
+ <restriction-a x="x" y="y" z="z">
+ <a>a</a>
+ <b>b</b>
+ <c>c</c>
+ </restriction-a>
+
+ <restriction-b y="y">
+ <a>a</a>
+ <b>b</b>
+ </restriction-b>
+
+ <restriction-b y="y">
+ <a>a</a>
+ <c>c</c>
+ </restriction-b>
+
+ <restriction-b x="x" y="y">
+ <a>a</a>
+ </restriction-b>
+
+</t:root>
diff --git a/tests/cxx/parser/validation/restriction/test-001.std b/tests/cxx/parser/validation/restriction/test-001.std
new file mode 100644
index 0000000..1666695
--- /dev/null
+++ b/tests/cxx/parser/validation/restriction/test-001.std
@@ -0,0 +1 @@
+7:7 expected element not encountered
diff --git a/tests/cxx/parser/validation/restriction/test-001.xml b/tests/cxx/parser/validation/restriction/test-001.xml
new file mode 100644
index 0000000..4015302
--- /dev/null
+++ b/tests/cxx/parser/validation/restriction/test-001.xml
@@ -0,0 +1,11 @@
+<t:root xmlns:t="test"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- valid base but not restriction: a element -->
+ <restriction-a z="z">
+ <b>b</b>
+ <c>c</c>
+ </restriction-a>
+
+</t:root>
diff --git a/tests/cxx/parser/validation/restriction/test-002.std b/tests/cxx/parser/validation/restriction/test-002.std
new file mode 100644
index 0000000..a261ba8
--- /dev/null
+++ b/tests/cxx/parser/validation/restriction/test-002.std
@@ -0,0 +1 @@
+10:18 expected attribute not encountered
diff --git a/tests/cxx/parser/validation/restriction/test-002.xml b/tests/cxx/parser/validation/restriction/test-002.xml
new file mode 100644
index 0000000..eb7684c
--- /dev/null
+++ b/tests/cxx/parser/validation/restriction/test-002.xml
@@ -0,0 +1,12 @@
+<t:root xmlns:t="test"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- valid base but not restriction: z attribute -->
+ <restriction-a>
+ <a>a</a>
+ <b>b</b>
+ <c>c</c>
+ </restriction-a>
+
+</t:root>
diff --git a/tests/cxx/parser/validation/restriction/test-003.std b/tests/cxx/parser/validation/restriction/test-003.std
new file mode 100644
index 0000000..c13bef2
--- /dev/null
+++ b/tests/cxx/parser/validation/restriction/test-003.std
@@ -0,0 +1 @@
+11:7 unexpected element encountered
diff --git a/tests/cxx/parser/validation/restriction/test-003.xml b/tests/cxx/parser/validation/restriction/test-003.xml
new file mode 100644
index 0000000..49f18c7
--- /dev/null
+++ b/tests/cxx/parser/validation/restriction/test-003.xml
@@ -0,0 +1,16 @@
+<t:root xmlns:t="test"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- valid base but not restriction: sequence maxOccurs="1" -->
+ <restriction-a z="z">
+ <a>a</a>
+ <b>b</b>
+ <c>c</c>
+
+ <a>a</a>
+ <b>b</b>
+ <c>c</c>
+ </restriction-a>
+
+</t:root>
diff --git a/tests/cxx/parser/validation/restriction/test-004.std b/tests/cxx/parser/validation/restriction/test-004.std
new file mode 100644
index 0000000..1666695
--- /dev/null
+++ b/tests/cxx/parser/validation/restriction/test-004.std
@@ -0,0 +1 @@
+7:7 expected element not encountered
diff --git a/tests/cxx/parser/validation/restriction/test-004.xml b/tests/cxx/parser/validation/restriction/test-004.xml
new file mode 100644
index 0000000..115cd38
--- /dev/null
+++ b/tests/cxx/parser/validation/restriction/test-004.xml
@@ -0,0 +1,10 @@
+<t:root xmlns:t="test"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- valid extension but not restriction: a element -->
+ <restriction-b y="y">
+ <b>b</b>
+ </restriction-b>
+
+</t:root>
diff --git a/tests/cxx/parser/validation/restriction/test-005.std b/tests/cxx/parser/validation/restriction/test-005.std
new file mode 100644
index 0000000..b2ee79e
--- /dev/null
+++ b/tests/cxx/parser/validation/restriction/test-005.std
@@ -0,0 +1 @@
+9:18 expected attribute not encountered
diff --git a/tests/cxx/parser/validation/restriction/test-005.xml b/tests/cxx/parser/validation/restriction/test-005.xml
new file mode 100644
index 0000000..e9ab7d9
--- /dev/null
+++ b/tests/cxx/parser/validation/restriction/test-005.xml
@@ -0,0 +1,11 @@
+<t:root xmlns:t="test"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- valid extension but not restriction: y attribute -->
+ <restriction-b>
+ <a>a</a>
+ <b>b</b>
+ </restriction-b>
+
+</t:root>
diff --git a/tests/cxx/parser/validation/restriction/test.xsd b/tests/cxx/parser/validation/restriction/test.xsd
new file mode 100644
index 0000000..158ded5
--- /dev/null
+++ b/tests/cxx/parser/validation/restriction/test.xsd
@@ -0,0 +1,82 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
+
+ <!-- simple case -->
+ <complexType name="base-a">
+ <sequence minOccurs="1" maxOccurs="2">
+ <element name="a" type="string" minOccurs="0"/>
+ <element name="b" type="string"/>
+ <element name="c" type="string"/>
+ </sequence>
+ <attribute name="x" type="string"/>
+ <attribute name="y" type="string"/>
+ <attribute name="z" type="string"/>
+ </complexType>
+
+ <complexType name="restriction-a">
+ <complexContent>
+ <restriction base="t:base-a">
+ <sequence minOccurs="1" maxOccurs="1">
+ <element name="a" type="string" minOccurs="1"/>
+ <element name="b" type="string"/>
+ <element name="c" type="string"/>
+ </sequence>
+ <!-- Can be ommited if not changed, e.g., 'x'. -->
+ <attribute name="y" type="string"/> <!-- But can also be repeated without change. -->
+ <attribute name="z" type="string" use="required"/>
+ </restriction>
+ </complexContent>
+ </complexType>
+
+ <!-- restriction of an extension -->
+ <complexType name="base-b">
+ <sequence>
+ <element name="a" type="string" minOccurs="0"/>
+ </sequence>
+ <attribute name="x" type="string"/>
+ </complexType>
+
+ <complexType name="extension-b">
+ <complexContent>
+ <extension base="t:base-b">
+ <choice>
+ <element name="b" type="string" minOccurs="0"/>
+ <element name="c" type="string"/>
+ </choice>
+ <attribute name="y" type="string"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="restriction-b">
+ <complexContent>
+ <restriction base="t:extension-b">
+ <sequence>
+ <sequence>
+ <element name="a" type="string" minOccurs="1"/>
+ </sequence>
+ <choice>
+ <element name="b" type="string" minOccurs="0"/>
+ <element name="c" type="string"/>
+ </choice>
+ </sequence>
+ <attribute name="y" type="string" use="required"/>
+ </restriction>
+ </complexContent>
+ </complexType>
+
+ <complexType name="type-b">
+ <choice maxOccurs="unbounded">
+ <element name="restriction-a" type="t:base-a"/>
+ <element name="restriction-b" type="t:extension-b"/>
+ </choice>
+ </complexType>
+
+ <complexType name="type-r">
+ <choice maxOccurs="unbounded">
+ <element name="restriction-a" type="t:restriction-a"/>
+ <element name="restriction-b" type="t:restriction-b"/>
+ </choice>
+ </complexType>
+
+</schema>
diff --git a/tests/cxx/parser/validation/sequence/driver.cxx b/tests/cxx/parser/validation/sequence/driver.cxx
new file mode 100644
index 0000000..60cef37
--- /dev/null
+++ b/tests/cxx/parser/validation/sequence/driver.cxx
@@ -0,0 +1,185 @@
+// file : tests/cxx/parser/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 the sequence compositor validation.
+//
+
+#include <string>
+#include <iostream>
+
+#include "test-pskel.hxx"
+
+using namespace std;
+using namespace test;
+using xml_schema::ro_string;
+
+struct sequence_pimpl: sequence_pskel
+{
+ virtual void
+ pre ()
+ {
+ cout << "{" << endl;
+ }
+
+#ifdef XSDE_STL
+ virtual void
+ a (string const& v)
+ {
+ cout << " a = " << v << endl;
+ }
+
+ virtual void
+ b (string const& v)
+ {
+ cout << " b = " << v << endl;
+ }
+
+ virtual void
+ c (string const& v)
+ {
+ cout << " c = " << v << endl;
+ }
+
+ virtual void
+ d (string const& v)
+ {
+ cout << " d = " << v << endl;
+ }
+
+ virtual void
+ e (string const& v)
+ {
+ cout << " e = " << v << endl;
+ }
+
+ virtual void
+ f (string const& v)
+ {
+ cout << " f = " << v << endl;
+ }
+#else
+ virtual void
+ a (char* v)
+ {
+ cout << " a = " << v << endl;
+ delete[] v;
+ }
+
+ virtual void
+ b (char* v)
+ {
+ cout << " b = " << v << endl;
+ delete[] v;
+ }
+
+ virtual void
+ c (char* v)
+ {
+ cout << " c = " << v << endl;
+ delete[] v;
+ }
+
+ virtual void
+ d (char* v)
+ {
+ cout << " d = " << v << endl;
+ delete[] v;
+ }
+
+ virtual void
+ e (char* v)
+ {
+ cout << " e = " << v << endl;
+ delete[] v;
+ }
+
+ virtual void
+ f (char* v)
+ {
+ cout << " f = " << v << endl;
+ delete[] v;
+ }
+#endif
+
+ virtual void
+#ifndef XSDE_POLYMORPHIC
+ _start_any_element (ro_string const& ns, ro_string const& name)
+#else
+ _start_any_element (ro_string const& ns, ro_string const& name, const char*)
+#endif
+ {
+ cout << " any: " << ns << "#" << name << endl
+ << " {" << endl;
+ }
+
+ virtual void
+ _any_characters (ro_string const& v)
+ {
+ cout << " chars = " << v << endl;
+ }
+
+ virtual void
+ _end_any_element (ro_string const&, ro_string const&)
+ {
+ cout << " }" << endl;
+ }
+
+ virtual void
+ post_sequence ()
+ {
+ cout << "}" << endl
+ << endl;
+ }
+};
+
+struct type_pimpl: type_pskel
+{
+};
+
+int
+main (int argc, char* argv[])
+{
+ if (argc != 2)
+ {
+ cerr << "usage: " << argv[0] << " test.xml" << endl;
+ return 1;
+ }
+
+ try
+ {
+ xml_schema::string_pimpl string_p;
+ sequence_pimpl sequence_p;
+ type_pimpl type_p;
+
+ sequence_p.parsers (string_p, string_p, string_p,
+ string_p, string_p, string_p);
+ type_p.parsers (sequence_p);
+
+ xml_schema::document_pimpl doc_p (type_p, "test", "root");
+
+ try
+ {
+ type_p.pre ();
+ doc_p.parse (argv[1]);
+ type_p.post_type ();
+ }
+ catch (xml_schema::parser_exception const& e)
+ {
+ cout << " " << e.line () << ":" << e.column () << " " << e << endl
+ << "}" << endl
+ << endl;
+ }
+ }
+ catch (xml_schema::parser_exception const& e)
+ {
+ cerr << e << endl;
+ return 1;
+ }
+ catch (ios_base::failure const&)
+ {
+ cerr << "io failure" << endl;
+ return 1;
+ }
+}
diff --git a/tests/cxx/parser/validation/sequence/makefile b/tests/cxx/parser/validation/sequence/makefile
new file mode 100644
index 0000000..f7ee5a9
--- /dev/null
+++ b/tests/cxx/parser/validation/sequence/makefile
@@ -0,0 +1,81 @@
+# file : tests/cxx/parser/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
+
+tests := 000 001 002 003 004 005 006
+
+obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=-pskel.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=-pskel.hxx) \
+ $(out_base)/$(xsd:.xsd=-pskel.ixx) \
+ $(out_base)/$(xsd:.xsd=-pskel.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.
+#
+test_targets := $(addprefix $(out_base)/.test-,$(tests))
+
+.PHONY: $(test)
+$(test): $(test_targets)
+
+
+$(test_targets): driver := $(driver)
+
+.PHONY: $(out_base)/.test-%
+$(out_base)/.test-%: $(driver) $(src_base)/test.xsd $(src_base)/test-%.xml $(src_base)/test-%.std
+ $(call message,test $(out_base)/$*,$(driver) $(src_base)/test-$*.xml | diff -u $(src_base)/test-$*.std -)
+
+
+# Clean.
+#
+.PHONY: $(clean)
+
+$(clean): $(driver).o.clean \
+ $(addsuffix .cxx.clean,$(obj)) \
+ $(addsuffix .cxx.clean,$(dep)) \
+ $(addprefix $(out_base)/,$(xsd:.xsd=-pskel.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/parser/xsd-cxx.make)
+
+
+# Dependencies.
+#
+$(call import,$(src_root)/xsde/makefile)
+$(call import,$(src_root)/libxsde/xsde/makefile) \ No newline at end of file
diff --git a/tests/cxx/parser/validation/sequence/test-000.std b/tests/cxx/parser/validation/sequence/test-000.std
new file mode 100644
index 0000000..8a44762
--- /dev/null
+++ b/tests/cxx/parser/validation/sequence/test-000.std
@@ -0,0 +1,56 @@
+{
+ c = c
+ d = d
+ any: test#any
+ {
+ chars = aaa
+ any: #a
+ {
+ chars = bbb
+ }
+ chars = ccc
+ }
+ f = f
+ e = e
+}
+
+{
+ a = a
+ b = b
+ c = c
+ d = d
+ d = d
+ d = d
+ any: other#any
+ {
+ chars = any
+ }
+ f = f
+ e = e
+ e = e
+}
+
+{
+ a = a
+ b = b
+ c = c
+ d = d
+ d = d
+ d = d
+ any: other#any
+ {
+ chars = any
+ }
+ f = f
+ e = e
+ e = e
+ c = c
+ d = d
+ any: test#any
+ {
+ chars = any
+ }
+ f = f
+ e = e
+}
+
diff --git a/tests/cxx/parser/validation/sequence/test-000.xml b/tests/cxx/parser/validation/sequence/test-000.xml
new file mode 100644
index 0000000..9bcbd7e
--- /dev/null
+++ b/tests/cxx/parser/validation/sequence/test-000.xml
@@ -0,0 +1,46 @@
+<t:root xmlns:t="test"
+ xmlns:o="other"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <sequence>
+ <c>c</c>
+ <d>d</d>
+ <t:any>aaa<a>bbb</a>ccc</t:any>
+ <f>f</f>
+ <e>e</e>
+ </sequence>
+
+ <sequence>
+ <a>a</a>
+ <b>b</b>
+ <c>c</c>
+ <d>d</d>
+ <d>d</d>
+ <d>d</d>
+ <o:any>any</o:any>
+ <f>f</f>
+ <e>e</e>
+ <e>e</e>
+ </sequence>
+
+ <sequence>
+ <a>a</a>
+ <b>b</b>
+ <c>c</c>
+ <d>d</d>
+ <d>d</d>
+ <d>d</d>
+ <o:any>any</o:any>
+ <f>f</f>
+ <e>e</e>
+ <e>e</e>
+
+ <c>c</c>
+ <d>d</d>
+ <t:any>any</t:any>
+ <f>f</f>
+ <e>e</e>
+ </sequence>
+
+</t:root>
diff --git a/tests/cxx/parser/validation/sequence/test-001.std b/tests/cxx/parser/validation/sequence/test-001.std
new file mode 100644
index 0000000..733078a
--- /dev/null
+++ b/tests/cxx/parser/validation/sequence/test-001.std
@@ -0,0 +1,4 @@
+{
+ 8:13 expected element not encountered
+}
+
diff --git a/tests/cxx/parser/validation/sequence/test-001.xml b/tests/cxx/parser/validation/sequence/test-001.xml
new file mode 100644
index 0000000..67d33ce
--- /dev/null
+++ b/tests/cxx/parser/validation/sequence/test-001.xml
@@ -0,0 +1,10 @@
+<t:root xmlns:t="test"
+ xmlns:o="other"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- fail minOccurs="1" -->
+ <sequence>
+ </sequence>
+
+</t:root>
diff --git a/tests/cxx/parser/validation/sequence/test-002.std b/tests/cxx/parser/validation/sequence/test-002.std
new file mode 100644
index 0000000..d58d744
--- /dev/null
+++ b/tests/cxx/parser/validation/sequence/test-002.std
@@ -0,0 +1,20 @@
+{
+ c = c
+ d = d
+ any: test#any
+ {
+ chars = any
+ }
+ f = f
+ e = e
+ c = c
+ d = d
+ any: test#any
+ {
+ chars = any
+ }
+ f = f
+ e = e
+ 20:7 unexpected element encountered
+}
+
diff --git a/tests/cxx/parser/validation/sequence/test-002.xml b/tests/cxx/parser/validation/sequence/test-002.xml
new file mode 100644
index 0000000..be25fcf
--- /dev/null
+++ b/tests/cxx/parser/validation/sequence/test-002.xml
@@ -0,0 +1,27 @@
+<t:root xmlns:t="test"
+ xmlns:o="other"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- fail maxOccurs="2" -->
+ <sequence>
+ <c>c</c>
+ <d>d</d>
+ <t:any>any</t:any>
+ <f>f</f>
+ <e>e</e>
+
+ <c>c</c>
+ <d>d</d>
+ <t:any>any</t:any>
+ <f>f</f>
+ <e>e</e>
+
+ <c>c</c>
+ <d>d</d>
+ <t:any>any</t:any>
+ <f>f</f>
+ <e>e</e>
+ </sequence>
+
+</t:root>
diff --git a/tests/cxx/parser/validation/sequence/test-003.std b/tests/cxx/parser/validation/sequence/test-003.std
new file mode 100644
index 0000000..db09f17
--- /dev/null
+++ b/tests/cxx/parser/validation/sequence/test-003.std
@@ -0,0 +1,5 @@
+{
+ a = a
+ 9:7 expected element not encountered
+}
+
diff --git a/tests/cxx/parser/validation/sequence/test-003.xml b/tests/cxx/parser/validation/sequence/test-003.xml
new file mode 100644
index 0000000..af7d21d
--- /dev/null
+++ b/tests/cxx/parser/validation/sequence/test-003.xml
@@ -0,0 +1,17 @@
+<t:root xmlns:t="test"
+ xmlns:o="other"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- fail a maxOccurs="1" -->
+ <sequence>
+ <a>a</a>
+ <a>a</a>
+ <c>c</c>
+ <d>d</d>
+ <t:any>any</t:any>
+ <f>f</f>
+ <e>e</e>
+ </sequence>
+
+</t:root>
diff --git a/tests/cxx/parser/validation/sequence/test-004.std b/tests/cxx/parser/validation/sequence/test-004.std
new file mode 100644
index 0000000..400577a
--- /dev/null
+++ b/tests/cxx/parser/validation/sequence/test-004.std
@@ -0,0 +1,4 @@
+{
+ 8:7 expected element not encountered
+}
+
diff --git a/tests/cxx/parser/validation/sequence/test-004.xml b/tests/cxx/parser/validation/sequence/test-004.xml
new file mode 100644
index 0000000..a58b6d4
--- /dev/null
+++ b/tests/cxx/parser/validation/sequence/test-004.xml
@@ -0,0 +1,14 @@
+<t:root xmlns:t="test"
+ xmlns:o="other"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- fail c minOccurs="1" -->
+ <sequence>
+ <d>d</d>
+ <t:any>any</t:any>
+ <f>f</f>
+ <e>e</e>
+ </sequence>
+
+</t:root>
diff --git a/tests/cxx/parser/validation/sequence/test-005.std b/tests/cxx/parser/validation/sequence/test-005.std
new file mode 100644
index 0000000..9603e0f
--- /dev/null
+++ b/tests/cxx/parser/validation/sequence/test-005.std
@@ -0,0 +1,6 @@
+{
+ c = c
+ d = d
+ 10:12 expected element not encountered
+}
+
diff --git a/tests/cxx/parser/validation/sequence/test-005.xml b/tests/cxx/parser/validation/sequence/test-005.xml
new file mode 100644
index 0000000..e3dd03d
--- /dev/null
+++ b/tests/cxx/parser/validation/sequence/test-005.xml
@@ -0,0 +1,15 @@
+<t:root xmlns:t="test"
+ xmlns:o1="other1"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- fail any namespace="##targetNamespace other" -->
+ <sequence>
+ <c>c</c>
+ <d>d</d>
+ <o1:any>any</o1:any>
+ <f>f</f>
+ <e>e</e>
+ </sequence>
+
+</t:root>
diff --git a/tests/cxx/parser/validation/sequence/test-006.std b/tests/cxx/parser/validation/sequence/test-006.std
new file mode 100644
index 0000000..d39b1b4
--- /dev/null
+++ b/tests/cxx/parser/validation/sequence/test-006.std
@@ -0,0 +1,13 @@
+{
+ c = c
+ d = d
+ any: test#any
+ {
+ chars = any
+ }
+ f = f
+ e = e
+ e = e
+ 14:7 unexpected element encountered
+}
+
diff --git a/tests/cxx/parser/validation/sequence/test-006.xml b/tests/cxx/parser/validation/sequence/test-006.xml
new file mode 100644
index 0000000..e1ecd69
--- /dev/null
+++ b/tests/cxx/parser/validation/sequence/test-006.xml
@@ -0,0 +1,17 @@
+<t:root xmlns:t="test"
+ xmlns:o="other"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- fail e maxOccurs="2" -->
+ <sequence>
+ <c>c</c>
+ <d>d</d>
+ <t:any>any</t:any>
+ <f>f</f>
+ <e>e</e>
+ <e>e</e>
+ <e>e</e>
+ </sequence>
+
+</t:root>
diff --git a/tests/cxx/parser/validation/sequence/test.xsd b/tests/cxx/parser/validation/sequence/test.xsd
new file mode 100644
index 0000000..8753f54
--- /dev/null
+++ b/tests/cxx/parser/validation/sequence/test.xsd
@@ -0,0 +1,28 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
+
+ <complexType name="sequence">
+ <sequence minOccurs="1" maxOccurs="2">
+ <element name="a" type="string" minOccurs="0"/>
+ <sequence>
+ <element name="b" type="string" minOccurs="0"/>
+ <element name="c" type="string"/>
+ </sequence>
+ <element name="d" type="string" maxOccurs="unbounded"/>
+ <sequence>
+ <any namespace="##targetNamespace other"/>
+ <element name="f" type="string"/>
+ </sequence>
+ <element name="e" type="string" maxOccurs="2"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="type">
+ <sequence>
+ <element name="sequence" type="t:sequence" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+
+ <element name="root" type="t:type"/>
+
+</schema>