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