summaryrefslogtreecommitdiff
path: root/tests/cxx/tree/union/ctor
diff options
context:
space:
mode:
Diffstat (limited to 'tests/cxx/tree/union/ctor')
-rw-r--r--tests/cxx/tree/union/ctor/driver.cxx32
-rw-r--r--tests/cxx/tree/union/ctor/makefile82
-rw-r--r--tests/cxx/tree/union/ctor/test.xsd14
3 files changed, 128 insertions, 0 deletions
diff --git a/tests/cxx/tree/union/ctor/driver.cxx b/tests/cxx/tree/union/ctor/driver.cxx
new file mode 100644
index 0000000..965c98c
--- /dev/null
+++ b/tests/cxx/tree/union/ctor/driver.cxx
@@ -0,0 +1,32 @@
+// file : tests/cxx/tree/union/ctor/driver.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test union constructors.
+//
+#include <string>
+
+#include "test.hxx"
+
+using namespace std;
+using namespace test;
+
+int
+main ()
+{
+ // Test ctor(const std::string&)
+ //
+ {
+ string const s ("123");
+ int_string_union u (s);
+ type t (s);
+ }
+
+ // Test ctor(const char*).
+ //
+ {
+ int_string_union u ("123");
+ type t ("123");
+ }
+}
diff --git a/tests/cxx/tree/union/ctor/makefile b/tests/cxx/tree/union/ctor/makefile
new file mode 100644
index 0000000..13f1ae8
--- /dev/null
+++ b/tests/cxx/tree/union/ctor/makefile
@@ -0,0 +1,82 @@
+# file : tests/cxx/tree/union/ctor/makefile
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2006-2009 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$(src_root)/libxsd
+$(obj) $(dep): $(xerces_c.l.cpp-options)
+
+$(out_base)/$(xsd:.xsd=.hxx) \
+$(out_base)/$(xsd:.xsd=.ixx) \
+$(out_base)/$(xsd:.xsd=.cxx): xsd := $(out_root)/xsd/xsd
+
+$(out_base)/$(xsd:.xsd=.hxx) \
+$(out_base)/$(xsd:.xsd=.ixx) \
+$(out_base)/$(xsd:.xsd=.cxx): xsd_options := --generate-default-ctor \
+--generate-from-base-ctor --generate-doxygen
+
+$(out_base)/$(xsd:.xsd=.hxx) \
+$(out_base)/$(xsd:.xsd=.ixx) \
+$(out_base)/$(xsd:.xsd=.cxx): $(out_root)/xsd/xsd
+
+$(call include-dep,$(dep))
+
+# Convenience alias for default target.
+#
+.PHONY: $(out_base)/
+$(out_base)/: $(driver)
+
+
+# Test.
+#
+.PHONY: $(test)
+
+$(test): driver := $(driver)
+$(test): $(driver)
+ $(call message,test $$1,$$1,$(driver))
+
+# Clean.
+#
+.PHONY: $(clean)
+
+$(clean): $(driver).o.clean \
+ $(addsuffix .cxx.clean,$(obj)) \
+ $(addsuffix .cxx.clean,$(dep)) \
+ $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean))
+
+
+# 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,$(scf_root)/xsd/tree/xsd-cxx.make)
+
+
+# Dependencies.
+#
+$(call import,$(src_root)/xsd/makefile)
diff --git a/tests/cxx/tree/union/ctor/test.xsd b/tests/cxx/tree/union/ctor/test.xsd
new file mode 100644
index 0000000..9601093
--- /dev/null
+++ b/tests/cxx/tree/union/ctor/test.xsd
@@ -0,0 +1,14 @@
+<?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">
+ <sequence>
+ <element name="a" type="t:int-string-union"/>
+ </sequence>
+ </complexType>
+
+</schema>