From 5e527213a2430bb3018e5eebd909aef294edf9b5 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 18 Dec 2020 18:48:46 +0300 Subject: Switch to build2 --- xsd-tests/cxx/parser/validation/all/buildfile | 22 + xsd-tests/cxx/parser/validation/all/driver.cxx | 98 ++ xsd-tests/cxx/parser/validation/all/test.xsd | 20 + xsd-tests/cxx/parser/validation/all/testscript | 190 +++ xsd-tests/cxx/parser/validation/any/buildfile | 24 + xsd-tests/cxx/parser/validation/any/driver.cxx | 121 ++ xsd-tests/cxx/parser/validation/any/output | 29 + xsd-tests/cxx/parser/validation/any/test.xml | 21 + xsd-tests/cxx/parser/validation/any/test.xsd | 20 + .../cxx/parser/validation/attribute/buildfile | 24 + .../cxx/parser/validation/attribute/driver.cxx | 197 +++ xsd-tests/cxx/parser/validation/attribute/output | 24 + xsd-tests/cxx/parser/validation/attribute/test.xml | 10 + xsd-tests/cxx/parser/validation/attribute/test.xsd | 71 + .../parser/validation/built-in/any-type/buildfile | 24 + .../parser/validation/built-in/any-type/driver.cxx | 154 ++ .../cxx/parser/validation/built-in/any-type/output | 99 ++ .../parser/validation/built-in/any-type/test.xml | 41 + .../parser/validation/built-in/any-type/test.xsd | 31 + .../parser/validation/built-in/binary/buildfile | 10 + .../parser/validation/built-in/binary/driver.cxx | 153 ++ .../parser/validation/built-in/boolean/buildfile | 10 + .../parser/validation/built-in/boolean/driver.cxx | 145 ++ .../cxx/parser/validation/built-in/byte/buildfile | 10 + .../cxx/parser/validation/built-in/byte/driver.cxx | 256 ++++ .../parser/validation/built-in/date-time/buildfile | 10 + .../validation/built-in/date-time/driver.cxx | 1533 ++++++++++++++++++++ .../cxx/parser/validation/built-in/float/buildfile | 10 + .../parser/validation/built-in/float/driver.cxx | 285 ++++ .../cxx/parser/validation/built-in/int/buildfile | 10 + .../cxx/parser/validation/built-in/int/driver.cxx | 116 ++ .../parser/validation/built-in/integer/buildfile | 10 + .../parser/validation/built-in/integer/driver.cxx | 303 ++++ .../cxx/parser/validation/built-in/long/buildfile | 10 + .../cxx/parser/validation/built-in/long/driver.cxx | 116 ++ .../cxx/parser/validation/built-in/qname/buildfile | 10 + .../parser/validation/built-in/qname/driver.cxx | 105 ++ .../cxx/parser/validation/built-in/short/buildfile | 10 + .../parser/validation/built-in/short/driver.cxx | 116 ++ .../parser/validation/built-in/string/buildfile | 10 + .../parser/validation/built-in/string/driver.cxx | 512 +++++++ .../cxx/parser/validation/built-in/uri/buildfile | 10 + .../cxx/parser/validation/built-in/uri/driver.cxx | 53 + xsd-tests/cxx/parser/validation/choice/buildfile | 22 + xsd-tests/cxx/parser/validation/choice/driver.cxx | 126 ++ xsd-tests/cxx/parser/validation/choice/test.xsd | 24 + xsd-tests/cxx/parser/validation/choice/testscript | 179 +++ .../cxx/parser/validation/restriction/buildfile | 22 + .../cxx/parser/validation/restriction/driver.cxx | 107 ++ .../cxx/parser/validation/restriction/test.xsd | 82 ++ .../cxx/parser/validation/restriction/testscript | 159 ++ xsd-tests/cxx/parser/validation/sequence/buildfile | 22 + .../cxx/parser/validation/sequence/driver.cxx | 139 ++ xsd-tests/cxx/parser/validation/sequence/test.xsd | 28 + .../cxx/parser/validation/sequence/testscript | 328 +++++ 55 files changed, 6271 insertions(+) create mode 100644 xsd-tests/cxx/parser/validation/all/buildfile create mode 100644 xsd-tests/cxx/parser/validation/all/driver.cxx create mode 100644 xsd-tests/cxx/parser/validation/all/test.xsd create mode 100644 xsd-tests/cxx/parser/validation/all/testscript create mode 100644 xsd-tests/cxx/parser/validation/any/buildfile create mode 100644 xsd-tests/cxx/parser/validation/any/driver.cxx create mode 100644 xsd-tests/cxx/parser/validation/any/output create mode 100644 xsd-tests/cxx/parser/validation/any/test.xml create mode 100644 xsd-tests/cxx/parser/validation/any/test.xsd create mode 100644 xsd-tests/cxx/parser/validation/attribute/buildfile create mode 100644 xsd-tests/cxx/parser/validation/attribute/driver.cxx create mode 100644 xsd-tests/cxx/parser/validation/attribute/output create mode 100644 xsd-tests/cxx/parser/validation/attribute/test.xml create mode 100644 xsd-tests/cxx/parser/validation/attribute/test.xsd create mode 100644 xsd-tests/cxx/parser/validation/built-in/any-type/buildfile create mode 100644 xsd-tests/cxx/parser/validation/built-in/any-type/driver.cxx create mode 100644 xsd-tests/cxx/parser/validation/built-in/any-type/output create mode 100644 xsd-tests/cxx/parser/validation/built-in/any-type/test.xml create mode 100644 xsd-tests/cxx/parser/validation/built-in/any-type/test.xsd create mode 100644 xsd-tests/cxx/parser/validation/built-in/binary/buildfile create mode 100644 xsd-tests/cxx/parser/validation/built-in/binary/driver.cxx create mode 100644 xsd-tests/cxx/parser/validation/built-in/boolean/buildfile create mode 100644 xsd-tests/cxx/parser/validation/built-in/boolean/driver.cxx create mode 100644 xsd-tests/cxx/parser/validation/built-in/byte/buildfile create mode 100644 xsd-tests/cxx/parser/validation/built-in/byte/driver.cxx create mode 100644 xsd-tests/cxx/parser/validation/built-in/date-time/buildfile create mode 100644 xsd-tests/cxx/parser/validation/built-in/date-time/driver.cxx create mode 100644 xsd-tests/cxx/parser/validation/built-in/float/buildfile create mode 100644 xsd-tests/cxx/parser/validation/built-in/float/driver.cxx create mode 100644 xsd-tests/cxx/parser/validation/built-in/int/buildfile create mode 100644 xsd-tests/cxx/parser/validation/built-in/int/driver.cxx create mode 100644 xsd-tests/cxx/parser/validation/built-in/integer/buildfile create mode 100644 xsd-tests/cxx/parser/validation/built-in/integer/driver.cxx create mode 100644 xsd-tests/cxx/parser/validation/built-in/long/buildfile create mode 100644 xsd-tests/cxx/parser/validation/built-in/long/driver.cxx create mode 100644 xsd-tests/cxx/parser/validation/built-in/qname/buildfile create mode 100644 xsd-tests/cxx/parser/validation/built-in/qname/driver.cxx create mode 100644 xsd-tests/cxx/parser/validation/built-in/short/buildfile create mode 100644 xsd-tests/cxx/parser/validation/built-in/short/driver.cxx create mode 100644 xsd-tests/cxx/parser/validation/built-in/string/buildfile create mode 100644 xsd-tests/cxx/parser/validation/built-in/string/driver.cxx create mode 100644 xsd-tests/cxx/parser/validation/built-in/uri/buildfile create mode 100644 xsd-tests/cxx/parser/validation/built-in/uri/driver.cxx create mode 100644 xsd-tests/cxx/parser/validation/choice/buildfile create mode 100644 xsd-tests/cxx/parser/validation/choice/driver.cxx create mode 100644 xsd-tests/cxx/parser/validation/choice/test.xsd create mode 100644 xsd-tests/cxx/parser/validation/choice/testscript create mode 100644 xsd-tests/cxx/parser/validation/restriction/buildfile create mode 100644 xsd-tests/cxx/parser/validation/restriction/driver.cxx create mode 100644 xsd-tests/cxx/parser/validation/restriction/test.xsd create mode 100644 xsd-tests/cxx/parser/validation/restriction/testscript create mode 100644 xsd-tests/cxx/parser/validation/sequence/buildfile create mode 100644 xsd-tests/cxx/parser/validation/sequence/driver.cxx create mode 100644 xsd-tests/cxx/parser/validation/sequence/test.xsd create mode 100644 xsd-tests/cxx/parser/validation/sequence/testscript (limited to 'xsd-tests/cxx/parser/validation') diff --git a/xsd-tests/cxx/parser/validation/all/buildfile b/xsd-tests/cxx/parser/validation/all/buildfile new file mode 100644 index 0000000..555843e --- /dev/null +++ b/xsd-tests/cxx/parser/validation/all/buildfile @@ -0,0 +1,22 @@ +# file : cxx/parser/validation/all/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs \ + testscript + +<{hxx ixx cxx}{test-pskel}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-parser --std c++11 \ + --generate-inline \ + --skel-file-suffix -pskel \ + --output-dir $out_base \ + --generate-validation \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/parser/validation/all/driver.cxx b/xsd-tests/cxx/parser/validation/all/driver.cxx new file mode 100644 index 0000000..a8cbcca --- /dev/null +++ b/xsd-tests/cxx/parser/validation/all/driver.cxx @@ -0,0 +1,98 @@ +// file : cxx/parser/validation/all/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the all compositor validation. +// + +#include +#include +#include + +#include "test-pskel.hxx" + +using namespace std; +using namespace test; + +struct all_pimpl: all_pskel +{ + virtual void + pre () + { + cout << "{" << endl; + } + + 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 + 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 doc_p (type_p, "test", "root"); + + try + { + ifstream ifs (argv[1]); + type_p.pre (); + doc_p.parse (ifs, argv[1], "", xml_schema::flags::dont_validate); + type_p.post_type (); + } + catch (xml_schema::exception const& e) + { + cout << " " << e << endl + << "}" << endl + << endl; + } + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + catch (ios_base::failure const&) + { + cerr << "io failure" << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/parser/validation/all/test.xsd b/xsd-tests/cxx/parser/validation/all/test.xsd new file mode 100644 index 0000000..1f670e3 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/all/test.xsd @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/parser/validation/all/testscript b/xsd-tests/cxx/parser/validation/all/testscript new file mode 100644 index 0000000..e93e59c --- /dev/null +++ b/xsd-tests/cxx/parser/validation/all/testscript @@ -0,0 +1,190 @@ +# file : cxx/parser/validation/all/testscript +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +test.arguments += test.xml + +: all-combinations +: +{ + cat <=test.xml; + + + + + a + b + c + + + + a + c + b + + + + b + a + c + + + + b + c + a + + + + c + a + b + + + + c + b + a + + + + + a + b + + + + a + b + + + EOI + + $* >>EOO + { + 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 + } + + EOO +} + +: required-not-present +: +{ + cat <=test.xml; + + + + + a + c + + + + EOI + + $* >>EOO + { + a = a + c = c + :9:9 error: expected element 'b' + } + + EOO +} + +: absent +: +{ + cat <=test.xml; + + + + + + + + EOI + + $* >>EOO + { + :7:9 error: expected element 'a' + } + + EOO +} + +: unexpected +: +{ + cat <=test.xml; + + + + + a + b + a + + + + EOI + + $* >>EOO + { + a = a + b = b + :9:7 error: unexpected element 'a' + } + + EOO +} diff --git a/xsd-tests/cxx/parser/validation/any/buildfile b/xsd-tests/cxx/parser/validation/any/buildfile new file mode 100644 index 0000000..57135f4 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/any/buildfile @@ -0,0 +1,24 @@ +# file : cxx/parser/validation/any/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs + +exe{driver}: xml{test}: test.input = true +exe{driver}: file{output}: test.stdout = true + +<{hxx ixx cxx}{test-pskel}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-parser --std c++11 \ + --generate-inline \ + --skel-file-suffix -pskel \ + --output-dir $out_base \ + --generate-validation \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/parser/validation/any/driver.cxx b/xsd-tests/cxx/parser/validation/any/driver.cxx new file mode 100644 index 0000000..1eceda6 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/any/driver.cxx @@ -0,0 +1,121 @@ +// file : cxx/parser/validation/any/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the any particle validation. +// + +#include +#include +#include + +#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; + } + + virtual void + a (string const& v) + { + cout << " a = " << v << endl; + } + + virtual void + x (string const& v) + { + cout << " x = " << v << endl; + } + + virtual void + _start_any_element (ro_string const&, + ro_string const& n, + ro_string const*) + { + 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 doc_p (type_p, "test", "root"); + + try + { + ifstream ifs (argv[1]); + type_p.pre (); + doc_p.parse (ifs, argv[1], "", xml_schema::flags::dont_validate); + type_p.post_type (); + } + catch (xml_schema::exception const& e) + { + cout << " " << e << endl + << "}" << endl + << endl; + } + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + catch (ios_base::failure const&) + { + cerr << "io failure" << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/parser/validation/any/output b/xsd-tests/cxx/parser/validation/any/output new file mode 100644 index 0000000..a1cc6e3 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/any/output @@ -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/xsd-tests/cxx/parser/validation/any/test.xml b/xsd-tests/cxx/parser/validation/any/test.xml new file mode 100644 index 0000000..f1a0c83 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/any/test.xml @@ -0,0 +1,21 @@ + + + + + + + + + + aaabbbccc + + + + a + aaabbbccc + + + diff --git a/xsd-tests/cxx/parser/validation/any/test.xsd b/xsd-tests/cxx/parser/validation/any/test.xsd new file mode 100644 index 0000000..c05aeb5 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/any/test.xsd @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/parser/validation/attribute/buildfile b/xsd-tests/cxx/parser/validation/attribute/buildfile new file mode 100644 index 0000000..d486193 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/attribute/buildfile @@ -0,0 +1,24 @@ +# file : cxx/parser/validation/attribute/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs + +exe{driver}: xml{test}: test.input = true +exe{driver}: file{output}: test.stdout = true + +<{hxx ixx cxx}{test-pskel}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-parser --std c++11 \ + --generate-inline \ + --skel-file-suffix -pskel \ + --output-dir $out_base \ + --generate-validation \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/parser/validation/attribute/driver.cxx b/xsd-tests/cxx/parser/validation/attribute/driver.cxx new file mode 100644 index 0000000..4710564 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/attribute/driver.cxx @@ -0,0 +1,197 @@ +// file : cxx/parser/validation/attribute/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test attribute and attribute wildcard (anyAttribute) validation. +// + +#include +#include +#include + +#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; + } + + virtual void + a (string const& v) + { + cout << " a = " << v << endl; + } + + virtual void + b (string const& v) + { + cout << " b = " << v << endl; + } + + 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 +{ + virtual void + pre () + { + cout << "pass-b" << endl + << "{" << endl; + } + + virtual void + a (string const& v) + { + cout << " a = " << v << endl; + } + + virtual void + b (string const& v) + { + cout << " b = " << v << endl; + } + + 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 +{ + virtual void + pre () + { + cout << "pass-c" << endl + << "{" << endl; + } + + virtual void + a (string const& v) + { + cout << " a = " << v << endl; + } + + virtual void + b (string const& v) + { + cout << " b = " << v << endl; + } + + virtual void + post_pass_c () + { + cout << "}" << endl + << endl; + } +}; + +struct fail_pimpl: fail_pskel +{ + virtual void + pre () + { + cout << "fail" << endl + << "{" << endl; + } + + virtual void + a (string const& v) + { + cout << " a = " << v << endl; + } + + 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 doc_p (type_p, "test", "root"); + + try + { + ifstream ifs (argv[1]); + type_p.pre (); + doc_p.parse (ifs, argv[1], "", xml_schema::flags::dont_validate); + type_p.post_type (); + } + catch (xml_schema::exception const& e) + { + cout << " " << e << endl + << "}" << endl + << endl; + } + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + catch (ios_base::failure const&) + { + cerr << "io failure" << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/parser/validation/attribute/output b/xsd-tests/cxx/parser/validation/attribute/output new file mode 100644 index 0000000..847b054 --- /dev/null +++ b/xsd-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:10 error: expected attribute 'a' +} + diff --git a/xsd-tests/cxx/parser/validation/attribute/test.xml b/xsd-tests/cxx/parser/validation/attribute/test.xml new file mode 100644 index 0000000..b994d1a --- /dev/null +++ b/xsd-tests/cxx/parser/validation/attribute/test.xml @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/xsd-tests/cxx/parser/validation/attribute/test.xsd b/xsd-tests/cxx/parser/validation/attribute/test.xsd new file mode 100644 index 0000000..833eb8e --- /dev/null +++ b/xsd-tests/cxx/parser/validation/attribute/test.xsd @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/parser/validation/built-in/any-type/buildfile b/xsd-tests/cxx/parser/validation/built-in/any-type/buildfile new file mode 100644 index 0000000..a6f366b --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/any-type/buildfile @@ -0,0 +1,24 @@ +# file : cxx/parser/validation/built-in/any-type/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs + +exe{driver}: xml{test}: test.input = true +exe{driver}: file{output}: test.stdout = true + +<{hxx ixx cxx}{test-pskel}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-parser --std c++11 \ + --generate-inline \ + --skel-file-suffix -pskel \ + --output-dir $out_base \ + --generate-validation \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/parser/validation/built-in/any-type/driver.cxx b/xsd-tests/cxx/parser/validation/built-in/any-type/driver.cxx new file mode 100644 index 0000000..cbeb864 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/any-type/driver.cxx @@ -0,0 +1,154 @@ +// file : cxx/parser/validation/built-in/any-type/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the anyType and anySimpleType validation. +// + +#include +#include +#include + +#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 + _start_any_element (ro_string const&, + ro_string const& n, + ro_string const*) + { + 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: virtual any_extension_pskel, + any_type_pimpl + +{ + virtual void + x (const string& v) + { + cout << " x = " << v << endl; + } +}; + +struct any_simple_extension_pimpl: virtual any_simple_extension_pskel, + any_simple_type_pimpl +{ + virtual void + x (const string& v) + { + cout << " x = " << v << 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_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_type_p, + any_extension_p, + any_simple_extension_p, + any_simple_type_p); + + xml_schema::document doc_p (type_p, "test", "root"); + + ifstream ifs (argv[1]); + type_p.pre (); + doc_p.parse (ifs, argv[1], "", xml_schema::flags::dont_validate); + type_p.post_type (); + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + catch (ios_base::failure const&) + { + cerr << "io failure" << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/parser/validation/built-in/any-type/output b/xsd-tests/cxx/parser/validation/built-in/any-type/output new file mode 100644 index 0000000..84d7b3a --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/any-type/output @@ -0,0 +1,99 @@ +{ + any text: '123abc' +} + +{ + any text: ' + ' + start any element 'any' + end any element 'any' + 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 attribute x = 'x' + any text: ' + ' + start any element 'a' + any text: 'a' + end any element 'a' + 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: ' + ' + start any element 'any' + end any element 'any' + 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: ' + ' +} + +{ + x = x + any text: ' + ' + start any element 'a' + any text: 'a' + end any element 'a' + 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: ' + ' +} + +{ + x = x + any text: 'abc123' +} + diff --git a/xsd-tests/cxx/parser/validation/built-in/any-type/test.xml b/xsd-tests/cxx/parser/validation/built-in/any-type/test.xml new file mode 100644 index 0000000..7875b7e --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/any-type/test.xml @@ -0,0 +1,41 @@ + + + + + + + + + + aaabbbccc + + + + a + aaabbbccc + + + + + + + + + + aaabbbccc + + + + a + aaabbbccc + + + + + abc123 + + diff --git a/xsd-tests/cxx/parser/validation/built-in/any-type/test.xsd b/xsd-tests/cxx/parser/validation/built-in/any-type/test.xsd new file mode 100644 index 0000000..86a4e13 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/any-type/test.xsd @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/parser/validation/built-in/binary/buildfile b/xsd-tests/cxx/parser/validation/built-in/binary/buildfile new file mode 100644 index 0000000..fd1594f --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/binary/buildfile @@ -0,0 +1,10 @@ +# file : cxx/parser/validation/built-in/binary/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} + +exe{driver}: {hxx cxx}{*} $libs + +# Define XSD_CXX11 since we include libxsd headers directly. +# +cxx.poptions += -DXSD_CXX11 diff --git a/xsd-tests/cxx/parser/validation/built-in/binary/driver.cxx b/xsd-tests/cxx/parser/validation/built-in/binary/driver.cxx new file mode 100644 index 0000000..3fe20ec --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/binary/driver.cxx @@ -0,0 +1,153 @@ +// file : cxx/parser/validation/built-in/binary/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the built-in base64Binary and hexBinary types validation. +// +#include + +#include +#include + +using namespace xsd::cxx::parser::validating; + +template +bool +test_post_fail (T& p) +{ + try + { + p._post (); + } + catch (invalid_value const&) + { + return true; + } + + return false; +} + +int +main () +{ + typedef xsd::cxx::parser::buffer buffer; + + // Good. + // + + // hexBinary + // + { + hex_binary_pimpl p; + p.pre (); + p._pre (); + p._characters (" \t\n "); + p._characters (" "); + p._post (); + assert (*p.post_hex_binary () == buffer ()); + } + + { + hex_binary_pimpl p; + p.pre (); + p._pre (); + p._characters (" \t\n313"); + p._characters ("23334356162636a6b "); + p._post (); + assert (*p.post_hex_binary () == buffer ("12345abcjk", 10)); + } + + // base64Binary + // + { + base64_binary_pimpl p; + p.pre (); + p._pre (); + p._characters (" \t\n "); + p._characters ("MTIzND "); + p._characters ("VhYmNqaw = = "); + p._post (); + assert (*p.post_base64_binary () == buffer ("12345abcjk", 10)); + } + + { + base64_binary_pimpl p; + p.pre (); + p._pre (); + p._characters ("YQ=="); + p._post (); + assert (*p.post_base64_binary () == buffer ("a", 1)); + } + + { + base64_binary_pimpl p; + p.pre (); + p._pre (); + p._characters ("YWI="); + p._post (); + assert (*p.post_base64_binary () == buffer ("ab", 2)); + } + + { + base64_binary_pimpl p; + p.pre (); + p._pre (); + p._characters ("YWJj"); + p._post (); + assert (*p.post_base64_binary () == buffer ("abc", 3)); + } + + // Bad + // + + // hexBinary + // + { + hex_binary_pimpl p; + p.pre (); + p._pre (); + p._characters ("313"); + assert (test_post_fail (p)); + } + + { + hex_binary_pimpl p; + p.pre (); + p._pre (); + p._characters ("313233343X6162636a6b"); + assert (test_post_fail (p)); + } + + // base64Binary + // + { + base64_binary_pimpl p; + p.pre (); + p._pre (); + // p._characters (""); + assert (test_post_fail (p)); + } + + { + base64_binary_pimpl p; + p.pre (); + p._pre (); + p._characters ("YQ"); + assert (test_post_fail (p)); + } + + { + base64_binary_pimpl p; + p.pre (); + p._pre (); + p._characters ("=="); + assert (test_post_fail (p)); + } + + { + base64_binary_pimpl p; + p.pre (); + p._pre (); + p._characters ("MTIzNDVhYmNqaw=A"); + assert (test_post_fail (p)); + } +} diff --git a/xsd-tests/cxx/parser/validation/built-in/boolean/buildfile b/xsd-tests/cxx/parser/validation/built-in/boolean/buildfile new file mode 100644 index 0000000..259614e --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/boolean/buildfile @@ -0,0 +1,10 @@ +# file : cxx/parser/validation/built-in/boolean/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} + +exe{driver}: {hxx cxx}{*} $libs + +# Define XSD_CXX11 since we include libxsd headers directly. +# +cxx.poptions += -DXSD_CXX11 diff --git a/xsd-tests/cxx/parser/validation/built-in/boolean/driver.cxx b/xsd-tests/cxx/parser/validation/built-in/boolean/driver.cxx new file mode 100644 index 0000000..f1499cd --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/boolean/driver.cxx @@ -0,0 +1,145 @@ +// file : cxx/parser/validation/built-in/boolean/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the built-in boolean type validation. +// +#include + +#include +#include + +using namespace xsd::cxx::parser::validating; + +bool +test_post_fail (boolean_pimpl& p) +{ + try + { + p._post (); + } + catch (invalid_value const&) + { + return true; + } + + return false; +} + +int +main () +{ + // Good. + // + { + boolean_pimpl p; + p.pre (); + p._pre (); + p._characters ("true"); + p._post (); + assert (p.post_boolean ()); + } + + { + boolean_pimpl p; + p.pre (); + p._pre (); + p._characters ("1"); + p._post (); + assert (p.post_boolean ()); + } + + { + boolean_pimpl p; + p.pre (); + p._pre (); + p._characters ("false"); + p._post (); + assert (!p.post_boolean ()); + } + + { + boolean_pimpl p; + p.pre (); + p._pre (); + p._characters ("0"); + p._post (); + assert (!p.post_boolean ()); + } + + + { + boolean_pimpl p; + p.pre (); + p._pre (); + p._characters (" true "); + p._post (); + assert (p.post_boolean ()); + } + + { + boolean_pimpl p; + p.pre (); + p._pre (); + p._characters (" "); + p._characters (" \n "); + p._characters (" fa"); + p._characters ("l"); + p._characters ("se "); + p._characters (" \n "); + p._characters (" "); + p._post (); + assert (!p.post_boolean ()); + } + + // Bad + // + { + boolean_pimpl p; + p.pre (); + p._pre (); + //p._characters (""); + assert (test_post_fail (p)); + } + + { + boolean_pimpl p; + p.pre (); + p._pre (); + p._characters (""); + assert (test_post_fail (p)); + } + + { + boolean_pimpl p; + p.pre (); + p._pre (); + p._characters (" "); + assert (test_post_fail (p)); + } + + { + boolean_pimpl p; + p.pre (); + p._pre (); + p._characters (" "); + assert (test_post_fail (p)); + } + + { + boolean_pimpl p; + p.pre (); + p._pre (); + p._characters ("fal"); + p._characters ("s "); + p._characters ("e"); + assert (test_post_fail (p)); + } + + { + boolean_pimpl p; + p.pre (); + p._pre (); + p._characters ("01"); + assert (test_post_fail (p)); + } +} diff --git a/xsd-tests/cxx/parser/validation/built-in/byte/buildfile b/xsd-tests/cxx/parser/validation/built-in/byte/buildfile new file mode 100644 index 0000000..87de911 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/byte/buildfile @@ -0,0 +1,10 @@ +# file : cxx/parser/validation/built-in/byte/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} + +exe{driver}: {hxx cxx}{*} $libs + +# Define XSD_CXX11 since we include libxsd headers directly. +# +cxx.poptions += -DXSD_CXX11 diff --git a/xsd-tests/cxx/parser/validation/built-in/byte/driver.cxx b/xsd-tests/cxx/parser/validation/built-in/byte/driver.cxx new file mode 100644 index 0000000..b533cfd --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/byte/driver.cxx @@ -0,0 +1,256 @@ +// file : cxx/parser/validation/built-in/byte/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the built-in byte and unsigned byte types validation. +// +#include + +#include +#include + +using namespace xsd::cxx::parser::validating; + +template +bool +test_post_fail (T& p) +{ + try + { + p._post (); + } + catch (invalid_value const&) + { + return true; + } + + return false; +} + +int +main () +{ + // Good. + // + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("123"); + p._post (); + assert (p.post_byte () == 123); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("\t +123 \n "); + p._post (); + assert (p.post_byte () == 123); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("-123"); + p._post (); + assert (p.post_byte () == -123); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("+123"); + p._post (); + assert (p.post_byte () == 123); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("0000000000000000123"); + p._post (); + assert (p.post_byte () == 123); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("+0000000000000000123"); + p._post (); + assert (p.post_byte () == 123); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("-0000000000000000123"); + p._post (); + assert (p.post_byte () == -123); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("\t \n"); + p._characters (" -"); + p._characters ("00000"); + p._characters ("001"); + p._characters ("23 \n\t"); + p._post (); + assert (p.post_byte () == -123); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("-128"); + p._post (); + assert (p.post_byte () == -128); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("127"); + p._post (); + assert (p.post_byte () == 127); + } + + { + unsigned_byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("+123"); + p._post (); + assert (p.post_unsigned_byte () == 123); + } + + { + unsigned_byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("0"); + p._post (); + assert (p.post_unsigned_byte () == 0); + } + + { + unsigned_byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("255"); + p._post (); + assert (p.post_unsigned_byte () == 255); + } + + // Bad + // + { + byte_pimpl p; + p.pre (); + p._pre (); + // p._characters (""); + assert (test_post_fail (p)); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters (""); + assert (test_post_fail (p)); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters (" \n \t "); + assert (test_post_fail (p)); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("+"); + assert (test_post_fail (p)); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("-"); + assert (test_post_fail (p)); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("++01"); + assert (test_post_fail (p)); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("--01"); + assert (test_post_fail (p)); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("-01"); + p._characters (" "); + p._characters ("23 "); + assert (test_post_fail (p)); + } + + { + unsigned_byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("-123"); + assert (test_post_fail (p)); + } + + // Ranges + // + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("-129"); + assert (test_post_fail (p)); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("128"); + assert (test_post_fail (p)); + } + + { + unsigned_byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("256"); + assert (test_post_fail (p)); + } +} diff --git a/xsd-tests/cxx/parser/validation/built-in/date-time/buildfile b/xsd-tests/cxx/parser/validation/built-in/date-time/buildfile new file mode 100644 index 0000000..47791e5 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/date-time/buildfile @@ -0,0 +1,10 @@ +# file : cxx/parser/validation/built-in/date-time/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} + +exe{driver}: {hxx cxx}{*} $libs + +# Define XSD_CXX11 since we include libxsd headers directly. +# +cxx.poptions += -DXSD_CXX11 diff --git a/xsd-tests/cxx/parser/validation/built-in/date-time/driver.cxx b/xsd-tests/cxx/parser/validation/built-in/date-time/driver.cxx new file mode 100644 index 0000000..da02a50 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/date-time/driver.cxx @@ -0,0 +1,1533 @@ +// file : cxx/parser/validation/built-in/date-time/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the built-in date and time types validation. +// +#include + +#include +#include + +using namespace xsd::cxx::parser::validating; + +template +bool +test_post_fail (T& p) +{ + try + { + p._post (); + } + catch (invalid_value const&) + { + return true; + } + + return false; +} + +int +main () +{ + typedef xsd::cxx::parser::gday gday; + typedef xsd::cxx::parser::gmonth gmonth; + typedef xsd::cxx::parser::gyear gyear; + typedef xsd::cxx::parser::gmonth_day gmonth_day; + typedef xsd::cxx::parser::gyear_month gyear_month; + typedef xsd::cxx::parser::date date; + typedef xsd::cxx::parser::time time; + typedef xsd::cxx::parser::date_time date_time; + typedef xsd::cxx::parser::duration duration; + + // Good. + // + + // gday & time zone parsing + // + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters (" \t\n "); + p._characters ("---1"); + p._characters ("2+12:00"); + p._post (); + assert (p.post_gday () == gday (12, 12, 00)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---01"); + p._post (); + assert (p.post_gday () == gday (1)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---31"); + p._post (); + assert (p.post_gday () == gday (31)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---15Z"); + p._post (); + assert (p.post_gday () == gday (15, 0, 0)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---15-14:00"); + p._post (); + assert (p.post_gday () == gday (15, -14, 0)); + } + + // gmonth + // + { + gmonth_pimpl p; + p.pre (); + p._pre (); + p._characters (" \t\n "); + p._characters ("--1"); + p._characters ("0+12:00"); + p._post (); + assert (p.post_gmonth () == gmonth (10, 12, 0)); + } + + { + gmonth_pimpl p; + p.pre (); + p._pre (); + p._characters ("--01"); + p._post (); + assert (p.post_gmonth () == gmonth (1)); + } + + { + gmonth_pimpl p; + p.pre (); + p._pre (); + p._characters ("--12Z"); + p._post (); + assert (p.post_gmonth () == gmonth (12, 0, 0)); + } + + // gyear + // + { + gyear_pimpl p; + p.pre (); + p._pre (); + p._characters (" \t\n "); + p._characters ("20"); + p._characters ("07+12:00"); + p._post (); + assert (p.post_gyear () == gyear (2007, 12, 00)); + } + + { + gyear_pimpl p; + p.pre (); + p._pre (); + p._characters ("0001"); + p._post (); + assert (p.post_gyear () == gyear (1)); + } + + { + gyear_pimpl p; + p.pre (); + p._pre (); + p._characters ("-20000Z"); + p._post (); + assert (p.post_gyear () == gyear (-20000, 0, 0)); + } + + // gmonth_day + // + { + gmonth_day_pimpl p; + p.pre (); + p._pre (); + 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)); + } + + { + gmonth_day_pimpl p; + p.pre (); + p._pre (); + p._characters ("--12-31"); + p._post (); + assert (p.post_gmonth_day () == gmonth_day (12, 31)); + } + + { + gmonth_day_pimpl p; + p.pre (); + p._pre (); + p._characters ("--01-01Z"); + p._post (); + assert (p.post_gmonth_day () == gmonth_day (1, 1, 0, 0)); + } + + // gyear_month + // + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + 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, 00)); + } + + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters ("-2007-10"); + p._post (); + assert (p.post_gyear_month () == gyear_month (-2007, 10)); + } + + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters ("20007-10Z"); + p._post (); + assert (p.post_gyear_month () == gyear_month (20007, 10, 0, 0)); + } + + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters ("-20007-01"); + p._post (); + assert (p.post_gyear_month () == gyear_month (-20007, 1)); + } + + // date + // + { + date_pimpl p; + p.pre (); + p._pre (); + 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)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("-2007-10-15"); + p._post (); + assert (p.post_date () == date (-2007, 10, 15)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("20007-12-31Z"); + p._post (); + assert (p.post_date () == date (20007, 12, 31, 0, 0)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("-20007-01-01"); + p._post (); + assert (p.post_date () == date (-20007, 1, 1)); + } + + // time + // + { + time_pimpl p; + p.pre (); + p._pre (); + 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)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("12:13:14"); + p._post (); + assert (p.post_time () == time (12, 13, 14.0)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("12:13:14Z"); + p._post (); + assert (p.post_time () == time (12, 13, 14.0, 0, 0)); + } + + // date_time + // + { + date_time_pimpl p; + p.pre (); + p._pre (); + 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)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("-2007-10-15T12:13:14"); + p._post (); + assert (p.post_date_time () == date_time (-2007, 10, 15, 12, 13, 14.0)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + 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)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("-20007-01-01T12:13:14"); + p._post (); + assert (p.post_date_time () == date_time (-20007, 1, 1, 12, 13, 14.0)); + } + + // duration + // + { + duration_pimpl p; + p.pre (); + p._pre (); + 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)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("P1Y"); + p._post (); + assert (p.post_duration () == duration (false, 1, 0, 0, 0, 0, 0.0)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("P1M"); + p._post (); + assert (p.post_duration () == duration (false, 0, 1, 0, 0, 0, 0.0)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("P1D"); + p._post (); + assert (p.post_duration () == duration (false, 0, 0, 1, 0, 0, 0.0)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("PT1H"); + p._post (); + assert (p.post_duration () == duration (false, 0, 0, 0, 1, 0, 0.0)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("PT1M"); + p._post (); + assert (p.post_duration () == duration (false, 0, 0, 0, 0, 1, 0.0)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("PT1.1S"); + p._post (); + assert (p.post_duration () == duration (false, 0, 0, 0, 0, 0, 1.1)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("P1YT1S"); + p._post (); + assert (p.post_duration () == duration (false, 1, 0, 0, 0, 0, 1.0)); + } + + // Bad + // + + // gday & time zone parsing + // + { + gday_pimpl p; + p.pre (); + p._pre (); + // p._characters (""); + assert (test_post_fail (p)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("--12"); + assert (test_post_fail (p)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---1"); + assert (test_post_fail (p)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---00"); + assert (test_post_fail (p)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---32"); + assert (test_post_fail (p)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---2X"); + assert (test_post_fail (p)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---12asd"); + assert (test_post_fail (p)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---12X"); + assert (test_post_fail (p)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---1212:00"); + assert (test_post_fail (p)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---12+2:00"); + assert (test_post_fail (p)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---12+1200"); + assert (test_post_fail (p)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---12+15:00"); + assert (test_post_fail (p)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---12+12:60"); + assert (test_post_fail (p)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---12+14:01"); + assert (test_post_fail (p)); + } + + // gmonth + // + { + gmonth_pimpl p; + p.pre (); + p._pre (); + // p._characters (""); + assert (test_post_fail (p)); + } + + { + gmonth_pimpl p; + p.pre (); + p._pre (); + p._characters ("-12"); + assert (test_post_fail (p)); + } + + { + gmonth_pimpl p; + p.pre (); + p._pre (); + p._characters ("--00"); + assert (test_post_fail (p)); + } + + { + gmonth_pimpl p; + p.pre (); + p._pre (); + p._characters ("--13"); + assert (test_post_fail (p)); + } + + { + gmonth_pimpl p; + p.pre (); + p._pre (); + p._characters ("--1X"); + assert (test_post_fail (p)); + } + + { + gmonth_pimpl p; + p.pre (); + p._pre (); + p._characters ("--11+12:3o"); + assert (test_post_fail (p)); + } + + // gyear + // + { + gyear_pimpl p; + p.pre (); + p._pre (); + // p._characters (""); + assert (test_post_fail (p)); + } + + { + gyear_pimpl p; + p.pre (); + p._pre (); + p._characters ("207"); + assert (test_post_fail (p)); + } + + { + gyear_pimpl p; + p.pre (); + p._pre (); + p._characters ("-207"); + assert (test_post_fail (p)); + } + + { + gyear_pimpl p; + p.pre (); + p._pre (); + p._characters ("-0000"); + assert (test_post_fail (p)); + } + + { + gyear_pimpl p; + p.pre (); + p._pre (); + p._characters ("20X7"); + assert (test_post_fail (p)); + } + + { + gyear_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007+12:3o"); + assert (test_post_fail (p)); + } + + // gmonth_day + // + { + gmonth_day_pimpl p; + p.pre (); + p._pre (); + // p._characters (""); + assert (test_post_fail (p)); + } + + { + gmonth_day_pimpl p; + p.pre (); + p._pre (); + p._characters ("-12-12"); + assert (test_post_fail (p)); + } + + { + gmonth_day_pimpl p; + p.pre (); + p._pre (); + p._characters ("--1212"); + assert (test_post_fail (p)); + } + + { + gmonth_day_pimpl p; + p.pre (); + p._pre (); + p._characters ("--12?12"); + assert (test_post_fail (p)); + } + + { + gmonth_day_pimpl p; + p.pre (); + p._pre (); + p._characters ("--00-12"); + assert (test_post_fail (p)); + } + + { + gmonth_day_pimpl p; + p.pre (); + p._pre (); + p._characters ("--12-00"); + assert (test_post_fail (p)); + } + + { + gmonth_day_pimpl p; + p.pre (); + p._pre (); + p._characters ("--13-23"); + assert (test_post_fail (p)); + } + + { + gmonth_day_pimpl p; + p.pre (); + p._pre (); + p._characters ("--12-32"); + assert (test_post_fail (p)); + } + + { + gmonth_day_pimpl p; + p.pre (); + p._pre (); + p._characters ("--1X-12"); + assert (test_post_fail (p)); + } + + { + gmonth_day_pimpl p; + p.pre (); + p._pre (); + p._characters ("--12-2X"); + assert (test_post_fail (p)); + } + + { + gmonth_day_pimpl p; + p.pre (); + p._pre (); + p._characters ("--11-11+12:3o"); + assert (test_post_fail (p)); + } + + // gyear_month + // + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + // p._characters (""); + assert (test_post_fail (p)); + } + + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters ("207-01"); + assert (test_post_fail (p)); + } + + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters ("-207-01"); + assert (test_post_fail (p)); + } + + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters ("0000-01"); + assert (test_post_fail (p)); + } + + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters ("20X7-01"); + assert (test_post_fail (p)); + } + + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007"); + assert (test_post_fail (p)); + } + + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007?12"); + assert (test_post_fail (p)); + } + + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-0"); + assert (test_post_fail (p)); + } + + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-00"); + assert (test_post_fail (p)); + } + + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-13"); + assert (test_post_fail (p)); + } + + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-1X"); + assert (test_post_fail (p)); + } + + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01+12:3o"); + assert (test_post_fail (p)); + } + + // date + // + { + date_pimpl p; + p.pre (); + p._pre (); + // p._characters (""); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("207-01-01"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("-207-01-01"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("0000-01-01"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("20X7-01-01"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007?01-01"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-0-01"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-00-01"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-13-01"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-1X-01"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-10"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-10?12"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-10-"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-10-0"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-10-00"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-10-32"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-10-2X"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01+12:3o"); + assert (test_post_fail (p)); + } + + // time + // + { + time_pimpl p; + p.pre (); + p._pre (); + // p._characters (""); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("1:01:01"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2X:01:01"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("23"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("23?01:01"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("23:0:01"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("23:60:01"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("23:4X:01"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("23:10"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("23:10?12"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("23:10:"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("23:10:0"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("23:10:01."); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("23:10:60"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("23:10:2X"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("24:01:00"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("24:00:01"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("23:01:01+12:3o"); + assert (test_post_fail (p)); + } + + // date_time + // + { + date_time_pimpl p; + p.pre (); + p._pre (); + // p._characters (""); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("207-01-01T12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("-207-01-01T12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("0000-01-01T12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("20X7-01-01T12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007?01-01T12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-0-01T12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-00-01T12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-13-01T12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-1X-01T12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-10"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-10?12T12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-10-T12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-10-0T12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-10-00T12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-10-32T12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-10-2XT12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T1:01:01"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T2X:01:01"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T23"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T23?01:01"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T23:0:01"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T23:60:01"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T23:4X:01"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T23:10"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T23:10?12"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T23:10:"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T23:10:0"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T23:10:01."); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T23:10:60"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T23:10:2X"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T24:01:00"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T24:00:01"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("23:01:01+12:3o"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T12:13:14+12:3o"); + assert (test_post_fail (p)); + } + + // duration + // + { + duration_pimpl p; + p.pre (); + p._pre (); + // p._characters (""); + assert (test_post_fail (p)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007Y"); + assert (test_post_fail (p)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("-2007Y"); + assert (test_post_fail (p)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("P-2007Y"); + assert (test_post_fail (p)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("P-1M"); + assert (test_post_fail (p)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("P-1D"); + assert (test_post_fail (p)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("PT-1H"); + assert (test_post_fail (p)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("PT-1M"); + assert (test_post_fail (p)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("PT-1.1S"); + assert (test_post_fail (p)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("P1H1M1S"); + assert (test_post_fail (p)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("P1M1Y"); + assert (test_post_fail (p)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("PT1S1H"); + assert (test_post_fail (p)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("PT1H1Y"); + assert (test_post_fail (p)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("P1Ygarbage"); + assert (test_post_fail (p)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("P1YT"); + assert (test_post_fail (p)); + } +} diff --git a/xsd-tests/cxx/parser/validation/built-in/float/buildfile b/xsd-tests/cxx/parser/validation/built-in/float/buildfile new file mode 100644 index 0000000..ca0eac1 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/float/buildfile @@ -0,0 +1,10 @@ +# file : cxx/parser/validation/built-in/float/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} + +exe{driver}: {hxx cxx}{*} $libs + +# Define XSD_CXX11 since we include libxsd headers directly. +# +cxx.poptions += -DXSD_CXX11 diff --git a/xsd-tests/cxx/parser/validation/built-in/float/driver.cxx b/xsd-tests/cxx/parser/validation/built-in/float/driver.cxx new file mode 100644 index 0000000..bb67eb7 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/float/driver.cxx @@ -0,0 +1,285 @@ +// file : cxx/parser/validation/built-in/float/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the built-in float, double, and decimal types validation. +// +#include +#include + +#include +#include + +using namespace xsd::cxx::parser::validating; + +template +bool +test_post_fail (T& p) +{ + try + { + p._post (); + } + catch (invalid_value const&) + { + return true; + } + + return false; +} + +int +main () +{ + // Good. + // + + // float + // + { + float_pimpl p; + p.pre (); + p._pre (); + p._characters (" 0000123.456 "); + p._post (); + assert (p.post_float () == 123.456F); + } + + { + float_pimpl p; + p.pre (); + p._pre (); + p._characters ("-12.345E2"); + p._post (); + assert (p.post_float () == -12.345E2F); + } + + { + float_pimpl p; + p.pre (); + p._pre (); + p._characters ("0"); + p._post (); + assert (p.post_float () == 0.0F); + } + + { + float_pimpl p; + p.pre (); + p._pre (); + p._characters ("-0"); + p._post (); + assert (p.post_float () == -0.0F); + } + + { + float_pimpl p; + p.pre (); + p._pre (); + p._characters ("INF"); + p._post (); + assert (isinf (p.post_float ())); + } + + { + float_pimpl p; + p.pre (); + p._pre (); + p._characters ("-INF"); + p._post (); + assert (isinf (p.post_float ())); + } + + { + float_pimpl p; + p.pre (); + p._pre (); + p._characters ("NaN"); + p._post (); + assert (isnan (p.post_float ())); + } + + // double + // + { + double_pimpl p; + p.pre (); + p._pre (); + p._characters (" 0000123.456789 "); + p._post (); + assert (p.post_double () == 123.456789); + } + + { + double_pimpl p; + p.pre (); + p._pre (); + p._characters ("-12.3456789E2"); + p._post (); + assert (p.post_double () == -12.3456789E2); + } + + { + double_pimpl p; + p.pre (); + p._pre (); + p._characters ("0"); + p._post (); + assert (p.post_double () == 0.0); + } + + { + double_pimpl p; + p.pre (); + p._pre (); + p._characters ("-0"); + p._post (); + assert (p.post_double () == -0.0); + } + + { + double_pimpl p; + p.pre (); + p._pre (); + p._characters ("INF"); + p._post (); + assert (isinf (p.post_double ())); + } + + { + double_pimpl p; + p.pre (); + p._pre (); + p._characters ("-INF"); + p._post (); + assert (isinf (p.post_double ())); + } + + { + double_pimpl p; + p.pre (); + p._pre (); + p._characters ("NaN"); + p._post (); + assert (isnan (p.post_double ())); + } + + // decimal + // + { + decimal_pimpl p; + p.pre (); + p._pre (); + p._characters (" 0000123.456789 "); + p._post (); + assert (p.post_decimal () == 123.456789); + } + + { + decimal_pimpl p; + p.pre (); + p._pre (); + p._characters ("-123.45678912345"); + p._post (); + assert (p.post_decimal () == -123.45678912345); + } + + { + decimal_pimpl p; + p.pre (); + p._pre (); + p._characters ("0"); + p._post (); + assert (p.post_decimal () == 0.0); + } + + { + decimal_pimpl p; + p.pre (); + p._pre (); + p._characters ("-0"); + p._post (); + assert (p.post_decimal () == -0.0); + } + + + // Bad + // + + // float + // + { + float_pimpl p; + p.pre (); + p._pre (); + p._characters ("+INF"); + assert (test_post_fail (p)); + } + + { + float_pimpl p; + p.pre (); + p._pre (); + p._characters ("1.45 E2"); + assert (test_post_fail (p)); + } + + // double + // + { + double_pimpl p; + p.pre (); + p._pre (); + p._characters ("+INF"); + assert (test_post_fail (p)); + } + + { + double_pimpl p; + p.pre (); + p._pre (); + p._characters ("1.45 E2"); + assert (test_post_fail (p)); + } + + // decimal + // + { + decimal_pimpl p; + p.pre (); + p._pre (); + p._characters ("INF"); + assert (test_post_fail (p)); + } + + { + decimal_pimpl p; + p.pre (); + p._pre (); + p._characters ("+INF"); + assert (test_post_fail (p)); + } + + { + decimal_pimpl p; + p.pre (); + p._pre (); + p._characters ("-INF"); + assert (test_post_fail (p)); + } + + { + decimal_pimpl p; + p.pre (); + p._pre (); + p._characters ("NaN"); + assert (test_post_fail (p)); + } + + { + decimal_pimpl p; + p.pre (); + p._pre (); + p._characters ("1.45 2"); + assert (test_post_fail (p)); + } +} diff --git a/xsd-tests/cxx/parser/validation/built-in/int/buildfile b/xsd-tests/cxx/parser/validation/built-in/int/buildfile new file mode 100644 index 0000000..51bdf12 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/int/buildfile @@ -0,0 +1,10 @@ +# file : cxx/parser/validation/built-in/int/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} + +exe{driver}: {hxx cxx}{*} $libs + +# Define XSD_CXX11 since we include libxsd headers directly. +# +cxx.poptions += -DXSD_CXX11 diff --git a/xsd-tests/cxx/parser/validation/built-in/int/driver.cxx b/xsd-tests/cxx/parser/validation/built-in/int/driver.cxx new file mode 100644 index 0000000..d31d206 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/int/driver.cxx @@ -0,0 +1,116 @@ +// file : cxx/parser/validation/built-in/int/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the built-in int and unsigned int types validation. +// +#include + +#include +#include + +using namespace xsd::cxx::parser::validating; + +template +bool +test_post_fail (T& p) +{ + try + { + p._post (); + } + catch (invalid_value const&) + { + return true; + } + + return false; +} + +int +main () +{ + // Good. + // + { + int_pimpl p; + p.pre (); + p._pre (); + p._characters ("-2147483648"); + p._post (); + assert (p.post_int () == -2147483648); + } + + { + int_pimpl p; + p.pre (); + p._pre (); + p._characters ("0"); + p._post (); + assert (p.post_int () == 0); + } + + { + int_pimpl p; + p.pre (); + p._pre (); + p._characters ("2147483647"); + p._post (); + assert (p.post_int () == 2147483647); + } + + { + unsigned_int_pimpl p; + p.pre (); + p._pre (); + p._characters ("0"); + p._post (); + assert (p.post_unsigned_int () == 0); + } + + { + unsigned_int_pimpl p; + p.pre (); + p._pre (); + p._characters ("4294967295"); + p._post (); + assert (p.post_unsigned_int () == 4294967295); + } + + // Bad + // + + { + unsigned_int_pimpl p; + p.pre (); + p._pre (); + p._characters ("-123"); + assert (test_post_fail (p)); + } + + + // Ranges + // + { + int_pimpl p; + p.pre (); + p._pre (); + p._characters ("-2147483649"); + assert (test_post_fail (p)); + } + + { + int_pimpl p; + p.pre (); + p._pre (); + p._characters ("2147483648"); + assert (test_post_fail (p)); + } + + { + unsigned_int_pimpl p; + p.pre (); + p._pre (); + p._characters ("4294967296"); + assert (test_post_fail (p)); + } +} diff --git a/xsd-tests/cxx/parser/validation/built-in/integer/buildfile b/xsd-tests/cxx/parser/validation/built-in/integer/buildfile new file mode 100644 index 0000000..4d63a19 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/integer/buildfile @@ -0,0 +1,10 @@ +# file : cxx/parser/validation/built-in/integer/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} + +exe{driver}: {hxx cxx}{*} $libs + +# Define XSD_CXX11 since we include libxsd headers directly. +# +cxx.poptions += -DXSD_CXX11 diff --git a/xsd-tests/cxx/parser/validation/built-in/integer/driver.cxx b/xsd-tests/cxx/parser/validation/built-in/integer/driver.cxx new file mode 100644 index 0000000..3a5fdd5 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/integer/driver.cxx @@ -0,0 +1,303 @@ +// file : cxx/parser/validation/built-in/integer/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the built-in integer & friends types validation. +// +#include + +#include +#include +#include + +#include +#include + +using namespace std; +using namespace xsd::cxx::parser::validating; + +template +bool +test_post_fail (T& p) +{ + try + { + p._post (); + } + catch (invalid_value const&) + { + return true; + } + + return false; +} + +int +main () +{ + // Good. + // + + std::string min; + std::string max; + std::string umax; + + { + ostringstream ostr; + ostr << LLONG_MIN; + min = ostr.str (); + } + + { + ostringstream ostr; + ostr << LLONG_MAX; + max = ostr.str (); + } + + { + ostringstream ostr; + ostr << ULLONG_MAX; + umax = ostr.str (); + } + + // integer + // + { + integer_pimpl p; + p.pre (); + p._pre (); + p._characters (min.c_str ()); + p._post (); + assert (p.post_integer () == LLONG_MIN); + } + + { + integer_pimpl p; + p.pre (); + p._pre (); + p._characters ("0"); + p._post (); + assert (p.post_integer () == 0); + } + + { + integer_pimpl p; + p.pre (); + p._pre (); + p._characters (max.c_str ()); + p._post (); + assert (p.post_integer () == LLONG_MAX); + } + + // negative_integer + // + { + negative_integer_pimpl p; + p.pre (); + p._pre (); + p._characters (min.c_str ()); + p._post (); + assert (p.post_negative_integer () == LLONG_MIN); + } + + { + negative_integer_pimpl p; + p.pre (); + p._pre (); + p._characters ("-1"); + p._post (); + assert (p.post_negative_integer () == -1); + } + + // non_positive_integer + // + { + non_positive_integer_pimpl p; + p.pre (); + p._pre (); + p._characters (min.c_str ()); + p._post (); + assert (p.post_non_positive_integer () == LLONG_MIN); + } + + { + non_positive_integer_pimpl p; + p.pre (); + p._pre (); + p._characters ("+0"); + p._post (); + assert (p.post_non_positive_integer () == 0); + } + + // positive_integer + // + { + positive_integer_pimpl p; + p.pre (); + p._pre (); + p._characters ("1"); + p._post (); + assert (p.post_positive_integer () == 1); + } + + { + positive_integer_pimpl p; + p.pre (); + p._pre (); + p._characters (umax.c_str ()); + p._post (); + assert (p.post_positive_integer () == ULLONG_MAX); + } + + // non_negative_integer + // + /* + { + non_negative_integer_pimpl p; + p.pre (); + p._pre (); + p._characters ("-0"); + p._post (); + assert (p.post_non_negative_integer () == 0); + } + */ + + { + non_negative_integer_pimpl p; + p.pre (); + p._pre (); + p._characters ("0"); + p._post (); + assert (p.post_non_negative_integer () == 0); + } + + { + non_negative_integer_pimpl p; + p.pre (); + p._pre (); + p._characters (umax.c_str ()); + p._post (); + assert (p.post_non_negative_integer () == ULLONG_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 + // + { + integer_pimpl p; + p.pre (); + p._pre (); + p._characters (past_min.c_str ()); + assert (test_post_fail (p)); + } + + { + integer_pimpl p; + p.pre (); + p._pre (); + p._characters (past_max.c_str ()); + assert (test_post_fail (p)); + } + + // negative_integer + // + { + negative_integer_pimpl p; + p.pre (); + p._pre (); + p._characters (past_min.c_str ()); + assert (test_post_fail (p)); + } + + { + negative_integer_pimpl p; + p.pre (); + p._pre (); + p._characters ("-0"); + assert (test_post_fail (p)); + } + + { + negative_integer_pimpl p; + p.pre (); + p._pre (); + p._characters ("1"); + assert (test_post_fail (p)); + } + + // non_positive_integer + // + { + non_positive_integer_pimpl p; + p.pre (); + p._pre (); + p._characters (past_min.c_str ()); + assert (test_post_fail (p)); + } + + { + non_positive_integer_pimpl p; + p.pre (); + p._pre (); + p._characters ("1"); + assert (test_post_fail (p)); + } + + // positive_integer + // + { + positive_integer_pimpl p; + p.pre (); + p._pre (); + p._characters ("-1"); + assert (test_post_fail (p)); + } + + { + positive_integer_pimpl p; + p.pre (); + p._pre (); + p._characters ("+0"); + assert (test_post_fail (p)); + } + + { + positive_integer_pimpl p; + p.pre (); + p._pre (); + p._characters (past_umax.c_str ()); + assert (test_post_fail (p)); + } + + // non_negative_integer + // + { + non_negative_integer_pimpl p; + p.pre (); + p._pre (); + p._characters ("-1"); + assert (test_post_fail (p)); + } + + { + non_negative_integer_pimpl p; + p.pre (); + p._pre (); + p._characters (past_umax.c_str ()); + assert (test_post_fail (p)); + } +} diff --git a/xsd-tests/cxx/parser/validation/built-in/long/buildfile b/xsd-tests/cxx/parser/validation/built-in/long/buildfile new file mode 100644 index 0000000..285ad70 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/long/buildfile @@ -0,0 +1,10 @@ +# file : cxx/parser/validation/built-in/long/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} + +exe{driver}: {hxx cxx}{*} $libs + +# Define XSD_CXX11 since we include libxsd headers directly. +# +cxx.poptions += -DXSD_CXX11 diff --git a/xsd-tests/cxx/parser/validation/built-in/long/driver.cxx b/xsd-tests/cxx/parser/validation/built-in/long/driver.cxx new file mode 100644 index 0000000..a4ab565 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/long/driver.cxx @@ -0,0 +1,116 @@ +// file : cxx/parser/validation/built-in/long/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the built-in long and unsigned long types validation. +// +#include + +#include +#include + +using namespace xsd::cxx::parser::validating; + +template +bool +test_post_fail (T& p) +{ + try + { + p._post (); + } + catch (invalid_value const&) + { + return true; + } + + return false; +} + +int +main () +{ + // Good. + // + { + long_pimpl p; + p.pre (); + p._pre (); + p._characters ("-9223372036854775808"); + p._post (); + assert (p.post_long () == (-9223372036854775807LL - 1)); + } + + { + long_pimpl p; + p.pre (); + p._pre (); + p._characters ("0"); + p._post (); + assert (p.post_long () == 0); + } + + { + long_pimpl p; + p.pre (); + p._pre (); + p._characters ("9223372036854775807"); + p._post (); + assert (p.post_long () == 9223372036854775807LL); + } + + { + unsigned_long_pimpl p; + p.pre (); + p._pre (); + p._characters ("0"); + p._post (); + assert (p.post_unsigned_long () == 0); + } + + { + unsigned_long_pimpl p; + p.pre (); + p._pre (); + p._characters ("18446744073709551615"); + p._post (); + assert (p.post_unsigned_long () == 18446744073709551615ULL); + } + + // Bad + // + + { + unsigned_long_pimpl p; + p.pre (); + p._pre (); + p._characters ("-123"); + assert (test_post_fail (p)); + } + + + // Ranges + // + { + long_pimpl p; + p.pre (); + p._pre (); + p._characters ("-9223372036854775809"); + assert (test_post_fail (p)); + } + + { + long_pimpl p; + p.pre (); + p._pre (); + p._characters ("9223372036854775808"); + assert (test_post_fail (p)); + } + + { + unsigned_long_pimpl p; + p.pre (); + p._pre (); + p._characters ("18446744073709551616"); + assert (test_post_fail (p)); + } +} diff --git a/xsd-tests/cxx/parser/validation/built-in/qname/buildfile b/xsd-tests/cxx/parser/validation/built-in/qname/buildfile new file mode 100644 index 0000000..47d644c --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/qname/buildfile @@ -0,0 +1,10 @@ +# file : cxx/parser/validation/built-in/qname/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} + +exe{driver}: {hxx cxx}{*} $libs + +# Define XSD_CXX11 since we include libxsd headers directly. +# +cxx.poptions += -DXSD_CXX11 diff --git a/xsd-tests/cxx/parser/validation/built-in/qname/driver.cxx b/xsd-tests/cxx/parser/validation/built-in/qname/driver.cxx new file mode 100644 index 0000000..85acd1c --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/qname/driver.cxx @@ -0,0 +1,105 @@ +// file : cxx/parser/validation/built-in/qname/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the built-in QName type validation. +// +#include + +#include +#include + +using namespace xsd::cxx::parser::validating; + +bool +test_post_fail (qname_pimpl& p) +{ + try + { + p._post (); + } + catch (invalid_value const&) + { + return true; + } + + return false; +} + +int +main () +{ + typedef xsd::cxx::parser::qname qname; + + // Good. + // + { + qname_pimpl p; + p.pre (); + p._pre (); + p._characters (" xsi"); + p._characters (":"); + p._characters ("schemaLocation"); + p._post (); + assert (p.post_qname () == qname ("xsi", "schemaLocation")); + } + + { + qname_pimpl p; + p.pre (); + p._pre (); + p._characters ("schemaLocation"); + p._post (); + assert (p.post_qname () == qname ("schemaLocation")); + } + + + // Bad + // + { + qname_pimpl p; + p.pre (); + p._pre (); + //p._characters (""); + assert (test_post_fail (p)); + } + + { + qname_pimpl p; + p.pre (); + p._pre (); + p._characters (":"); + assert (test_post_fail (p)); + } + + { + qname_pimpl p; + p.pre (); + p._pre (); + p._characters ("xsi:"); + assert (test_post_fail (p)); + } + + { + qname_pimpl p; + p.pre (); + p._pre (); + p._characters (":schemaLocation"); + assert (test_post_fail (p)); + } + + { + qname_pimpl p; + p.pre (); + p._pre (); + p._characters ("x?i:schemaLocation"); + assert (test_post_fail (p)); + } + + { + qname_pimpl p; + p.pre (); + p._pre (); + p._characters ("xsi:schema Location"); + assert (test_post_fail (p)); + } +} diff --git a/xsd-tests/cxx/parser/validation/built-in/short/buildfile b/xsd-tests/cxx/parser/validation/built-in/short/buildfile new file mode 100644 index 0000000..782b404 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/short/buildfile @@ -0,0 +1,10 @@ +# file : cxx/parser/validation/built-in/short/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} + +exe{driver}: {hxx cxx}{*} $libs + +# Define XSD_CXX11 since we include libxsd headers directly. +# +cxx.poptions += -DXSD_CXX11 diff --git a/xsd-tests/cxx/parser/validation/built-in/short/driver.cxx b/xsd-tests/cxx/parser/validation/built-in/short/driver.cxx new file mode 100644 index 0000000..7c79b22 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/short/driver.cxx @@ -0,0 +1,116 @@ +// file : cxx/parser/validation/built-in/short/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the built-in short and unsigned short types validation. +// +#include + +#include +#include + +using namespace xsd::cxx::parser::validating; + +template +bool +test_post_fail (T& p) +{ + try + { + p._post (); + } + catch (invalid_value const&) + { + return true; + } + + return false; +} + +int +main () +{ + // Good. + // + { + short_pimpl p; + p.pre (); + p._pre (); + p._characters ("-32768"); + p._post (); + assert (p.post_short () == -32768); + } + + { + short_pimpl p; + p.pre (); + p._pre (); + p._characters ("0"); + p._post (); + assert (p.post_short () == 0); + } + + { + short_pimpl p; + p.pre (); + p._pre (); + p._characters ("32767"); + p._post (); + assert (p.post_short () == 32767); + } + + { + unsigned_short_pimpl p; + p.pre (); + p._pre (); + p._characters ("0"); + p._post (); + assert (p.post_unsigned_short () == 0); + } + + { + unsigned_short_pimpl p; + p.pre (); + p._pre (); + p._characters ("65535"); + p._post (); + assert (p.post_unsigned_short () == 65535); + } + + // Bad + // + + { + unsigned_short_pimpl p; + p.pre (); + p._pre (); + p._characters ("-1234"); + assert (test_post_fail (p)); + } + + + // Ranges + // + { + short_pimpl p; + p.pre (); + p._pre (); + p._characters ("-32769"); + assert (test_post_fail (p)); + } + + { + short_pimpl p; + p.pre (); + p._pre (); + p._characters ("32768"); + assert (test_post_fail (p)); + } + + { + unsigned_short_pimpl p; + p.pre (); + p._pre (); + p._characters ("65536"); + assert (test_post_fail (p)); + } +} diff --git a/xsd-tests/cxx/parser/validation/built-in/string/buildfile b/xsd-tests/cxx/parser/validation/built-in/string/buildfile new file mode 100644 index 0000000..83e5f7a --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/string/buildfile @@ -0,0 +1,10 @@ +# file : cxx/parser/validation/built-in/string/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} + +exe{driver}: {hxx cxx}{*} $libs + +# Define XSD_CXX11 since we include libxsd headers directly. +# +cxx.poptions += -DXSD_CXX11 diff --git a/xsd-tests/cxx/parser/validation/built-in/string/driver.cxx b/xsd-tests/cxx/parser/validation/built-in/string/driver.cxx new file mode 100644 index 0000000..920385a --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/string/driver.cxx @@ -0,0 +1,512 @@ +// file : cxx/parser/validation/built-in/string/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the built-in string & friends types validation. +// +#include +#include + +#include +#include + +using namespace xsd::cxx::parser::validating; + +template +bool +test_post_fail (T& p) +{ + try + { + p._post_impl (); // List implementation needs this to be post_impl. + } + catch (invalid_value const&) + { + return true; + } + + return false; +} + +int +main () +{ + typedef xsd::cxx::parser::string_sequence strings; + + // Good. + // + + // string + // + { + string_pimpl p; + p.pre (); + p._pre (); + p._characters (" \n\t"); + p._characters (" aaa "); + p._characters ("bbb"); + p._characters (" "); + p._post (); + assert (p.post_string () == " \n\t aaa bbb "); + } + + // normalized_string + // + { + normalized_string_pimpl p; + p.pre (); + p._pre (); + p._characters (" \n\t"); + p._characters (" aaa \n\t "); + p._characters (" bbb"); + p._characters (" "); + p._post (); + assert (p.post_normalized_string () == " aaa bbb "); + } + + // token + // + { + token_pimpl p; + p.pre (); + p._pre (); + p._characters (" \n\t"); + p._characters (" aaa \n\t "); + p._characters (" bbb \n\t"); + p._characters (" "); + p._post (); + assert (p.post_token () == "aaa bbb"); + } + + // name + // + { + name_pimpl p; + p.pre (); + p._pre (); + p._characters (" \n\t"); + p._characters (" a:b-c_d123 "); + p._characters (" "); + p._post (); + assert (p.post_name () == "a:b-c_d123"); + } + + { + name_pimpl p; + p.pre (); + p._pre (); + p._characters (" \n\t"); + p._characters (" _12 "); + p._characters (" "); + p._post (); + assert (p.post_name () == "_12"); + } + + { + name_pimpl p; + p.pre (); + p._pre (); + p._characters (" \n\t"); + p._characters (" :12 "); + p._characters (" "); + p._post (); + assert (p.post_name () == ":12"); + } + + // nmtoken + // + { + nmtoken_pimpl p; + p.pre (); + p._pre (); + p._characters (" \n\t"); + p._characters (" 123a:b-c_d123 "); + p._characters (" \n\t"); + p._characters (" "); + p._post (); + assert (p.post_nmtoken () == "123a:b-c_d123"); + } + + // nmtokens + // + { + strings s; + s.push_back ("123"); + s.push_back ("abc"); + + nmtokens_pimpl p; + p.pre (); + p._pre (); + p._characters (" \n\t"); + p._characters (" 123 "); + p._characters (" \n\t abc "); + p._characters (" "); + p._post (); + assert (p.post_nmtokens () == s); + } + + // ncname + // + { + ncname_pimpl p; + p.pre (); + p._pre (); + p._characters (" \n\t"); + p._characters (" a.b-c_d123 "); + p._characters (" "); + p._post (); + assert (p.post_ncname () == "a.b-c_d123"); + } + + // id + // + { + id_pimpl p; + p.pre (); + p._pre (); + p._characters (" \n\t"); + p._characters (" a.b-c_d123 "); + p._characters (" "); + p._post (); + assert (p.post_id () == "a.b-c_d123"); + } + + // idref + // + { + idref_pimpl p; + p.pre (); + p._pre (); + p._characters (" \n\t"); + p._characters (" a.b-c_d123 "); + p._characters (" "); + p._post (); + assert (p.post_idref () == "a.b-c_d123"); + } + + // idrefs + // + { + strings s; + s.push_back ("a123"); + s.push_back ("abc"); + + idrefs_pimpl p; + p.pre (); + p._pre (); + p._characters (" \n\t"); + p._characters (" a123 "); + p._characters (" \n\t abc "); + p._characters (" "); + p._post (); + assert (p.post_idrefs () == s); + } + + // language + // + { + language_pimpl p; + p.pre (); + p._pre (); + p._characters (" x "); + p._post (); + assert (p.post_language () == "x"); + } + + { + language_pimpl p; + p.pre (); + p._pre (); + p._characters (" en "); + p._post (); + assert (p.post_language () == "en"); + } + + { + language_pimpl p; + p.pre (); + p._pre (); + p._characters (" en"); + p._characters ("-us "); + p._post (); + assert (p.post_language () == "en-us"); + } + + { + language_pimpl p; + p.pre (); + p._pre (); + p._characters ("one-two-three-four44-seven77-eight888"); + p._post (); + assert (p.post_language () == "one-two-three-four44-seven77-eight888"); + } + + + // Bad + // + + // name + // + { + name_pimpl p; + p.pre (); + p._pre (); + p._characters (""); + assert (test_post_fail (p)); + } + + { + name_pimpl p; + p.pre (); + p._pre (); + p._characters (".a"); + assert (test_post_fail (p)); + } + + { + name_pimpl p; + p.pre (); + p._pre (); + p._characters ("-a"); + assert (test_post_fail (p)); + } + + { + name_pimpl p; + p.pre (); + p._pre (); + p._characters ("1a"); + assert (test_post_fail (p)); + } + + { + name_pimpl p; + p.pre (); + p._pre (); + p._characters ("a,b"); + assert (test_post_fail (p)); + } + + { + name_pimpl p; + p.pre (); + p._pre (); + p._characters ("a b"); + assert (test_post_fail (p)); + } + + { + name_pimpl p; + p.pre (); + p._pre (); + p._characters ("a p; + p.pre (); + p._pre (); + p._characters (""); + assert (test_post_fail (p)); + } + + { + nmtoken_pimpl p; + p.pre (); + p._pre (); + p._characters ("a,b"); + assert (test_post_fail (p)); + } + + { + nmtoken_pimpl p; + p.pre (); + p._pre (); + p._characters ("a b"); + assert (test_post_fail (p)); + } + + { + nmtoken_pimpl p; + p.pre (); + p._pre (); + p._characters ("a p; + p.pre (); + p._pre (); + p._characters (" "); + p._characters (" \t\n "); + assert (test_post_fail (p)); + } + + { + nmtokens_pimpl p; + p.pre (); + p._pre (); + p._characters ("ab a,b"); + assert (test_post_fail (p)); + } + + // ncname + // + { + ncname_pimpl p; + p.pre (); + p._pre (); + p._characters (""); + assert (test_post_fail (p)); + } + + { + ncname_pimpl p; + p.pre (); + p._pre (); + p._characters (".a"); + assert (test_post_fail (p)); + } + + { + ncname_pimpl p; + p.pre (); + p._pre (); + p._characters ("-a"); + assert (test_post_fail (p)); + } + + { + ncname_pimpl p; + p.pre (); + p._pre (); + p._characters (":a"); + assert (test_post_fail (p)); + } + + { + ncname_pimpl p; + p.pre (); + p._pre (); + p._characters ("1a"); + assert (test_post_fail (p)); + } + + { + ncname_pimpl p; + p.pre (); + p._pre (); + p._characters ("1:a"); + assert (test_post_fail (p)); + } + + { + ncname_pimpl p; + p.pre (); + p._pre (); + p._characters ("a,b"); + assert (test_post_fail (p)); + } + + { + ncname_pimpl p; + p.pre (); + p._pre (); + p._characters ("a b"); + assert (test_post_fail (p)); + } + + { + ncname_pimpl p; + p.pre (); + p._pre (); + p._characters ("a p; + p.pre (); + p._pre (); + p._characters ("a b"); + assert (test_post_fail (p)); + } + + // idref + // + { + idref_pimpl p; + p.pre (); + p._pre (); + p._characters ("a b"); + assert (test_post_fail (p)); + } + + // idrefs + // + { + idrefs_pimpl p; + p.pre (); + p._pre (); + p._characters (" "); + p._characters (" \t\n "); + assert (test_post_fail (p)); + } + + { + idrefs_pimpl p; + p.pre (); + p._pre (); + p._characters ("ab a p; + p.pre (); + p._pre (); + p._characters (" "); + assert (test_post_fail (p)); + } + + { + language_pimpl p; + p.pre (); + p._pre (); + p._characters ("en-"); + assert (test_post_fail (p)); + } + + { + language_pimpl p; + p.pre (); + p._pre (); + p._characters ("a1"); + assert (test_post_fail (p)); + } + + { + language_pimpl p; + p.pre (); + p._pre (); + p._characters ("en+us"); + assert (test_post_fail (p)); + } + + { + language_pimpl p; + p.pre (); + p._pre (); + p._characters ("en-nine99999"); + assert (test_post_fail (p)); + } +} diff --git a/xsd-tests/cxx/parser/validation/built-in/uri/buildfile b/xsd-tests/cxx/parser/validation/built-in/uri/buildfile new file mode 100644 index 0000000..a8fdf82 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/uri/buildfile @@ -0,0 +1,10 @@ +# file : cxx/parser/validation/built-in/uri/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} + +exe{driver}: {hxx cxx}{*} $libs + +# Define XSD_CXX11 since we include libxsd headers directly. +# +cxx.poptions += -DXSD_CXX11 diff --git a/xsd-tests/cxx/parser/validation/built-in/uri/driver.cxx b/xsd-tests/cxx/parser/validation/built-in/uri/driver.cxx new file mode 100644 index 0000000..dcc9242 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/uri/driver.cxx @@ -0,0 +1,53 @@ +// file : cxx/parser/validation/built-in/uri/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the built-in anyURI type validation. +// +#include + +#include +#include + +using namespace xsd::cxx::parser::validating; + +int +main () +{ + // Good. + // + { + uri_pimpl p; + p.pre (); + p._pre (); + p._characters (" "); + p._post (); + assert (p.post_uri () == ""); + } + + { + uri_pimpl p; + p.pre (); + p._pre (); + p._characters ("relative"); + p._post (); + assert (p.post_uri () == "relative"); + } + + { + uri_pimpl p; + p.pre (); + p._pre (); + p._characters ("#id"); + p._post (); + assert (p.post_uri () == "#id"); + } + + { + uri_pimpl p; + p.pre (); + p._pre (); + p._characters ("http://www.example.com/foo#bar"); + p._post (); + assert (p.post_uri () == "http://www.example.com/foo#bar"); + } +} diff --git a/xsd-tests/cxx/parser/validation/choice/buildfile b/xsd-tests/cxx/parser/validation/choice/buildfile new file mode 100644 index 0000000..adf0832 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/choice/buildfile @@ -0,0 +1,22 @@ +# file : cxx/parser/validation/choice/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs \ + testscript + +<{hxx ixx cxx}{test-pskel}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-parser --std c++11 \ + --generate-inline \ + --skel-file-suffix -pskel \ + --output-dir $out_base \ + --generate-validation \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/parser/validation/choice/driver.cxx b/xsd-tests/cxx/parser/validation/choice/driver.cxx new file mode 100644 index 0000000..4a52c5d --- /dev/null +++ b/xsd-tests/cxx/parser/validation/choice/driver.cxx @@ -0,0 +1,126 @@ +// file : cxx/parser/validation/choice/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the choice compositor validation. +// + +#include +#include +#include + +#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; + } + + 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 + _start_any_element (ro_string const& ns, + ro_string const& name, + ro_string const*) + { + 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 doc_p (type_p, "test", "root"); + + try + { + ifstream ifs (argv[1]); + type_p.pre (); + doc_p.parse (ifs, argv[1], "", xml_schema::flags::dont_validate); + type_p.post_type (); + } + catch (xml_schema::exception const& e) + { + cout << " " << e << endl + << "}" << endl + << endl; + } + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + catch (ios_base::failure const&) + { + cerr << "io failure" << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/parser/validation/choice/test.xsd b/xsd-tests/cxx/parser/validation/choice/test.xsd new file mode 100644 index 0000000..8132bbb --- /dev/null +++ b/xsd-tests/cxx/parser/validation/choice/test.xsd @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/parser/validation/choice/testscript b/xsd-tests/cxx/parser/validation/choice/testscript new file mode 100644 index 0000000..c5f5afa --- /dev/null +++ b/xsd-tests/cxx/parser/validation/choice/testscript @@ -0,0 +1,179 @@ +# file : cxx/parser/validation/choice/testscript +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +test.arguments += test.xml + +: valid +: +{ + cat <=test.xml; + + + + a + + b + + + + c + d + + any + + a + + + + c + d + + d + + a + + + + EOI + + $* >>EOO + { + a = a + b = b + } + + { + c = c + d = d + any: other#any + { + chars = any + } + a = a + } + + { + c = c + d = d + d = d + a = a + } + + EOO +} + +: absent1 +: +{ + cat <=test.xml; + + + + + + + + EOI + + $* >>EOO + { + :8:12 error: expected element 'a' + } + + EOO +} + +: absent2 +: +{ + cat <=test.xml; + + + + + c + d + + any + + a + b + + + + EOI + + $* >>EOO + { + c = c + d = d + any: other#any + { + chars = any + } + a = a + :14:8 error: unexpected element 'b' + } + + EOO +} + +: absent3 +: +{ + cat <=test.xml; + + + + + c + + + + EOI + + $* >>EOO + { + c = c + :9:12 error: expected element 'd' + } + + EOO +} + +: absent4 +: +{ + cat <=test.xml; + + + + + x + + + + EOI + + $* >>EOO + { + :8:8 error: expected element 'a' instead of 'x' + } + + EOO +} diff --git a/xsd-tests/cxx/parser/validation/restriction/buildfile b/xsd-tests/cxx/parser/validation/restriction/buildfile new file mode 100644 index 0000000..4c415bf --- /dev/null +++ b/xsd-tests/cxx/parser/validation/restriction/buildfile @@ -0,0 +1,22 @@ +# file : cxx/parser/validation/restriction/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs \ + testscript + +<{hxx ixx cxx}{test-pskel}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-parser --std c++11 \ + --generate-inline \ + --skel-file-suffix -pskel \ + --output-dir $out_base \ + --generate-validation \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/parser/validation/restriction/driver.cxx b/xsd-tests/cxx/parser/validation/restriction/driver.cxx new file mode 100644 index 0000000..206b9f8 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/restriction/driver.cxx @@ -0,0 +1,107 @@ +// file : cxx/parser/validation/restriction/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the restriction compositor validation. +// + +#include +#include +#include + +#include "test-pskel.hxx" + +using namespace std; +using namespace test; + +struct base_a_pimpl: base_a_pskel +{ +}; + +struct restriction_a_pimpl: restriction_a_pskel +{ +}; + +struct extension_b_pimpl: extension_b_pskel +{ +}; + +struct restriction_b_pimpl: restriction_b_pskel +{ +}; + +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 doc_b_p (type_b_p, "test", "root"); + xml_schema::document doc_r_p (type_r_p, "test", "root"); + + { + ifstream ifs (argv[1]); + type_b_p.pre (); + doc_b_p.parse (ifs, argv[1], "", xml_schema::flags::dont_validate); + type_b_p.post_type_b (); + } + + try + { + ifstream ifs (argv[1]); + type_r_p.pre (); + doc_r_p.parse (ifs, argv[1], "", xml_schema::flags::dont_validate); + type_r_p.post_type_r (); + } + catch (xml_schema::exception const& e) + { + cout << e << endl; + } + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + catch (ios_base::failure const&) + { + cerr << "io failure" << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/parser/validation/restriction/test.xsd b/xsd-tests/cxx/parser/validation/restriction/test.xsd new file mode 100644 index 0000000..158ded5 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/restriction/test.xsd @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/parser/validation/restriction/testscript b/xsd-tests/cxx/parser/validation/restriction/testscript new file mode 100644 index 0000000..ea5a4e8 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/restriction/testscript @@ -0,0 +1,159 @@ +# file : cxx/parser/validation/all/testscript +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +test.arguments += test.xml + +: valid +: +{ + cat <=test.xml; + + + + a + b + c + + + + a + b + c + + + + a + b + + + + a + c + + + + a + + + + EOI + + $* +} + +: invalid1 +: +{ + cat <=test.xml; + + + + + b + c + + + + EOI + + $* >>EOO + :7:8 error: expected element 'a' instead of 'b' + EOO +} + +: invalid2 +: +{ + cat <=test.xml; + + + + + a + b + c + + + + EOI + + $* >>EOO + :10:19 error: expected attribute 'z' + EOO +} + +: invalid3 +: +{ + cat <=test.xml; + + + + + a + b + c + + a + b + c + + + + EOI + + $* >>EOO + :11:8 error: unexpected element 'a' + EOO +} + +: invalid4 +: +{ + cat <=test.xml; + + + + + b + + + + EOI + + $* >>EOO + :7:8 error: expected element 'a' instead of 'b' + EOO +} + +: invalid5 +: +{ + cat <=test.xml; + + + + + a + b + + + + EOI + + $* >>EOO + :9:19 error: expected attribute 'y' + EOO +} diff --git a/xsd-tests/cxx/parser/validation/sequence/buildfile b/xsd-tests/cxx/parser/validation/sequence/buildfile new file mode 100644 index 0000000..b205091 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/sequence/buildfile @@ -0,0 +1,22 @@ +# file : cxx/parser/validation/sequence/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs \ + testscript + +<{hxx ixx cxx}{test-pskel}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-parser --std c++11 \ + --generate-inline \ + --skel-file-suffix -pskel \ + --output-dir $out_base \ + --generate-validation \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/parser/validation/sequence/driver.cxx b/xsd-tests/cxx/parser/validation/sequence/driver.cxx new file mode 100644 index 0000000..6b5bf70 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/sequence/driver.cxx @@ -0,0 +1,139 @@ +// file : cxx/parser/validation/sequence/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the sequence compositor validation. +// + +#include +#include +#include + +#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; + } + + 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; + } + + virtual void + _start_any_element (ro_string const& ns, + ro_string const& name, + ro_string const*) + { + 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 doc_p (type_p, "test", "root"); + + try + { + ifstream ifs (argv[1]); + type_p.pre (); + doc_p.parse (ifs, argv[1], "", xml_schema::flags::dont_validate); + type_p.post_type (); + } + catch (xml_schema::exception const& e) + { + cout << " " << e << endl + << "}" << endl + << endl; + } + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + catch (ios_base::failure const&) + { + cerr << "io failure" << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/parser/validation/sequence/test.xsd b/xsd-tests/cxx/parser/validation/sequence/test.xsd new file mode 100644 index 0000000..8753f54 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/sequence/test.xsd @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/parser/validation/sequence/testscript b/xsd-tests/cxx/parser/validation/sequence/testscript new file mode 100644 index 0000000..deebb9f --- /dev/null +++ b/xsd-tests/cxx/parser/validation/sequence/testscript @@ -0,0 +1,328 @@ +# file : cxx/parser/validation/sequence/testscript +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +test.arguments += test.xml + +: valid +: +{ + cat <=test.xml; + + + + c + d + aaabbbccc + f + e + + + + a + b + c + d + d + d + any + f + e + e + + + + a + b + c + d + d + d + any + f + e + e + + c + d + any + f + e + + + + EOI + + $* >>EOO + { + 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 + } + + EOO +} + +: invalid1 +: +{ + cat <=test.xml; + + + + + + + + EOI + + $* >>EOO + { + :8:14 error: expected element 'a' + } + + EOO +} + +: invalid2 +: +{ + cat <=test.xml; + + + + + c + d + any + f + e + + c + d + any + f + e + + c + d + any + f + e + + + + EOI + + $* >>EOO + { + 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:8 error: unexpected element 'c' + } + + EOO +} + +: invalid3 +: +{ + cat <=test.xml; + + + + + a + a + c + d + any + f + e + + + + EOI + + $* >>EOO + { + a = a + :9:8 error: expected element 'b' instead of 'a' + } + + EOO +} + +: invalid4 +: +{ + cat <=test.xml; + + + + + d + any + f + e + + + + EOI + + $* >>EOO + { + :8:8 error: expected element 'a' instead of 'd' + } + + EOO +} + +: invalid5 +: +{ + cat <=test.xml; + + + + + c + d + any + f + e + + + + EOI + + $* >>EOO + { + c = c + d = d + :10:13 error: expected element '##targetNamespace#*' instead of 'other1#any' + } + + EOO +} + +: invalid6 +: +{ + cat <=test.xml; + + + + + c + d + any + f + e + e + e + + + + EOI + + $* >>EOO + { + c = c + d = d + any: test#any + { + chars = any + } + f = f + e = e + e = e + :14:8 error: unexpected element 'e' + } + + EOO +} -- cgit v1.1