diff options
Diffstat (limited to 'tests/cxx/serializer/all')
-rw-r--r-- | tests/cxx/serializer/all/driver.cxx | 108 | ||||
-rw-r--r-- | tests/cxx/serializer/all/makefile | 72 | ||||
-rw-r--r-- | tests/cxx/serializer/all/output | 1 | ||||
-rw-r--r-- | tests/cxx/serializer/all/test.xsd | 27 |
4 files changed, 208 insertions, 0 deletions
diff --git a/tests/cxx/serializer/all/driver.cxx b/tests/cxx/serializer/all/driver.cxx new file mode 100644 index 0000000..f781b94 --- /dev/null +++ b/tests/cxx/serializer/all/driver.cxx @@ -0,0 +1,108 @@ +// file : tests/cxx/serializer/all/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 the all compositor serialization. +// + +#include <iostream> + +#include "test-sskel.hxx" + +using namespace std; +using namespace test; + +struct test_1_simpl: test_1_sskel +{ + virtual int + a () + { + return 123; + } + + virtual bool + b_present () + { + return true; + } + + virtual int + b () + { + return 234; + } +}; + +struct test_2_simpl: test_2_sskel +{ + test_2_simpl () + : i_ (0) + { + } + + virtual bool + all_present () + { + return i_++; + } + + virtual int + a () + { + return 123; + } + + virtual int + b () + { + return 234; + } + +private: + int i_; +}; + +struct root_simpl: root_sskel +{ + virtual void + pre () + { + n1_ = 0; + n2_ = 0; + } + + virtual bool + test_1_next () + { + return n1_++ < 1; + } + + virtual bool + test_2_next () + { + return n2_++ < 2; + } + +private: + int n1_, n2_; +}; + +int +main () +{ + xml_schema::int_simpl int_s; + test_1_simpl test_1_s; + test_2_simpl test_2_s; + root_simpl root_s; + + test_1_s.serializers (int_s, int_s); + test_2_s.serializers (int_s, int_s); + root_s.serializers (test_1_s, test_2_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/all/makefile b/tests/cxx/serializer/all/makefile new file mode 100644 index 0000000..d73444a --- /dev/null +++ b/tests/cxx/serializer/all/makefile @@ -0,0 +1,72 @@ +# file : tests/cxx/serializer/all/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): $(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): $(out_root)/xsde/xsde + +$(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/all/output b/tests/cxx/serializer/all/output new file mode 100644 index 0000000..ec04b95 --- /dev/null +++ b/tests/cxx/serializer/all/output @@ -0,0 +1 @@ +<g1:root xmlns:g1="test"><test-1><a>123</a><b>234</b></test-1><test-2></test-2><test-2><a>123</a><b>234</b></test-2></g1:root>
\ No newline at end of file diff --git a/tests/cxx/serializer/all/test.xsd b/tests/cxx/serializer/all/test.xsd new file mode 100644 index 0000000..7d369f5 --- /dev/null +++ b/tests/cxx/serializer/all/test.xsd @@ -0,0 +1,27 @@ +<?xml version="1.0"?> +<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test"> + + <complexType name="test-1"> + <all> + <element name="a" type="int"/> + <element name="b" type="int" minOccurs="0"/> + </all> + </complexType> + + <complexType name="test-2"> + <all minOccurs="0"> + <element name="a" type="int"/> + <element name="b" type="int"/> + </all> + </complexType> + + <complexType name="root"> + <sequence> + <element name="test-1" type="t:test-1" maxOccurs="unbounded"/> + <element name="test-2" type="t:test-2" maxOccurs="unbounded"/> + </sequence> + </complexType> + + <element name="root" type="t:root"/> + +</schema> |