aboutsummaryrefslogtreecommitdiff
path: root/tests/cxx/serializer/enumeration
diff options
context:
space:
mode:
Diffstat (limited to 'tests/cxx/serializer/enumeration')
-rw-r--r--tests/cxx/serializer/enumeration/boolean.hxx15
-rw-r--r--tests/cxx/serializer/enumeration/driver.cxx74
-rw-r--r--tests/cxx/serializer/enumeration/makefile75
-rw-r--r--tests/cxx/serializer/enumeration/output1
-rw-r--r--tests/cxx/serializer/enumeration/test.map7
-rw-r--r--tests/cxx/serializer/enumeration/test.xsd35
6 files changed, 207 insertions, 0 deletions
diff --git a/tests/cxx/serializer/enumeration/boolean.hxx b/tests/cxx/serializer/enumeration/boolean.hxx
new file mode 100644
index 0000000..b648a56
--- /dev/null
+++ b/tests/cxx/serializer/enumeration/boolean.hxx
@@ -0,0 +1,15 @@
+// file : tests/cxx/serializer/enumeration/boolean.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef BOOLEAN_HXX
+#define BOOLEAN_HXX
+
+enum boolean
+{
+ FALSE,
+ TRUE
+};
+
+#endif // BOOLEAN_HXX
diff --git a/tests/cxx/serializer/enumeration/driver.cxx b/tests/cxx/serializer/enumeration/driver.cxx
new file mode 100644
index 0000000..ae200ae
--- /dev/null
+++ b/tests/cxx/serializer/enumeration/driver.cxx
@@ -0,0 +1,74 @@
+// file : tests/cxx/serializer/enumeration/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 enumeration type serialization.
+//
+
+#include <iostream>
+
+#include "test-sskel.hxx"
+
+using namespace std;
+using namespace test;
+
+struct digit_simpl: digit_sskel
+{
+ digit_simpl ()
+ : digit_sskel (&base_impl_)
+ {
+ }
+
+private:
+ xml_schema::int_simpl base_impl_;
+};
+
+struct boolean_simpl: boolean_sskel
+{
+ boolean_simpl ()
+ : boolean_sskel (&base_impl_)
+ {
+ }
+
+ virtual void
+ pre (boolean b)
+ {
+ int i = b;
+ base_impl_.pre (i);
+ }
+
+private:
+ xml_schema::int_simpl base_impl_;
+};
+
+struct root_simpl: root_sskel
+{
+ virtual int
+ digit ()
+ {
+ return 7;
+ }
+
+ virtual ::boolean
+ boolean ()
+ {
+ return TRUE;
+ }
+};
+
+int
+main ()
+{
+ digit_simpl digit_s;
+ boolean_simpl boolean_s;
+ root_simpl root_s;
+
+ root_s.serializers (digit_s, boolean_s);
+
+ xml_schema::document_simpl doc_s (root_s, "test", "root");
+
+ root_s.pre ();
+ doc_s.serialize (cout);
+ root_s.post ();
+}
diff --git a/tests/cxx/serializer/enumeration/makefile b/tests/cxx/serializer/enumeration/makefile
new file mode 100644
index 0000000..2ccb073
--- /dev/null
+++ b/tests/cxx/serializer/enumeration/makefile
@@ -0,0 +1,75 @@
+# file : tests/cxx/serializer/enumeration/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=-sskel.o))
+dep := $(obj:.o=.o.d)
+
+xsde.l := $(out_root)/libxsde/xsde/xsde.l
+xsde.l.cpp-options := $(out_root)/libxsde/xsde/xsde.l.cpp-options
+
+driver := $(out_base)/driver
+test := $(out_base)/.test
+clean := $(out_base)/.clean
+
+
+# Build.
+#
+$(driver): $(obj) $(xsde.l)
+
+$(obj) $(dep): cpp_options := -I$(out_base) -I$(src_base)
+$(obj) $(dep): $(xsde.l.cpp-options)
+
+skel := $(out_base)/$(xsd:.xsd=-sskel.hxx) \
+ $(out_base)/$(xsd:.xsd=-sskel.ixx) \
+ $(out_base)/$(xsd:.xsd=-sskel.cxx)
+
+$(skel): xsde := $(out_root)/xsde/xsde
+$(skel): xsde_options += --type-map $(src_base)/test.map
+
+$(skel): $(out_root)/xsde/xsde $(src_base)/test.map
+
+$(call include-dep,$(dep))
+
+# Convenience alias for default target.
+#
+.PHONY: $(out_base)/
+$(out_base)/: $(driver)
+
+
+# Test.
+#
+.PHONY: $(test)
+
+$(test): driver := $(driver)
+$(test): $(driver) $(src_base)/output
+ $(call message,test $$1,$$1 | diff -u $(src_base)/output -,$(driver))
+
+# Clean.
+#
+.PHONY: $(clean)
+
+$(clean): $(driver).o.clean \
+ $(addsuffix .cxx.clean,$(obj)) \
+ $(addsuffix .cxx.clean,$(dep)) \
+ $(addprefix $(out_base)/,$(xsd:.xsd=-sskel.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)/xsde/serializer/xsd-cxx.make)
+
+
+# Dependencies.
+#
+$(call import,$(src_root)/xsde/makefile)
+$(call import,$(src_root)/libxsde/xsde/makefile)
diff --git a/tests/cxx/serializer/enumeration/output b/tests/cxx/serializer/enumeration/output
new file mode 100644
index 0000000..4907042
--- /dev/null
+++ b/tests/cxx/serializer/enumeration/output
@@ -0,0 +1 @@
+<g1:root xmlns:g1="test"><digit>7</digit><boolean>1</boolean></g1:root> \ No newline at end of file
diff --git a/tests/cxx/serializer/enumeration/test.map b/tests/cxx/serializer/enumeration/test.map
new file mode 100644
index 0000000..73f5d25
--- /dev/null
+++ b/tests/cxx/serializer/enumeration/test.map
@@ -0,0 +1,7 @@
+namespace test
+{
+ include "boolean.hxx";
+
+ digit int int;
+ boolean ::boolean ::boolean;
+}
diff --git a/tests/cxx/serializer/enumeration/test.xsd b/tests/cxx/serializer/enumeration/test.xsd
new file mode 100644
index 0000000..c130f75
--- /dev/null
+++ b/tests/cxx/serializer/enumeration/test.xsd
@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
+
+ <simpleType name="digit">
+ <restriction base="int">
+ <enumeration value="0"/>
+ <enumeration value="1"/>
+ <enumeration value="2"/>
+ <enumeration value="3"/>
+ <enumeration value="4"/>
+ <enumeration value="5"/>
+ <enumeration value="6"/>
+ <enumeration value="7"/>
+ <enumeration value="8"/>
+ <enumeration value="9"/>
+ </restriction>
+ </simpleType>
+
+ <simpleType name="boolean">
+ <restriction base="int">
+ <enumeration value="0"/>
+ <enumeration value="1"/>
+ </restriction>
+ </simpleType>
+
+ <complexType name="root">
+ <sequence>
+ <element name="digit" type="t:digit"/>
+ <element name="boolean" type="t:boolean"/>
+ </sequence>
+ </complexType>
+
+ <element name="root" type="t:root"/>
+
+</schema>