aboutsummaryrefslogtreecommitdiff
path: root/tests/cxx/tree
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2014-04-10 12:57:06 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2014-04-10 12:57:06 +0200
commit884dea7531962b17ef843ac2175faa050e8b0758 (patch)
treed70950ab2a6f314b06f37faa67252678ce3007b1 /tests/cxx/tree
parent0f6ff689dc6bae8fed94da0fcabd39f015e7a62b (diff)
Add support for ordered types, mixed content
Diffstat (limited to 'tests/cxx/tree')
-rw-r--r--tests/cxx/tree/makefile1
-rw-r--r--tests/cxx/tree/order/driver.cxx65
-rw-r--r--tests/cxx/tree/order/makefile94
-rw-r--r--tests/cxx/tree/order/output92
-rw-r--r--tests/cxx/tree/order/test.xml71
-rw-r--r--tests/cxx/tree/order/test.xsd130
-rw-r--r--tests/cxx/tree/wildcard/driver.cxx3
7 files changed, 456 insertions, 0 deletions
diff --git a/tests/cxx/tree/makefile b/tests/cxx/tree/makefile
index 43f806b..cd081e8 100644
--- a/tests/cxx/tree/makefile
+++ b/tests/cxx/tree/makefile
@@ -20,6 +20,7 @@ float \
list \
name-clash \
naming \
+order \
polymorphism \
prefix \
test-template \
diff --git a/tests/cxx/tree/order/driver.cxx b/tests/cxx/tree/order/driver.cxx
new file mode 100644
index 0000000..01d8d9f
--- /dev/null
+++ b/tests/cxx/tree/order/driver.cxx
@@ -0,0 +1,65 @@
+// file : tests/cxx/tree/order/driver.cxx
+// copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test ordered type support.
+//
+
+#include <memory> // std::auto_ptr/unique_ptr
+#include <cassert>
+#include <iostream>
+
+#include <xercesc/dom/DOM.hpp>
+#include <xercesc/util/PlatformUtils.hpp>
+
+#include "test.hxx"
+
+using namespace std;
+using namespace test;
+using namespace xercesc;
+
+int
+main (int argc, char* argv[])
+{
+ if (argc != 2)
+ {
+ cerr << "usage: " << argv[0] << " test.xml" << endl;
+ return 1;
+ }
+
+ XMLPlatformUtils::Initialize ();
+
+ try
+ {
+ XSD_AUTO_PTR<root> r (root_ (argv[1], xml_schema::flags::dont_initialize));
+
+ root c (*r);
+ assert (c == *r);
+
+ for (root::t1_const_iterator j (r->t1 ().begin ());
+ j != r->t1 ().end (); ++j)
+ {
+ const t1_derived& d (*j);
+
+ for (t1_derived::content_order_const_iterator i (
+ d.content_order ().begin ()); i != d.content_order ().end (); ++i)
+ {
+ cout << i->id << ' ' << i->index << endl;
+ }
+ }
+
+ xml_schema::namespace_infomap map;
+
+ map["t"].name = "test";
+ map["t1"].name = "test1";
+
+ root_ (cout, *r, map, "UTF-8", xml_schema::flags::dont_initialize);
+ }
+ catch (xml_schema::exception const& e)
+ {
+ cerr << e << endl;
+ return 1;
+ }
+
+ XMLPlatformUtils::Terminate ();
+}
diff --git a/tests/cxx/tree/order/makefile b/tests/cxx/tree/order/makefile
new file mode 100644
index 0000000..0dff0f9
--- /dev/null
+++ b/tests/cxx/tree/order/makefile
@@ -0,0 +1,94 @@
+# file : tests/cxx/tree/order/makefile
+# copyright : Copyright (c) 2006-2014 Code Synthesis Tools CC
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make
+
+xsd := test.xsd
+cxx := driver.cxx
+
+obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.o))
+dep := $(obj:.o=.o.d)
+
+driver := $(out_base)/driver
+test := $(out_base)/.test
+clean := $(out_base)/.clean
+
+
+# Import.
+#
+$(call import,\
+ $(scf_root)/import/libxerces-c/stub.make,\
+ l: xerces_c.l,cpp-options: xerces_c.l.cpp-options)
+
+
+# Build.
+#
+$(driver): $(obj) $(xerces_c.l)
+
+$(obj) $(dep): cpp_options := -I$(out_base) -I$(src_base) -I$(src_root)/libxsd
+$(obj) $(dep): $(xerces_c.l.cpp-options)
+
+genf := $(xsd:.xsd=.hxx) $(xsd:.xsd=.ixx) $(xsd:.xsd=.cxx)
+gen := $(addprefix $(out_base)/,$(genf))
+
+$(gen): xsd := $(out_root)/xsd/xsd
+$(gen): xsd_options += --generate-serialization --generate-wildcard \
+--generate-comparison \
+--ordered-type t1_base --ordered-type t1_derived \
+--ordered-type t2_base --ordered-type t2_derived \
+--ordered-type t3_type \
+--ordered-type t4_base --ordered-type t4_derived \
+--ordered-type t5_base --ordered-type t5_derived \
+--ordered-type t6_base --ordered-type t6_derived \
+--ordered-type t7_type
+$(gen): $(out_root)/xsd/xsd
+
+$(call include-dep,$(dep),$(obj),$(gen))
+
+# Convenience alias for default target.
+#
+$(out_base)/: $(driver)
+
+
+# Test.
+#
+$(test): driver := $(driver)
+$(test): $(driver) $(src_base)/test.xml $(src_base)/output
+ $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver))
+
+# Clean.
+#
+$(clean): $(driver).o.clean \
+ $(addsuffix .cxx.clean,$(obj)) \
+ $(addsuffix .cxx.clean,$(dep)) \
+ $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean))
+
+# Generated .gitignore.
+#
+ifeq ($(out_base),$(src_base))
+$(gen): | $(out_base)/.gitignore
+$(driver): | $(out_base)/.gitignore
+
+$(out_base)/.gitignore: files := driver $(genf)
+$(clean): $(out_base)/.gitignore.clean
+
+$(call include,$(bld_root)/git/gitignore.make)
+endif
+
+# How to.
+#
+$(call include,$(bld_root)/cxx/o-e.make)
+$(call include,$(bld_root)/cxx/cxx-o.make)
+$(call include,$(bld_root)/cxx/cxx-d.make)
+
+$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
+ifdef cxx_standard
+$(gen): xsd_options += --std $(cxx_standard)
+$(call include,$(scf_root)/xsd/tree/xsd-cxx.make)
+endif
+
+
+# Dependencies.
+#
+$(call import,$(src_root)/xsd/makefile)
diff --git a/tests/cxx/tree/order/output b/tests/cxx/tree/order/output
new file mode 100644
index 0000000..73442fe
--- /dev/null
+++ b/tests/cxx/tree/order/output
@@ -0,0 +1,92 @@
+2 0
+1 0
+1 1
+2 1
+3 0
+4 0
+3 1
+4 1
+<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
+<t:root xmlns:t="test" xmlns:t1="test1">
+ <t1>
+ <b>b1</b>
+ <a>a1</a>
+ <a>a2</a>
+ <b>b2</b>
+ <c>c1</c>
+ <d>d1</d>
+ <t1:e>e1</t1:e>
+ <d>d2</d>
+ <t1:f>f1</t1:f>
+ </t1>
+ <t2>
+ <b>b1</b>
+ <a>a1</a>
+ <b>b2</b>
+ <a>a2</a>
+ </t2>
+ <t3>
+ <a>a1</a>
+ <b>b1</b>
+ <c>c1</c>
+ <c>c2</c>
+ </t3>
+ <t3>
+ <a>a1</a>
+ <c>c1</c>
+ </t3>
+ <t4>
+ t1
+
+ <b>b1</b>
+ t2
+
+ <a>a1</a>
+ t3
+
+ <b>b2</b>
+ t4
+
+ <a>a2</a>
+ t5
+
+ <t1:d>d1</t1:d>
+ t6
+
+ <c>c1</c>
+ t7
+
+ </t4>
+ <t5a>
+ t5a
+ </t5a>
+ <t5b>
+ t1
+
+ <b>b1</b>
+ t2
+
+ <a>a1</a>
+ t3
+
+ <a>a2</a>
+ t4
+
+ <b>b2</b>
+ t5
+
+ </t5b>
+ <t6>
+ t6
+ </t6>
+ <t7>
+ t1
+
+ <t1:a>a1</t1:a>
+ t2
+
+ <t1:b>b1</t1:b>
+ t3
+
+ </t7>
+</t:root>
diff --git a/tests/cxx/tree/order/test.xml b/tests/cxx/tree/order/test.xml
new file mode 100644
index 0000000..cd82936
--- /dev/null
+++ b/tests/cxx/tree/order/test.xml
@@ -0,0 +1,71 @@
+<t:root xmlns:t="test"
+ xmlns:t1="test1"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+ <t1>
+ <b>b1</b>
+ <a>a1</a>
+ <a>a2</a>
+ <b>b2</b>
+ <c>c1</c>
+ <d>d1</d>
+ <t1:e>e1</t1:e>
+ <d>d2</d>
+ <t1:f>f1</t1:f>
+ </t1>
+ <t2>
+ <b>b1</b>
+ <a>a1</a>
+ <b>b2</b>
+ <a>a2</a>
+ </t2>
+ <t3>
+ <a>a1</a>
+ <b>b1</b>
+ <c>c1</c>
+ <c>c2</c>
+ </t3>
+ <t3>
+ <a>a1</a>
+ <c>c1</c>
+ </t3>
+ <t4>
+ t1
+ <b>b1</b>
+ t2
+ <a>a1</a>
+ t3
+ <b>b2</b>
+ t4
+ <a>a2</a>
+ t5
+ <t1:d>d1</t1:d>
+ t6
+ <c>c1</c>
+ t7
+ </t4>
+ <t5a>
+ t5a
+ </t5a>
+ <t5b>
+ t1
+ <b>b1</b>
+ t2
+ <a>a1</a>
+ t3
+ <a>a2</a>
+ t4
+ <b>b2</b>
+ t5
+ </t5b>
+ <t6>
+ t6
+ </t6>
+ <t7>
+ t1
+ <t1:a>a1</t1:a>
+ t2
+ <t1:b>b1</t1:b>
+ t3
+ </t7>
+</t:root>
diff --git a/tests/cxx/tree/order/test.xsd b/tests/cxx/tree/order/test.xsd
new file mode 100644
index 0000000..c30c027
--- /dev/null
+++ b/tests/cxx/tree/order/test.xsd
@@ -0,0 +1,130 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
+
+ <!-- Test 1: general, with non-ordered intermediate. -->
+
+ <complexType name="t1_base">
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element name="a" type="string"/>
+ <element name="b" type="string"/>
+ </choice>
+ </complexType>
+
+ <complexType name="t1_interm">
+ <complexContent>
+ <extension base="t:t1_base">
+ <sequence>
+ <element name="c" type="string" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="t1_derived">
+ <complexContent>
+ <extension base="t:t1_interm">
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element name="d" type="string"/>
+ <any namespace="##other" processContents="lax"/>
+ </choice>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Test 2: empty base. -->
+
+ <complexType name="t2_base"/>
+
+ <complexType name="t2_derived">
+ <complexContent>
+ <extension base="t:t2_base">
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element name="a" type="string"/>
+ <element name="b" type="string"/>
+ </choice>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Test 3: element cardinalities. -->
+
+ <complexType name="t3_type">
+ <sequence>
+ <element name="a" type="string"/>
+ <element name="b" type="string" minOccurs="0"/>
+ <element name="c" type="string" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+
+
+ <!-- Test 4: mixed content, general. -->
+
+ <complexType name="t4_base" mixed="true">
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element name="a" type="string"/>
+ <element name="b" type="string"/>
+ </choice>
+ </complexType>
+
+ <complexType name="t4_derived">
+ <complexContent mixed="true">
+ <extension base="t:t4_base">
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element name="c" type="string"/>
+ <any namespace="##other" processContents="lax"/>
+ </choice>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Test 5: mixed content, empty base. -->
+
+ <complexType name="t5_base" mixed="true"/>
+
+ <complexType name="t5_derived">
+ <complexContent mixed="true">
+ <extension base="t:t5_base">
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element name="a" type="string"/>
+ <element name="b" type="string"/>
+ </choice>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- Test 6: mixed content, empty base and derived. -->
+
+ <complexType name="t6_base" mixed="true"/>
+
+ <complexType name="t6_derived">
+ <complexContent mixed="true">
+ <extension base="t:t6_base"/>
+ </complexContent>
+ </complexType>
+
+ <!-- Test 7: mixed content wildcard only. -->
+
+ <complexType name="t7_type" mixed="true">
+ <sequence>
+ <any namespace="##other" processContents="lax" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+
+ <!-- Root -->
+
+ <complexType name="root">
+ <sequence>
+ <element name="t1" type="t:t1_derived" maxOccurs="unbounded"/>
+ <element name="t2" type="t:t2_derived" maxOccurs="unbounded"/>
+ <element name="t3" type="t:t3_type" maxOccurs="unbounded"/>
+ <element name="t4" type="t:t4_derived" maxOccurs="unbounded"/>
+ <element name="t5a" type="t:t5_base" maxOccurs="unbounded"/>
+ <element name="t5b" type="t:t5_derived" maxOccurs="unbounded"/>
+ <element name="t6" type="t:t6_derived" maxOccurs="unbounded"/>
+ <element name="t7" type="t:t7_type" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+
+ <element name="root" type="t:root"/>
+
+</schema>
diff --git a/tests/cxx/tree/wildcard/driver.cxx b/tests/cxx/tree/wildcard/driver.cxx
index 9d0945f..e2db827 100644
--- a/tests/cxx/tree/wildcard/driver.cxx
+++ b/tests/cxx/tree/wildcard/driver.cxx
@@ -9,6 +9,9 @@
#include <sstream>
#include <iostream>
+#include <xercesc/dom/DOM.hpp>
+#include <xercesc/util/PlatformUtils.hpp>
+
#include "test.hxx" // Get XSD_CXX11 defined.
#include <xsd/cxx/xml/string.hxx>