From 9db750f407ceeb5c1fab99414b074d289bfda179 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 11 Mar 2009 09:30:41 +0200 Subject: Add support for parsing/serialization of recursive types tests/cxx/hybrid/recursive/: new test --- tests/cxx/hybrid/makefile | 2 +- tests/cxx/hybrid/recursive/driver.cxx | 56 +++++++++++++++++ tests/cxx/hybrid/recursive/makefile | 98 +++++++++++++++++++++++++++++ tests/cxx/hybrid/recursive/output | 1 + tests/cxx/hybrid/recursive/test.xml | 25 ++++++++ tests/cxx/hybrid/recursive/test.xsd | 115 ++++++++++++++++++++++++++++++++++ 6 files changed, 296 insertions(+), 1 deletion(-) create mode 100644 tests/cxx/hybrid/recursive/driver.cxx create mode 100644 tests/cxx/hybrid/recursive/makefile create mode 100644 tests/cxx/hybrid/recursive/output create mode 100644 tests/cxx/hybrid/recursive/test.xml create mode 100644 tests/cxx/hybrid/recursive/test.xsd (limited to 'tests') diff --git a/tests/cxx/hybrid/makefile b/tests/cxx/hybrid/makefile index 84fed4c..2ea9a3d 100644 --- a/tests/cxx/hybrid/makefile +++ b/tests/cxx/hybrid/makefile @@ -8,7 +8,7 @@ include $(dir $(lastword $(MAKEFILE_LIST)))../../../build/bootstrap.make tests := sequences ifeq ($(xsde_iostream),y) -tests += built-in list test-template union +tests += built-in list recursive test-template union ifeq ($(xsde_cdr),y) tests += binary/cdr diff --git a/tests/cxx/hybrid/recursive/driver.cxx b/tests/cxx/hybrid/recursive/driver.cxx new file mode 100644 index 0000000..d3ce1c3 --- /dev/null +++ b/tests/cxx/hybrid/recursive/driver.cxx @@ -0,0 +1,56 @@ +// file : tests/cxx/hybrid/recursive/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test recursive parsing and serialization. +// + +#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/recursive/makefile b/tests/cxx/hybrid/recursive/makefile new file mode 100644 index 0000000..7c65294 --- /dev/null +++ b/tests/cxx/hybrid/recursive/makefile @@ -0,0 +1,98 @@ +# file : tests/cxx/hybrid/recursive/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) + +genf := $(xsd:.xsd=.hxx) $(xsd:.xsd=.cxx) \ + $(xsd:.xsd=-pskel.hxx) $(xsd:.xsd=-pskel.cxx) \ + $(xsd:.xsd=-pimpl.hxx) $(xsd:.xsd=-pimpl.cxx) \ + $(xsd:.xsd=-sskel.hxx) $(xsd:.xsd=-sskel.cxx) \ + $(xsd:.xsd=-simpl.hxx) $(xsd:.xsd=-simpl.cxx) + +gen := $(addprefix $(out_base)/,$(genf)) + +$(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)) + + +# Generated .gitignore. +# +ifeq ($(out_base),$(src_base)) +$(gen): | $(out_base)/.gitignore +$(driver): | $(out_base)/.gitignore + +$(out_base)/.gitignore: files := driver $(genf) +$(clean): $(out_base)/.gitignore.clean + +$(call include,$(bld_root)/git/gitignore.make) +endif + + +# 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/recursive/output b/tests/cxx/hybrid/recursive/output new file mode 100644 index 0000000..6b89789 --- /dev/null +++ b/tests/cxx/hybrid/recursive/output @@ -0,0 +1 @@ +123123123123123123123123123abca1123abca1456defb2123abca1456defb2789ghic3123abc123abc123abc123abc123abcdef123abcdefghi \ No newline at end of file diff --git a/tests/cxx/hybrid/recursive/test.xml b/tests/cxx/hybrid/recursive/test.xml new file mode 100644 index 0000000..4db2950 --- /dev/null +++ b/tests/cxx/hybrid/recursive/test.xml @@ -0,0 +1,25 @@ + + + 123 + 123 + 123 + + + 123 + 123 + 123 + 123123 + + 123abca1 + 123abca1456defb2 + 123abca1456defb2789ghic3 + + 123abc + 123abc + 123abc + + 123abc + 123abcdef + 123abcdefghi + + diff --git a/tests/cxx/hybrid/recursive/test.xsd b/tests/cxx/hybrid/recursive/test.xsd new file mode 100644 index 0000000..578bf8f --- /dev/null +++ b/tests/cxx/hybrid/recursive/test.xsd @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.1