From f0510d2f90467de8e8f260b47d79a9baaf9bef17 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 17 Sep 2009 07:15:29 +0200 Subject: Start tracking XSD with git --- tests/cxx/parser/validation/any/driver.cxx | 123 +++++++++++++++++++++++++++ tests/cxx/parser/validation/any/makefile | 85 ++++++++++++++++++ tests/cxx/parser/validation/any/test-000.std | 29 +++++++ tests/cxx/parser/validation/any/test-000.xml | 21 +++++ tests/cxx/parser/validation/any/test.xsd | 20 +++++ 5 files changed, 278 insertions(+) create mode 100644 tests/cxx/parser/validation/any/driver.cxx create mode 100644 tests/cxx/parser/validation/any/makefile create mode 100644 tests/cxx/parser/validation/any/test-000.std create mode 100644 tests/cxx/parser/validation/any/test-000.xml create mode 100644 tests/cxx/parser/validation/any/test.xsd (limited to 'tests/cxx/parser/validation/any') diff --git a/tests/cxx/parser/validation/any/driver.cxx b/tests/cxx/parser/validation/any/driver.cxx new file mode 100644 index 0000000..956bc7a --- /dev/null +++ b/tests/cxx/parser/validation/any/driver.cxx @@ -0,0 +1,123 @@ +// file : tests/cxx/parser/validation/any/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the any particle validation. +// + +#include +#include +#include + +#include "test-pskel.hxx" + +using namespace std; +using namespace test; +using xml_schema::ro_string; + +struct any_a_pimpl: any_a_pskel +{ + virtual void + pre () + { + cout << "{" << endl; + } + + virtual void + a (string const& v) + { + cout << " a = " << v << endl; + } + + virtual void + x (string const& v) + { + cout << " x = " << v << endl; + } + + virtual void + _start_any_element (ro_string const&, + ro_string const& n, + ro_string const*) + { + cout << " start any element '" << n << "'" << endl; + } + + virtual void + _end_any_element (ro_string const&, ro_string const& n) + { + cout << " end any element '" << n << "'" << endl; + } + + virtual void + _any_attribute (ro_string const&, + ro_string const& n, + ro_string const& v) + { + cout << " any attribute " << n << " = '" << v << "'" << endl; + } + + virtual void + _any_characters (ro_string const& s) + { + cout << " any text: '" << s << "'" << endl; + } + + virtual void + post_any_a () + { + cout << "}" << endl + << endl; + } +}; + +struct type_pimpl: type_pskel +{ +}; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + xml_schema::string_pimpl string_p; + any_a_pimpl any_a_p; + type_pimpl type_p; + + any_a_p.parsers (string_p, string_p); + type_p.parsers (any_a_p); + + xml_schema::document doc_p (type_p, "test", "root"); + + try + { + ifstream ifs (argv[1]); + type_p.pre (); + doc_p.parse (ifs, argv[1], "", xml_schema::flags::dont_validate); + type_p.post_type (); + } + catch (xml_schema::exception const& e) + { + cout << " " << e << endl + << "}" << endl + << endl; + } + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + catch (ios_base::failure const&) + { + cerr << "io failure" << endl; + return 1; + } +} diff --git a/tests/cxx/parser/validation/any/makefile b/tests/cxx/parser/validation/any/makefile new file mode 100644 index 0000000..76d8618 --- /dev/null +++ b/tests/cxx/parser/validation/any/makefile @@ -0,0 +1,85 @@ +# file : tests/cxx/parser/validation/any/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 + +tests := 000 + +obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=-pskel.o)) +dep := $(obj:.o=.o.d) + +driver := $(out_base)/driver +test := $(out_base)/.test +clean := $(out_base)/.clean + +# Import. +# +$(call import,\ + $(scf_root)/import/libxerces-c/stub.make,\ + l: xerces_c.l,cpp-options: xerces_c.l.cpp-options) + +# Build. +# +$(driver): $(obj) $(xerces_c.l) + +$(obj) $(dep): cpp_options := -I$(src_root)/libxsd +$(obj) $(dep): $(xerces_c.l.cpp-options) + +skel := $(out_base)/$(xsd:.xsd=-pskel.hxx) \ + $(out_base)/$(xsd:.xsd=-pskel.ixx) \ + $(out_base)/$(xsd:.xsd=-pskel.cxx) + +$(skel): xsd := $(out_root)/xsd/xsd +$(skel): xsd_options := --generate-validation +$(skel): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +test_targets := $(addprefix $(out_base)/.test-,$(tests)) + +.PHONY: $(test) +$(test): $(test_targets) + + +$(test_targets): driver := $(driver) + +.PHONY: $(out_base)/.test-% +$(out_base)/.test-%: $(driver) $(src_base)/test.xsd $(src_base)/test-%.xml $(src_base)/test-%.std + $(call message,test $(out_base)/$*,$(driver) $(src_base)/test-$*.xml | diff -u $(src_base)/test-$*.std -) + + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=-pskel.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)/xsd/parser/xsd-cxx.make) + + +# Dependencies. +# +$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/parser/validation/any/test-000.std b/tests/cxx/parser/validation/any/test-000.std new file mode 100644 index 0000000..a1cc6e3 --- /dev/null +++ b/tests/cxx/parser/validation/any/test-000.std @@ -0,0 +1,29 @@ +{ + start any element 'any' + end any element 'any' +} + +{ + start any element 'any' + any attribute x = 'xxx' + any text: 'aaa' + start any element 'a' + any text: 'bbb' + end any element 'a' + any text: 'ccc' + end any element 'any' +} + +{ + x = x + a = a + start any element 'any' + any attribute x = 'xxx' + any text: 'aaa' + start any element 'a' + any text: 'bbb' + end any element 'a' + any text: 'ccc' + end any element 'any' +} + diff --git a/tests/cxx/parser/validation/any/test-000.xml b/tests/cxx/parser/validation/any/test-000.xml new file mode 100644 index 0000000..f1a0c83 --- /dev/null +++ b/tests/cxx/parser/validation/any/test-000.xml @@ -0,0 +1,21 @@ + + + + + + + + + + aaabbbccc + + + + a + aaabbbccc + + + diff --git a/tests/cxx/parser/validation/any/test.xsd b/tests/cxx/parser/validation/any/test.xsd new file mode 100644 index 0000000..c05aeb5 --- /dev/null +++ b/tests/cxx/parser/validation/any/test.xsd @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + -- cgit v1.1