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/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 ++++++++++++++++++++++ 4 files changed, 351 insertions(+) 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 (limited to 'xsd-tests/cxx/parser/validation/choice') 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 +} -- cgit v1.1