From 9553149aa6b6561c49981adf2848607a43765054 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 11 Oct 2010 12:43:48 +0200 Subject: Support for validation of the pattern facet New test: hybrid/pattern. --- tests/cxx/hybrid/makefile | 4 +- tests/cxx/hybrid/pattern/driver.cxx | 56 ++++++++++++++++++ tests/cxx/hybrid/pattern/makefile | 108 ++++++++++++++++++++++++++++++++++ tests/cxx/hybrid/pattern/test-000.std | 11 ++++ tests/cxx/hybrid/pattern/test-000.xml | 13 ++++ tests/cxx/hybrid/pattern/test.xsd | 53 +++++++++++++++++ 6 files changed, 243 insertions(+), 2 deletions(-) create mode 100644 tests/cxx/hybrid/pattern/driver.cxx create mode 100644 tests/cxx/hybrid/pattern/makefile create mode 100644 tests/cxx/hybrid/pattern/test-000.std create mode 100644 tests/cxx/hybrid/pattern/test-000.xml create mode 100644 tests/cxx/hybrid/pattern/test.xsd (limited to 'tests') diff --git a/tests/cxx/hybrid/makefile b/tests/cxx/hybrid/makefile index cef5ffc..af610f5 100644 --- a/tests/cxx/hybrid/makefile +++ b/tests/cxx/hybrid/makefile @@ -11,7 +11,7 @@ include $(dir $(lastword $(MAKEFILE_LIST)))../../../build/bootstrap.make all_tests := sequences polymorphism iterator built-in default enumeration \ iso8859-1 list recursive test-template union binary/cdr binary/xdr choice \ -clone +clone pattern build_tests := sequences @@ -26,7 +26,7 @@ endif endif ifeq ($(xsde_iostream),y) -build_tests += built-in default enumeration list test-template union +build_tests += built-in default enumeration list test-template union pattern ifeq ($(xsde_encoding),iso8859-1) build_tests += iso8859-1 diff --git a/tests/cxx/hybrid/pattern/driver.cxx b/tests/cxx/hybrid/pattern/driver.cxx new file mode 100644 index 0000000..b9d8663 --- /dev/null +++ b/tests/cxx/hybrid/pattern/driver.cxx @@ -0,0 +1,56 @@ +// file : tests/cxx/hybrid/pattern/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the pattern facet validation. +// + +#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, xml_schema::document_simpl::pretty_print); + root_s.post (); + + delete r; +} diff --git a/tests/cxx/hybrid/pattern/makefile b/tests/cxx/hybrid/pattern/makefile new file mode 100644 index 0000000..8313805 --- /dev/null +++ b/tests/cxx/hybrid/pattern/makefile @@ -0,0 +1,108 @@ +# file : tests/cxx/hybrid/pattern/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2010 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 +dist := $(out_base)/.dist +dist-win := $(out_base)/.dist-win +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) $(dist) $(dist-win): xsde_options += --generate-parser \ +--generate-serializer --generate-aggregate + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +$(out_base)/: $(driver) + + +# Test. +# +$(test): driver := $(driver) +$(test): $(driver) $(src_base)/test-000.xml $(src_base)/test-000.std + $(call message,test $$1,$$1 $(src_base)/test-000.xml | diff -u $(src_base)/test-000.std -,$(driver)) + + +# Dist. +# +$(dist) $(dist-win): opt := -src $(src_base) -cmd cxx-hybrid -xsd "$(xsd)" \ +-cxx "$(cxx)" -gen "$(genf)" -opt "$(xsde_options)" -out $(dist_prefix) + +$(dist): + $(call message,install $(src_base),$(scf_root)/dist $(opt)) + +$(dist-win): + $(call message,install $(src_base),$(scf_root)/dist -win $(opt)) + + +# 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/pattern/test-000.std b/tests/cxx/hybrid/pattern/test-000.std new file mode 100644 index 0000000..7b0d83a --- /dev/null +++ b/tests/cxx/hybrid/pattern/test-000.std @@ -0,0 +1,11 @@ + + foobarbaz + 12,32,123,321, + 12321 + 12321 + + + + + abcdef + \ No newline at end of file diff --git a/tests/cxx/hybrid/pattern/test-000.xml b/tests/cxx/hybrid/pattern/test-000.xml new file mode 100644 index 0000000..d503cb1 --- /dev/null +++ b/tests/cxx/hybrid/pattern/test-000.xml @@ -0,0 +1,13 @@ + + + foobarbaz + 12,32,123,321, + 12321 + 12321 + + + + + abcdef + + diff --git a/tests/cxx/hybrid/pattern/test.xsd b/tests/cxx/hybrid/pattern/test.xsd new file mode 100644 index 0000000..e008709 --- /dev/null +++ b/tests/cxx/hybrid/pattern/test.xsd @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.1