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/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 +++++++++++++++++++++ 4 files changed, 517 insertions(+) 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/sequence') 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