summaryrefslogtreecommitdiff
path: root/xsd-tests/cxx/parser/union
diff options
context:
space:
mode:
Diffstat (limited to 'xsd-tests/cxx/parser/union')
-rw-r--r--xsd-tests/cxx/parser/union/buildfile23
-rw-r--r--xsd-tests/cxx/parser/union/driver.cxx60
-rw-r--r--xsd-tests/cxx/parser/union/output2
-rw-r--r--xsd-tests/cxx/parser/union/test.xml10
-rw-r--r--xsd-tests/cxx/parser/union/test.xsd16
5 files changed, 111 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..1a8615c
--- /dev/null
+++ b/xsd-tests/cxx/parser/union/buildfile
@@ -0,0 +1,23 @@
+# file : cxx/parser/union/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 \
+ $path($<[0])
+}}
+
+cxx.poptions =+ "-I$out_base"
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>