aboutsummaryrefslogtreecommitdiff
path: root/tests/cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-10-11 12:43:48 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-10-11 12:43:48 +0200
commit9553149aa6b6561c49981adf2848607a43765054 (patch)
treeff941ad89aa2c87ec5ddbd7a7bdd189fc33f87ba /tests/cxx
parent0dd6d623af5dfe3590d0c269f76a2fa322e75e58 (diff)
Support for validation of the pattern facet
New test: hybrid/pattern.
Diffstat (limited to 'tests/cxx')
-rw-r--r--tests/cxx/hybrid/makefile4
-rw-r--r--tests/cxx/hybrid/pattern/driver.cxx56
-rw-r--r--tests/cxx/hybrid/pattern/makefile108
-rw-r--r--tests/cxx/hybrid/pattern/test-000.std11
-rw-r--r--tests/cxx/hybrid/pattern/test-000.xml13
-rw-r--r--tests/cxx/hybrid/pattern/test.xsd53
6 files changed, 243 insertions, 2 deletions
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 <boris@codesynthesis.com>
+// copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test the pattern facet validation.
+//
+
+#include <iostream>
+
+#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 <boris@codesynthesis.com>
+# 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 @@
+<t:root xmlns:t="test">
+ <t1>foobarbaz</t1>
+ <t2>12,32,123,321,</t2>
+ <t3>12321</t3>
+ <t4>12321</t4>
+ <t5>
+
+
+ </t5>
+ <t6>abcdef</t6>
+</t:root> \ 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 @@
+<t:root xmlns:t="test">
+
+ <t1>foobarbaz</t1>
+ <t2>12,32,123,321,</t2>
+ <t3>12321</t3>
+ <t4>12321</t4>
+ <t5>
+
+
+ </t5>
+ <t6>abcdef</t6>
+
+</t:root>
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 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
+
+ <simpleType name="t1">
+ <restriction base="string">
+ <pattern value="foo.*baz"/>
+ </restriction>
+ </simpleType>
+
+ <simpleType name="t2">
+ <restriction base="string">
+ <pattern value="([123]+,)+"/>
+ </restriction>
+ </simpleType>
+
+ <simpleType name="t3">
+ <restriction base="string">
+ <pattern value="[1-9]*"/>
+ </restriction>
+ </simpleType>
+
+ <simpleType name="t4">
+ <restriction base="string">
+ <pattern value="\d+"/>
+ </restriction>
+ </simpleType>
+
+ <simpleType name="t5">
+ <restriction base="string">
+ <pattern value="\s+"/>
+ </restriction>
+ </simpleType>
+
+ <simpleType name="t6">
+ <restriction base="string">
+ <pattern value="\w+"/>
+ </restriction>
+ </simpleType>
+
+ <complexType name="type">
+ <sequence>
+ <element name="t1" type="t:t1" maxOccurs="unbounded"/>
+ <element name="t2" type="t:t2" maxOccurs="unbounded"/>
+ <element name="t3" type="t:t3" maxOccurs="unbounded"/>
+ <element name="t4" type="t:t4" maxOccurs="unbounded"/>
+ <element name="t5" type="t:t5" maxOccurs="unbounded"/>
+ <element name="t6" type="t:t6" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+
+ <element name="root" type="t:type"/>
+
+</schema>