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/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 +++++++++++++++++++++++++++++++++++++ 5 files changed, 390 insertions(+) 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 (limited to 'tests/cxx/hybrid/choice') 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.1