From 707cc94fe52463870a9c6c8e2e66eaaa389e601d Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 24 Feb 2009 15:16:26 +0200 Subject: Start tracking XSD/e with git after version 3.0.0 --- tests/cxx/hybrid/built-in/driver.cxx | 56 ++++ tests/cxx/hybrid/built-in/makefile | 88 ++++++ tests/cxx/hybrid/built-in/output | 5 + tests/cxx/hybrid/built-in/test.xml | 24 ++ tests/cxx/hybrid/built-in/test.xsd | 125 +++++++++ tests/cxx/hybrid/choice/driver.cxx | 70 +++++ tests/cxx/hybrid/choice/makefile | 88 ++++++ tests/cxx/hybrid/choice/output | 1 + tests/cxx/hybrid/choice/test.xml | 57 ++++ tests/cxx/hybrid/choice/test.xsd | 174 ++++++++++++ tests/cxx/hybrid/compositor/includee.xsd | 14 + tests/cxx/hybrid/compositor/includer.xsd | 14 + tests/cxx/hybrid/compositor/test.xsd | 186 +++++++++++++ tests/cxx/hybrid/compositor/tmp.xsd | 87 ++++++ tests/cxx/hybrid/file-per-type/a.xsd | 14 + tests/cxx/hybrid/file-per-type/b.xsd | 16 ++ tests/cxx/hybrid/file-per-type/test.xsd | 9 + tests/cxx/hybrid/list/driver.cxx | 56 ++++ tests/cxx/hybrid/list/makefile | 88 ++++++ tests/cxx/hybrid/list/output | 1 + tests/cxx/hybrid/list/test.xml | 8 + tests/cxx/hybrid/list/test.xsd | 35 +++ tests/cxx/hybrid/makefile | 29 ++ tests/cxx/hybrid/reorder/test.xsd | 26 ++ tests/cxx/hybrid/sequences/driver.cxx | 442 ++++++++++++++++++++++++++++++ tests/cxx/hybrid/sequences/makefile | 61 +++++ tests/cxx/hybrid/size/test.xsd | 136 +++++++++ tests/cxx/hybrid/test-template/driver.cxx | 56 ++++ tests/cxx/hybrid/test-template/makefile | 88 ++++++ tests/cxx/hybrid/test-template/output | 1 + tests/cxx/hybrid/test-template/test.xml | 5 + tests/cxx/hybrid/test-template/test.xsd | 12 + tests/cxx/hybrid/union/driver.cxx | 56 ++++ tests/cxx/hybrid/union/makefile | 88 ++++++ tests/cxx/hybrid/union/output | 1 + tests/cxx/hybrid/union/test.xml | 6 + tests/cxx/hybrid/union/test.xsd | 26 ++ 37 files changed, 2249 insertions(+) create mode 100644 tests/cxx/hybrid/built-in/driver.cxx create mode 100644 tests/cxx/hybrid/built-in/makefile create mode 100644 tests/cxx/hybrid/built-in/output create mode 100644 tests/cxx/hybrid/built-in/test.xml create mode 100644 tests/cxx/hybrid/built-in/test.xsd create mode 100644 tests/cxx/hybrid/choice/driver.cxx create mode 100644 tests/cxx/hybrid/choice/makefile create mode 100644 tests/cxx/hybrid/choice/output create mode 100644 tests/cxx/hybrid/choice/test.xml create mode 100644 tests/cxx/hybrid/choice/test.xsd create mode 100644 tests/cxx/hybrid/compositor/includee.xsd create mode 100644 tests/cxx/hybrid/compositor/includer.xsd create mode 100644 tests/cxx/hybrid/compositor/test.xsd create mode 100644 tests/cxx/hybrid/compositor/tmp.xsd create mode 100644 tests/cxx/hybrid/file-per-type/a.xsd create mode 100644 tests/cxx/hybrid/file-per-type/b.xsd create mode 100644 tests/cxx/hybrid/file-per-type/test.xsd create mode 100644 tests/cxx/hybrid/list/driver.cxx create mode 100644 tests/cxx/hybrid/list/makefile create mode 100644 tests/cxx/hybrid/list/output create mode 100644 tests/cxx/hybrid/list/test.xml create mode 100644 tests/cxx/hybrid/list/test.xsd create mode 100644 tests/cxx/hybrid/makefile create mode 100644 tests/cxx/hybrid/reorder/test.xsd create mode 100644 tests/cxx/hybrid/sequences/driver.cxx create mode 100644 tests/cxx/hybrid/sequences/makefile create mode 100644 tests/cxx/hybrid/size/test.xsd create mode 100644 tests/cxx/hybrid/test-template/driver.cxx create mode 100644 tests/cxx/hybrid/test-template/makefile create mode 100644 tests/cxx/hybrid/test-template/output create mode 100644 tests/cxx/hybrid/test-template/test.xml create mode 100644 tests/cxx/hybrid/test-template/test.xsd create mode 100644 tests/cxx/hybrid/union/driver.cxx create mode 100644 tests/cxx/hybrid/union/makefile create mode 100644 tests/cxx/hybrid/union/output create mode 100644 tests/cxx/hybrid/union/test.xml create mode 100644 tests/cxx/hybrid/union/test.xsd (limited to 'tests/cxx/hybrid') diff --git a/tests/cxx/hybrid/built-in/driver.cxx b/tests/cxx/hybrid/built-in/driver.cxx new file mode 100644 index 0000000..6204882 --- /dev/null +++ b/tests/cxx/hybrid/built-in/driver.cxx @@ -0,0 +1,56 @@ +// file : tests/cxx/hybrid/built-in/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test built-in types. +// + +#include + +#include "test.hxx" +#include "test-pimpl.hxx" +#include "test-simpl.hxx" + +using namespace std; +using namespace test; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + // Parse. + // + root_paggr root_p; + + xml_schema::document_pimpl doc_p ( + root_p.root_parser (), + root_p.root_namespace (), + root_p.root_name ()); + + root_p.pre (); + doc_p.parse (argv[1]); + type* r = root_p.post (); + + // Serialize. + // + root_saggr root_s; + + xml_schema::document_simpl doc_s ( + root_s.root_serializer (), + root_s.root_namespace (), + root_s.root_name ()); + + doc_s.add_prefix ("t", "test"); + + root_s.pre (*r); + doc_s.serialize (cout); + root_s.post (); + + delete r; +} diff --git a/tests/cxx/hybrid/built-in/makefile b/tests/cxx/hybrid/built-in/makefile new file mode 100644 index 0000000..c62315c --- /dev/null +++ b/tests/cxx/hybrid/built-in/makefile @@ -0,0 +1,88 @@ +# file : tests/cxx/hybrid/built-in/makefile +# author : Boris Kolpackov +# 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) \ +$(xsd:.xsd=-pskel.o) \ +$(xsd:.xsd=-pimpl.o) \ +$(xsd:.xsd=-sskel.o) \ +$(xsd:.xsd=-simpl.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) + +gen := $(out_base)/$(xsd:.xsd=.hxx) \ + $(out_base)/$(xsd:.xsd=.cxx) \ + $(out_base)/$(xsd:.xsd=-pskel.hxx) \ + $(out_base)/$(xsd:.xsd=-pskel.cxx) \ + $(out_base)/$(xsd:.xsd=-pimpl.hxx) \ + $(out_base)/$(xsd:.xsd=-pimpl.cxx) \ + $(out_base)/$(xsd:.xsd=-sskel.hxx) \ + $(out_base)/$(xsd:.xsd=-sskel.cxx) \ + $(out_base)/$(xsd:.xsd=-simpl.hxx) \ + $(out_base)/$(xsd:.xsd=-simpl.cxx) + +$(gen): $(out_root)/xsde/xsde +$(gen): xsde := $(out_root)/xsde/xsde +$(gen): xsde_options += --generate-parser --generate-serializer \ +--generate-aggregate + +$(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)/test.xml $(src_base)/output + $(call message,test $$1,$$1 $(src_base)/test.xml | diff -ubB $(src_base)/output -,$(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)/xsde/hybrid/xsd-cxx.make) + + +# Dependencies. +# +$(call import,$(src_root)/xsde/makefile) +$(call import,$(src_root)/libxsde/xsde/makefile) diff --git a/tests/cxx/hybrid/built-in/output b/tests/cxx/hybrid/built-in/output new file mode 100644 index 0000000..6798590 --- /dev/null +++ b/tests/cxx/hybrid/built-in/output @@ -0,0 +1,5 @@ +123abc123456789123YmFzZTY0IGJpbmFyeQ== +YmFzZTY0IGJpbmFyeQ== +YmFzZTY0IGJpbmFyeQ== +YmFzZTY0IGJpbmFyeQ== +abcdefghijkl \ No newline at end of file diff --git a/tests/cxx/hybrid/built-in/test.xml b/tests/cxx/hybrid/built-in/test.xml new file mode 100644 index 0000000..ae72e80 --- /dev/null +++ b/tests/cxx/hybrid/built-in/test.xml @@ -0,0 +1,24 @@ + + + + 123abc + + + + + 123 + 456 + 789 + 123 + + YmFzZTY0IGJpbmFyeQ== + YmFzZTY0IGJpbmFyeQ== + YmFzZTY0IGJpbmFyeQ== + YmFzZTY0IGJpbmFyeQ== + + abc + def + ghi + jkl + + diff --git a/tests/cxx/hybrid/built-in/test.xsd b/tests/cxx/hybrid/built-in/test.xsd new file mode 100644 index 0000000..1481d4f --- /dev/null +++ b/tests/cxx/hybrid/built-in/test.xsd @@ -0,0 +1,125 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/hybrid/choice/driver.cxx b/tests/cxx/hybrid/choice/driver.cxx new file mode 100644 index 0000000..0ba13de --- /dev/null +++ b/tests/cxx/hybrid/choice/driver.cxx @@ -0,0 +1,70 @@ +// file : tests/cxx/hybrid/choice/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test choice mapping. +// + +#include +#include + +#include "test.hxx" +#include "test-pimpl.hxx" +#include "test-simpl.hxx" + +using namespace std; +using namespace test; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + +#ifdef XSDE_STL + { + test1 x; + x.b ("foo"); + test1 y (x); + assert (y.b () == "foo"); + test1 z; + y.a (123); + z = y; + assert (z.a () == 123); + } +#endif + + // Parse. + // + root_paggr root_p; + + xml_schema::document_pimpl doc_p ( + root_p.root_parser (), + root_p.root_namespace (), + root_p.root_name ()); + + root_p.pre (); + doc_p.parse (argv[1]); + type* r = root_p.post (); + + // Serialize. + // + root_saggr root_s; + + xml_schema::document_simpl doc_s ( + root_s.root_serializer (), + root_s.root_namespace (), + root_s.root_name ()); + + doc_s.add_prefix ("t", "test"); + + root_s.pre (*r); + doc_s.serialize (cout); + root_s.post (); + + delete r; +} diff --git a/tests/cxx/hybrid/choice/makefile b/tests/cxx/hybrid/choice/makefile new file mode 100644 index 0000000..cd256ff --- /dev/null +++ b/tests/cxx/hybrid/choice/makefile @@ -0,0 +1,88 @@ +# file : tests/cxx/hybrid/choice/makefile +# author : Boris Kolpackov +# 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) \ +$(xsd:.xsd=-pskel.o) \ +$(xsd:.xsd=-pimpl.o) \ +$(xsd:.xsd=-sskel.o) \ +$(xsd:.xsd=-simpl.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) + +gen := $(out_base)/$(xsd:.xsd=.hxx) \ + $(out_base)/$(xsd:.xsd=.cxx) \ + $(out_base)/$(xsd:.xsd=-pskel.hxx) \ + $(out_base)/$(xsd:.xsd=-pskel.cxx) \ + $(out_base)/$(xsd:.xsd=-pimpl.hxx) \ + $(out_base)/$(xsd:.xsd=-pimpl.cxx) \ + $(out_base)/$(xsd:.xsd=-sskel.hxx) \ + $(out_base)/$(xsd:.xsd=-sskel.cxx) \ + $(out_base)/$(xsd:.xsd=-simpl.hxx) \ + $(out_base)/$(xsd:.xsd=-simpl.cxx) + +$(gen): $(out_root)/xsde/xsde +$(gen): xsde := $(out_root)/xsde/xsde +$(gen): xsde_options += --generate-parser --generate-serializer \ +--generate-aggregate + +$(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)/test.xml $(src_base)/output + $(call message,test $$1,$$1 $(src_base)/test.xml | diff -ubB $(src_base)/output -,$(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)/xsde/hybrid/xsd-cxx.make) + + +# Dependencies. +# +$(call import,$(src_root)/xsde/makefile) +$(call import,$(src_root)/libxsde/xsde/makefile) diff --git a/tests/cxx/hybrid/choice/output b/tests/cxx/hybrid/choice/output new file mode 100644 index 0000000..b299e90 --- /dev/null +++ b/tests/cxx/hybrid/choice/output @@ -0,0 +1 @@ +123abcdef1.23123truefalseabc1.231231.231231.231234.564561.23true1.23true123truefalseabc1.23true1231.23truefalseabctrue1.23true1.23true123truefalseabc1.23true1231.23truefalseabctruetruetrue \ No newline at end of file diff --git a/tests/cxx/hybrid/choice/test.xml b/tests/cxx/hybrid/choice/test.xml new file mode 100644 index 0000000..48f06fd --- /dev/null +++ b/tests/cxx/hybrid/choice/test.xml @@ -0,0 +1,57 @@ + + + + + 123 + + abcdef + + 1.23123 + + truefalseabc + + + + 1.23123 + 1.23123 + 1.231234.56456 + + + + + 1.23 + true + 1.23 + true + + + 123 + truefalseabc + 1.23 + true + 1231.23 + truefalseabctrue + + + + + 1.23 + true + 1.23 + true + 123 + truefalseabc + 1.23 + true + 1231.23 + truefalseabctrue + + + + + true + true + + + diff --git a/tests/cxx/hybrid/choice/test.xsd b/tests/cxx/hybrid/choice/test.xsd new file mode 100644 index 0000000..9fe5f5c --- /dev/null +++ b/tests/cxx/hybrid/choice/test.xsd @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/hybrid/compositor/includee.xsd b/tests/cxx/hybrid/compositor/includee.xsd new file mode 100644 index 0000000..1def761 --- /dev/null +++ b/tests/cxx/hybrid/compositor/includee.xsd @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/tests/cxx/hybrid/compositor/includer.xsd b/tests/cxx/hybrid/compositor/includer.xsd new file mode 100644 index 0000000..fc730e4 --- /dev/null +++ b/tests/cxx/hybrid/compositor/includer.xsd @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/tests/cxx/hybrid/compositor/test.xsd b/tests/cxx/hybrid/compositor/test.xsd new file mode 100644 index 0000000..3d1b1ce --- /dev/null +++ b/tests/cxx/hybrid/compositor/test.xsd @@ -0,0 +1,186 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/hybrid/compositor/tmp.xsd b/tests/cxx/hybrid/compositor/tmp.xsd new file mode 100644 index 0000000..fc3a4bd --- /dev/null +++ b/tests/cxx/hybrid/compositor/tmp.xsd @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/hybrid/file-per-type/a.xsd b/tests/cxx/hybrid/file-per-type/a.xsd new file mode 100644 index 0000000..9abe165 --- /dev/null +++ b/tests/cxx/hybrid/file-per-type/a.xsd @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/tests/cxx/hybrid/file-per-type/b.xsd b/tests/cxx/hybrid/file-per-type/b.xsd new file mode 100644 index 0000000..f10ad4c --- /dev/null +++ b/tests/cxx/hybrid/file-per-type/b.xsd @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/tests/cxx/hybrid/file-per-type/test.xsd b/tests/cxx/hybrid/file-per-type/test.xsd new file mode 100644 index 0000000..ebb2f23 --- /dev/null +++ b/tests/cxx/hybrid/file-per-type/test.xsd @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/tests/cxx/hybrid/list/driver.cxx b/tests/cxx/hybrid/list/driver.cxx new file mode 100644 index 0000000..5d6b20e --- /dev/null +++ b/tests/cxx/hybrid/list/driver.cxx @@ -0,0 +1,56 @@ +// file : tests/cxx/hybrid/list/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test list mapping. +// + +#include + +#include "test.hxx" +#include "test-pimpl.hxx" +#include "test-simpl.hxx" + +using namespace std; +using namespace test; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + // Parse. + // + root_paggr root_p; + + xml_schema::document_pimpl doc_p ( + root_p.root_parser (), + root_p.root_namespace (), + root_p.root_name ()); + + root_p.pre (); + doc_p.parse (argv[1]); + type* r = root_p.post (); + + // Serialize. + // + root_saggr root_s; + + xml_schema::document_simpl doc_s ( + root_s.root_serializer (), + root_s.root_namespace (), + root_s.root_name ()); + + doc_s.add_prefix ("t", "test"); + + root_s.pre (*r); + doc_s.serialize (cout); + root_s.post (); + + delete r; +} diff --git a/tests/cxx/hybrid/list/makefile b/tests/cxx/hybrid/list/makefile new file mode 100644 index 0000000..5d70a97 --- /dev/null +++ b/tests/cxx/hybrid/list/makefile @@ -0,0 +1,88 @@ +# file : tests/cxx/hybrid/list/makefile +# author : Boris Kolpackov +# 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) \ +$(xsd:.xsd=-pskel.o) \ +$(xsd:.xsd=-pimpl.o) \ +$(xsd:.xsd=-sskel.o) \ +$(xsd:.xsd=-simpl.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) + +gen := $(out_base)/$(xsd:.xsd=.hxx) \ + $(out_base)/$(xsd:.xsd=.cxx) \ + $(out_base)/$(xsd:.xsd=-pskel.hxx) \ + $(out_base)/$(xsd:.xsd=-pskel.cxx) \ + $(out_base)/$(xsd:.xsd=-pimpl.hxx) \ + $(out_base)/$(xsd:.xsd=-pimpl.cxx) \ + $(out_base)/$(xsd:.xsd=-sskel.hxx) \ + $(out_base)/$(xsd:.xsd=-sskel.cxx) \ + $(out_base)/$(xsd:.xsd=-simpl.hxx) \ + $(out_base)/$(xsd:.xsd=-simpl.cxx) + +$(gen): $(out_root)/xsde/xsde +$(gen): xsde := $(out_root)/xsde/xsde +$(gen): xsde_options += --generate-parser --generate-serializer \ +--generate-aggregate + +$(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)/test.xml $(src_base)/output + $(call message,test $$1,$$1 $(src_base)/test.xml | diff -ubB $(src_base)/output -,$(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)/xsde/hybrid/xsd-cxx.make) + + +# Dependencies. +# +$(call import,$(src_root)/xsde/makefile) +$(call import,$(src_root)/libxsde/xsde/makefile) diff --git a/tests/cxx/hybrid/list/output b/tests/cxx/hybrid/list/output new file mode 100644 index 0000000..6c1ac43 --- /dev/null +++ b/tests/cxx/hybrid/list/output @@ -0,0 +1 @@ +123 456 789one t:two threeabc def ghiabc def ghi \ No newline at end of file diff --git a/tests/cxx/hybrid/list/test.xml b/tests/cxx/hybrid/list/test.xml new file mode 100644 index 0000000..2451a4b --- /dev/null +++ b/tests/cxx/hybrid/list/test.xml @@ -0,0 +1,8 @@ + + + 123 456 789 + one t:two three + abc def ghi + abc def ghi + + diff --git a/tests/cxx/hybrid/list/test.xsd b/tests/cxx/hybrid/list/test.xsd new file mode 100644 index 0000000..d864b12 --- /dev/null +++ b/tests/cxx/hybrid/list/test.xsd @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/hybrid/makefile b/tests/cxx/hybrid/makefile new file mode 100644 index 0000000..3351241 --- /dev/null +++ b/tests/cxx/hybrid/makefile @@ -0,0 +1,29 @@ +# file : tests/cxx/hybrid/makefile +# author : Boris Kolpackov +# 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 + +tests := sequences + +ifeq ($(xsde_iostream),y) +tests += built-in list test-template union + +ifeq ($(xsde_parser_validation),y) +tests += choice +endif + +endif + +default := $(out_base)/ +test := $(out_base)/.test +clean := $(out_base)/.clean + +.PHONY: $(default) $(test) $(clean) + +$(default): $(addprefix $(out_base)/,$(addsuffix /,$(tests))) +$(test): $(addprefix $(out_base)/,$(addsuffix /.test,$(tests))) +$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(tests))) + +$(foreach t,$(tests),$(call import,$(src_base)/$t/makefile)) diff --git a/tests/cxx/hybrid/reorder/test.xsd b/tests/cxx/hybrid/reorder/test.xsd new file mode 100644 index 0000000..1b610cc --- /dev/null +++ b/tests/cxx/hybrid/reorder/test.xsd @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/hybrid/sequences/driver.cxx b/tests/cxx/hybrid/sequences/driver.cxx new file mode 100644 index 0000000..3d6c702 --- /dev/null +++ b/tests/cxx/hybrid/sequences/driver.cxx @@ -0,0 +1,442 @@ +// file : tests/cxx/hybrid/sequences/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test sequence templates. +// +#include +#include + +#include + +#ifndef XSDE_STL +#include +#endif + +#include + +using std::string; +using namespace xsde::cxx::hybrid; + +void data_destructor (void* p, size_t) +{ + delete static_cast (p); +} + +void data_destructor_pos (void* p, size_t i) +{ + switch (i) + { + case 0: + { + delete static_cast (p); + break; + } + case 1: + { + delete static_cast (p); + break; + } + } +} + +int +main () +{ + // + // pod_seq + // + typedef pod_seq pod; + + { + pod s; + s.push_back (111); + assert (s.size () == 1 && s[0] == 111); + s.pop_back (); + assert (s.size () == 0); + } + + { + pod s; + s.push_back (111); + s.erase (s.begin ()); + assert (s.size () == 0); + + s.push_back (111); + s.push_back (222); + s.push_back (333); + s.erase (s.begin ()); + assert (s.size () == 2 && s[0] == 222 && s[1] == 333); + + s.push_back (444); + s.erase (s.begin () + 1); + assert (s.size () == 2 && s[0] == 222 && s[1] == 444); + + s.push_back (555); + s.erase (s.begin () + 2); + assert (s.size () == 2 && s[0] == 222 && s[1] == 444); + } + + { + pod s; + s.reserve (2); + s.push_back (111); + s.push_back (222); + s.push_back (333); + assert (s.size () == 3 && s[0] == 111 && s[1] == 222 && s[2] == 333); + } + + { + pod s; + s.insert (s.begin (), 111); + assert (s.size () == 1 && s[0] == 111); + s.push_back (222); + s.push_back (333); + + s.insert (s.begin (), 444); + assert (s[0] == 444); + + s.insert (s.begin () + 1, 555); + assert (s[1] == 555); + + s.insert (s.end (), 666); + assert (s[5] == 666); + + assert (s[0] == 444 && s[1] == 555 && s[2] == 111 && + s[3] == 222 && s[4] == 333 && s[5] == 666); + } + + { + pod s; + s.reserve (2); + s.push_back (111); + s.push_back (222); + s.insert (s.begin () + 1, 333); + assert (s[0] == 111 && s[1] == 333 && s[2] == 222); + } + + // + // fix_seq + // + typedef fix_seq fix; + + { + fix s; + s.push_back ("aaa"); + assert (s.size () == 1 && s[0] == "aaa"); + s.pop_back (); + assert (s.size () == 0); + } + + { + fix s; + s.push_back ("aaa"); + s.erase (s.begin ()); + assert (s.size () == 0); + + s.push_back ("aaa"); + s.push_back ("bbb"); + s.push_back ("ccc"); + s.erase (s.begin ()); + assert (s.size () == 2 && s[0] == "bbb" && s[1] == "ccc"); + + s.push_back ("ddd"); + s.erase (s.begin () + 1); + assert (s.size () == 2 && s[0] == "bbb" && s[1] == "ddd"); + + s.push_back ("eee"); + s.erase (s.begin () + 2); + assert (s.size () == 2 && s[0] == "bbb" && s[1] == "ddd"); + } + + { + fix s; + s.reserve (2); + s.push_back ("aaa"); + s.push_back ("bbb"); + s.push_back ("ccc"); + assert (s.size () == 3 && s[0] == "aaa" && + s[1] == "bbb" && s[2] == "ccc"); + } + + { + fix s; + s.insert (s.begin (), "aaa"); + assert (s.size () == 1 && s[0] == "aaa"); + s.push_back ("bbb"); + s.push_back ("ccc"); + + s.insert (s.begin (), "ddd"); + assert (s[0] == "ddd"); + + s.insert (s.begin () + 1, "eee"); + assert (s[1] == "eee"); + + s.insert (s.end (), "fff"); + assert (s[5] == "fff"); + + assert (s[0] == "ddd" && s[1] == "eee" && s[2] == "aaa" && + s[3] == "bbb" && s[4] == "ccc" && s[5] == "fff"); + } + + { + fix s; + s.reserve (2); + s.push_back ("aaa"); + s.push_back ("bbb"); + s.insert (s.begin () + 1, "ccc"); + assert (s[0] == "aaa" && s[1] == "ccc" && s[2] == "bbb"); + } + + // + // var_seq + // + typedef var_seq var; + + { + var s; + s.push_back (new string ("aaa")); + assert (s.size () == 1 && s[0] == "aaa"); + s.pop_back (); + assert (s.size () == 0); + } + + { + var s; + s.push_back (new string ("aaa")); + s.erase (s.begin ()); + assert (s.size () == 0); + + s.push_back (new string ("aaa")); + s.push_back (new string ("bbb")); + s.push_back (new string ("ccc")); + s.erase (s.begin ()); + assert (s.size () == 2 && s[0] == "bbb" && s[1] == "ccc"); + + s.push_back (new string ("ddd")); + s.erase (s.begin () + 1); + assert (s.size () == 2 && s[0] == "bbb" && s[1] == "ddd"); + + s.push_back (new string ("eee")); + s.erase (s.begin () + 2); + assert (s.size () == 2 && s[0] == "bbb" && s[1] == "ddd"); + } + + { + var s; + s.reserve (2); + s.push_back (new string ("aaa")); + s.push_back (new string ("bbb")); + s.push_back (new string ("ccc")); + assert (s.size () == 3 && s[0] == "aaa" && + s[1] == "bbb" && s[2] == "ccc"); + } + + { + var s; + s.insert (s.begin (), new string ("aaa")); + assert (s.size () == 1 && s[0] == "aaa"); + s.push_back (new string ("bbb")); + s.push_back (new string ("ccc")); + + s.insert (s.begin (), new string ("ddd")); + assert (s[0] == "ddd"); + + s.insert (s.begin () + 1, new string ("eee")); + assert (s[1] == "eee"); + + s.insert (s.end (), new string ("fff")); + assert (s[5] == "fff"); + + assert (s[0] == "ddd" && s[1] == "eee" && s[2] == "aaa" && + s[3] == "bbb" && s[4] == "ccc" && s[5] == "fff"); + } + + { + var s; + s.reserve (2); + s.push_back (new string ("aaa")); + s.push_back (new string ("bbb")); + s.insert (s.begin () + 1, new string ("ccc")); + assert (s[0] == "aaa" && s[1] == "ccc" && s[2] == "bbb"); + } + + // + // str_seq + // + typedef str_seq str; + +#ifndef XSDE_STL + using xsde::cxx::strdupx; + + { + str s; + s.push_back (strdupx ("aaa")); + assert (s.size () == 1 && s[0] == string ("aaa")); + s.pop_back (); + assert (s.size () == 0); + } + + { + str s; + s.push_back_copy ("aaa"); + s.erase (s.begin ()); + assert (s.size () == 0); + + s.push_back_copy ("aaa"); + s.push_back_copy ("bbb"); + s.push_back_copy ("ccc"); + s.erase (s.begin ()); + assert (s.size () == 2 && + s[0] == string ("bbb") && s[1] == string ("ccc")); + + s.push_back_copy ("ddd"); + s.erase (s.begin () + 1); + assert (s.size () == 2 && + s[0] == string ("bbb") && s[1] == string ("ddd")); + + s.push_back_copy ("eee"); + s.erase (s.begin () + 2); + assert (s.size () == 2 && + s[0] == string ("bbb") && s[1] == string ("ddd")); + } + + { + str s; + s.reserve (2); + s.push_back_copy ("aaa"); + s.push_back_copy ("bbb"); + s.push_back_copy ("ccc"); + assert (s.size () == 3 && + s[0] == string ("aaa") && + s[1] == string ("bbb") && + s[2] == string ("ccc")); + } + + { + str s; + s.insert (s.begin (), strdupx ("aaa")); + assert (s.size () == 1 && s[0] == string ("aaa")); + s.push_back_copy ("bbb"); + s.push_back_copy ("ccc"); + + s.insert (s.begin (), strdupx ("ddd")); + assert (s[0] == string ("ddd")); + + s.insert (s.begin () + 1, strdupx ("eee")); + assert (s[1] == string ("eee")); + + s.insert (s.end (), strdupx ("fff")); + assert (s[5] == string ("fff")); + + assert (s[0] == string ("ddd") && s[1] == string ("eee") && + s[2] == string ("aaa") && s[3] == string ("bbb") && + s[4] == string ("ccc") && s[5] == string ("fff")); + } + + { + str s; + s.reserve (2); + s.push_back_copy ("aaa"); + s.push_back_copy ("bbb"); + s.insert (s.begin () + 1, strdupx ("ccc")); + assert (s[0] == string ("aaa") && + s[1] == string ("ccc") && + s[2] == string ("bbb")); + } + +#else + + { + str s; + s.push_back ("aaa"); + assert (s.size () == 1 && s[0] == "aaa"); + s.pop_back (); + assert (s.size () == 0); + } + + { + str s; + s.push_back ("aaa"); + s.erase (s.begin ()); + assert (s.size () == 0); + + s.push_back ("aaa"); + s.push_back ("bbb"); + s.push_back ("ccc"); + s.erase (s.begin ()); + assert (s.size () == 2 && s[0] == "bbb" && s[1] == "ccc"); + + s.push_back ("ddd"); + s.erase (s.begin () + 1); + assert (s.size () == 2 && s[0] == "bbb" && s[1] == "ddd"); + + s.push_back ("eee"); + s.erase (s.begin () + 2); + assert (s.size () == 2 && s[0] == "bbb" && s[1] == "ddd"); + } + + { + str s; + s.reserve (2); + s.push_back ("aaa"); + s.push_back ("bbb"); + s.push_back ("ccc"); + assert (s.size () == 3 && + s[0] == "aaa" && s[1] == "bbb" && s[2] == "ccc"); + } + + { + str s; + s.insert (s.begin (), "aaa"); + assert (s.size () == 1 && s[0] == "aaa"); + s.push_back ("bbb"); + s.push_back ("ccc"); + + s.insert (s.begin (), "ddd"); + assert (s[0] == "ddd"); + + s.insert (s.begin () + 1, "eee"); + assert (s[1] == "eee"); + + s.insert (s.end (), "fff"); + assert (s[5] == "fff"); + + assert (s[0] == "ddd" && s[1] == "eee" && s[2] == "aaa" && + s[3] == "bbb" && s[4] == "ccc" && s[5] == "fff"); + } + + { + str s; + s.reserve (2); + s.push_back ("aaa"); + s.push_back ("bbb"); + s.insert (s.begin () + 1, "ccc"); + assert (s[0] == "aaa" && s[1] == "ccc" && s[2] == "bbb"); + } +#endif + + // + // data_seq + // + typedef data_seq data; + + { + data s; + s.destructor (&data_destructor); + s.push_back (new string ("aaa")); + s.push_back (new string ("bbb")); + assert (*static_cast (s[0]) == "aaa" && + *static_cast (s[1]) == "bbb"); + } + + { + data s; + s.destructor (&data_destructor_pos); + s.push_back (new string ("aaa")); + s.push_back (new int (5)); + assert (*static_cast (s[0]) == "aaa" && + *static_cast (s[1]) == 5); + } +} diff --git a/tests/cxx/hybrid/sequences/makefile b/tests/cxx/hybrid/sequences/makefile new file mode 100644 index 0000000..41f5941 --- /dev/null +++ b/tests/cxx/hybrid/sequences/makefile @@ -0,0 +1,61 @@ +# file : tests/cxx/hybrid/sequences/makefile +# author : Boris Kolpackov +# 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 + +cxx := driver.cxx + +obj := $(addprefix $(out_base)/,$(cxx:.cxx=.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) + +$(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)) + + +# 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) + + +# Dependencies. +# +$(call import,$(src_root)/libxsde/xsde/makefile) diff --git a/tests/cxx/hybrid/size/test.xsd b/tests/cxx/hybrid/size/test.xsd new file mode 100644 index 0000000..e8e265d --- /dev/null +++ b/tests/cxx/hybrid/size/test.xsd @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/hybrid/test-template/driver.cxx b/tests/cxx/hybrid/test-template/driver.cxx new file mode 100644 index 0000000..c482a0c --- /dev/null +++ b/tests/cxx/hybrid/test-template/driver.cxx @@ -0,0 +1,56 @@ +// file : tests/cxx/hybrid/test-template/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Insert test description here. +// + +#include + +#include "test.hxx" +#include "test-pimpl.hxx" +#include "test-simpl.hxx" + +using namespace std; +using namespace test; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + // Parse. + // + root_paggr root_p; + + xml_schema::document_pimpl doc_p ( + root_p.root_parser (), + root_p.root_namespace (), + root_p.root_name ()); + + root_p.pre (); + doc_p.parse (argv[1]); + type* r = root_p.post (); + + // Serialize. + // + root_saggr root_s; + + xml_schema::document_simpl doc_s ( + root_s.root_serializer (), + root_s.root_namespace (), + root_s.root_name ()); + + doc_s.add_prefix ("t", "test"); + + root_s.pre (*r); + doc_s.serialize (cout); + root_s.post (); + + delete r; +} diff --git a/tests/cxx/hybrid/test-template/makefile b/tests/cxx/hybrid/test-template/makefile new file mode 100644 index 0000000..2a73ad9 --- /dev/null +++ b/tests/cxx/hybrid/test-template/makefile @@ -0,0 +1,88 @@ +# file : tests/cxx/hybrid/test-template/makefile +# author : Boris Kolpackov +# 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) \ +$(xsd:.xsd=-pskel.o) \ +$(xsd:.xsd=-pimpl.o) \ +$(xsd:.xsd=-sskel.o) \ +$(xsd:.xsd=-simpl.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) + +gen := $(out_base)/$(xsd:.xsd=.hxx) \ + $(out_base)/$(xsd:.xsd=.cxx) \ + $(out_base)/$(xsd:.xsd=-pskel.hxx) \ + $(out_base)/$(xsd:.xsd=-pskel.cxx) \ + $(out_base)/$(xsd:.xsd=-pimpl.hxx) \ + $(out_base)/$(xsd:.xsd=-pimpl.cxx) \ + $(out_base)/$(xsd:.xsd=-sskel.hxx) \ + $(out_base)/$(xsd:.xsd=-sskel.cxx) \ + $(out_base)/$(xsd:.xsd=-simpl.hxx) \ + $(out_base)/$(xsd:.xsd=-simpl.cxx) + +$(gen): $(out_root)/xsde/xsde +$(gen): xsde := $(out_root)/xsde/xsde +$(gen): xsde_options += --generate-parser --generate-serializer \ +--generate-aggregate + +$(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)/test.xml $(src_base)/output + $(call message,test $$1,$$1 $(src_base)/test.xml | diff -ubB $(src_base)/output -,$(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)/xsde/hybrid/xsd-cxx.make) + + +# Dependencies. +# +$(call import,$(src_root)/xsde/makefile) +$(call import,$(src_root)/libxsde/xsde/makefile) diff --git a/tests/cxx/hybrid/test-template/output b/tests/cxx/hybrid/test-template/output new file mode 100644 index 0000000..66261f6 --- /dev/null +++ b/tests/cxx/hybrid/test-template/output @@ -0,0 +1 @@ +123 \ No newline at end of file diff --git a/tests/cxx/hybrid/test-template/test.xml b/tests/cxx/hybrid/test-template/test.xml new file mode 100644 index 0000000..1b7571e --- /dev/null +++ b/tests/cxx/hybrid/test-template/test.xml @@ -0,0 +1,5 @@ + + + 123 + + diff --git a/tests/cxx/hybrid/test-template/test.xsd b/tests/cxx/hybrid/test-template/test.xsd new file mode 100644 index 0000000..e0a9be1 --- /dev/null +++ b/tests/cxx/hybrid/test-template/test.xsd @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/tests/cxx/hybrid/union/driver.cxx b/tests/cxx/hybrid/union/driver.cxx new file mode 100644 index 0000000..286bf14 --- /dev/null +++ b/tests/cxx/hybrid/union/driver.cxx @@ -0,0 +1,56 @@ +// file : tests/cxx/hybrid/union/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test union mapping. +// + +#include + +#include "test.hxx" +#include "test-pimpl.hxx" +#include "test-simpl.hxx" + +using namespace std; +using namespace test; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + // Parse. + // + root_paggr root_p; + + xml_schema::document_pimpl doc_p ( + root_p.root_parser (), + root_p.root_namespace (), + root_p.root_name ()); + + root_p.pre (); + doc_p.parse (argv[1]); + type* r = root_p.post (); + + // Serialize. + // + root_saggr root_s; + + xml_schema::document_simpl doc_s ( + root_s.root_serializer (), + root_s.root_namespace (), + root_s.root_name ()); + + doc_s.add_prefix ("t", "test"); + + root_s.pre (*r); + doc_s.serialize (cout); + root_s.post (); + + delete r; +} diff --git a/tests/cxx/hybrid/union/makefile b/tests/cxx/hybrid/union/makefile new file mode 100644 index 0000000..5c1289c --- /dev/null +++ b/tests/cxx/hybrid/union/makefile @@ -0,0 +1,88 @@ +# file : tests/cxx/hybrid/union/makefile +# author : Boris Kolpackov +# 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) \ +$(xsd:.xsd=-pskel.o) \ +$(xsd:.xsd=-pimpl.o) \ +$(xsd:.xsd=-sskel.o) \ +$(xsd:.xsd=-simpl.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) + +gen := $(out_base)/$(xsd:.xsd=.hxx) \ + $(out_base)/$(xsd:.xsd=.cxx) \ + $(out_base)/$(xsd:.xsd=-pskel.hxx) \ + $(out_base)/$(xsd:.xsd=-pskel.cxx) \ + $(out_base)/$(xsd:.xsd=-pimpl.hxx) \ + $(out_base)/$(xsd:.xsd=-pimpl.cxx) \ + $(out_base)/$(xsd:.xsd=-sskel.hxx) \ + $(out_base)/$(xsd:.xsd=-sskel.cxx) \ + $(out_base)/$(xsd:.xsd=-simpl.hxx) \ + $(out_base)/$(xsd:.xsd=-simpl.cxx) + +$(gen): $(out_root)/xsde/xsde +$(gen): xsde := $(out_root)/xsde/xsde +$(gen): xsde_options += --generate-parser --generate-serializer \ +--generate-aggregate + +$(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)/test.xml $(src_base)/output + $(call message,test $$1,$$1 $(src_base)/test.xml | diff -ubB $(src_base)/output -,$(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)/xsde/hybrid/xsd-cxx.make) + + +# Dependencies. +# +$(call import,$(src_root)/xsde/makefile) +$(call import,$(src_root)/libxsde/xsde/makefile) diff --git a/tests/cxx/hybrid/union/output b/tests/cxx/hybrid/union/output new file mode 100644 index 0000000..9748083 --- /dev/null +++ b/tests/cxx/hybrid/union/output @@ -0,0 +1 @@ +123one \ No newline at end of file diff --git a/tests/cxx/hybrid/union/test.xml b/tests/cxx/hybrid/union/test.xml new file mode 100644 index 0000000..a2218b2 --- /dev/null +++ b/tests/cxx/hybrid/union/test.xml @@ -0,0 +1,6 @@ + + + 123 + one + + diff --git a/tests/cxx/hybrid/union/test.xsd b/tests/cxx/hybrid/union/test.xsd new file mode 100644 index 0000000..60a8d21 --- /dev/null +++ b/tests/cxx/hybrid/union/test.xsd @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.1