diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2020-12-18 18:48:46 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2021-01-13 22:32:43 +0300 |
commit | 2615896faa646e5830abf2c269150e1165c66515 (patch) | |
tree | 7d95978ec0a83094c9462ed4e1f59d42f4ff8ddb /xsd-tests/cxx/parser/union | |
parent | 7420f85ea19b0562ffdd8123442f32bc8bac1267 (diff) |
Switch to build2
Diffstat (limited to 'xsd-tests/cxx/parser/union')
-rw-r--r-- | xsd-tests/cxx/parser/union/buildfile | 22 | ||||
-rw-r--r-- | xsd-tests/cxx/parser/union/driver.cxx | 60 | ||||
-rw-r--r-- | xsd-tests/cxx/parser/union/output | 2 | ||||
-rw-r--r-- | xsd-tests/cxx/parser/union/test.xml | 10 | ||||
-rw-r--r-- | xsd-tests/cxx/parser/union/test.xsd | 16 |
5 files changed, 110 insertions, 0 deletions
diff --git a/xsd-tests/cxx/parser/union/buildfile b/xsd-tests/cxx/parser/union/buildfile new file mode 100644 index 0000000..28f240c --- /dev/null +++ b/xsd-tests/cxx/parser/union/buildfile @@ -0,0 +1,22 @@ +# file : cxx/parser/union/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} + +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 + +cxx.poptions =+ "-I$out_base" + +<{hxx ixx cxx}{test-pskel}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-parser $xsd_cxx_std \ + --generate-inline \ + --skel-file-suffix -pskel \ + --output-dir $out_base \ + $path($<[0]) +}} diff --git a/xsd-tests/cxx/parser/union/driver.cxx b/xsd-tests/cxx/parser/union/driver.cxx new file mode 100644 index 0000000..c5b5c71 --- /dev/null +++ b/xsd-tests/cxx/parser/union/driver.cxx @@ -0,0 +1,60 @@ +// file : cxx/parser/union/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test xsd:union parsing. +// + +#include <string> +#include <iostream> + +#include "test-pskel.hxx" + +using namespace std; +using namespace test; + +struct int_string_union_pimpl: int_string_union_pskel +{ + virtual void + _characters (const xml_schema::ro_string& s) + { + cout << "'" << s << "'" << 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 + { + int_string_union_pimpl int_string_union_p; + type_pimpl type_p; + + type_p.parsers (int_string_union_p); + + xml_schema::document doc_p (type_p, "test", "root"); + + type_p.pre (); + doc_p.parse (argv[1]); + type_p.post_type (); + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + catch (std::ios_base::failure const&) + { + cerr << "io failure" << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/parser/union/output b/xsd-tests/cxx/parser/union/output new file mode 100644 index 0000000..a92ffc3 --- /dev/null +++ b/xsd-tests/cxx/parser/union/output @@ -0,0 +1,2 @@ +'one' +'1' diff --git a/xsd-tests/cxx/parser/union/test.xml b/xsd-tests/cxx/parser/union/test.xml new file mode 100644 index 0000000..5b3e799 --- /dev/null +++ b/xsd-tests/cxx/parser/union/test.xml @@ -0,0 +1,10 @@ +<t:root xmlns:t="test" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="test test.xsd"> + + <int-string-union/> + <int-string-union> </int-string-union> + <int-string-union>one</int-string-union> + <int-string-union>1</int-string-union> + +</t:root> diff --git a/xsd-tests/cxx/parser/union/test.xsd b/xsd-tests/cxx/parser/union/test.xsd new file mode 100644 index 0000000..5bf3d47 --- /dev/null +++ b/xsd-tests/cxx/parser/union/test.xsd @@ -0,0 +1,16 @@ +<?xml version="1.0"?> +<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test"> + + <simpleType name="int-string-union"> + <union memberTypes="int string"/> + </simpleType> + + <complexType name="type"> + <choice maxOccurs="unbounded"> + <element name="int-string-union" type="t:int-string-union"/> + </choice> + </complexType> + + <element name="root" type="t:type"/> + +</schema> |