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 --- .../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 +++++ 5 files changed, 349 insertions(+) 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 (limited to 'xsd-tests/cxx/parser/validation/built-in/any-type') 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.1