summaryrefslogtreecommitdiff
path: root/xsd/tests/cxx/parser/validation/all
diff options
context:
space:
mode:
Diffstat (limited to 'xsd/tests/cxx/parser/validation/all')
-rw-r--r--xsd/tests/cxx/parser/validation/all/driver.cxx100
-rw-r--r--xsd/tests/cxx/parser/validation/all/makefile89
-rw-r--r--xsd/tests/cxx/parser/validation/all/test-000.std46
-rw-r--r--xsd/tests/cxx/parser/validation/all/test-000.xml53
-rw-r--r--xsd/tests/cxx/parser/validation/all/test-001.std6
-rw-r--r--xsd/tests/cxx/parser/validation/all/test-001.xml11
-rw-r--r--xsd/tests/cxx/parser/validation/all/test-002.std4
-rw-r--r--xsd/tests/cxx/parser/validation/all/test-002.xml9
-rw-r--r--xsd/tests/cxx/parser/validation/all/test-003.std6
-rw-r--r--xsd/tests/cxx/parser/validation/all/test-003.xml12
-rw-r--r--xsd/tests/cxx/parser/validation/all/test.xsd20
11 files changed, 356 insertions, 0 deletions
diff --git a/xsd/tests/cxx/parser/validation/all/driver.cxx b/xsd/tests/cxx/parser/validation/all/driver.cxx
new file mode 100644
index 0000000..d4a3839
--- /dev/null
+++ b/xsd/tests/cxx/parser/validation/all/driver.cxx
@@ -0,0 +1,100 @@
+// file : tests/cxx/parser/validation/all/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 all compositor validation.
+//
+
+#include <string>
+#include <fstream>
+#include <iostream>
+
+#include "test-pskel.hxx"
+
+using namespace std;
+using namespace test;
+
+struct all_pimpl: all_pskel
+{
+ virtual void
+ pre ()
+ {
+ cout << "{" << endl;
+ }
+
+ virtual void
+ a (string const& v)
+ {
+ cout << " a = " << v << endl;
+ }
+
+ virtual void
+ b (string const& v)
+ {
+ cout << " b = " << v << endl;
+ }
+
+ virtual void
+ c (string const& v)
+ {
+ cout << " c = " << v << endl;
+ }
+
+ virtual void
+ post_all ()
+ {
+ 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;
+ all_pimpl all_p;
+ type_pimpl type_p;
+
+ all_p.parsers (string_p, string_p, string_p);
+ type_p.parsers (all_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/xsd/tests/cxx/parser/validation/all/makefile b/xsd/tests/cxx/parser/validation/all/makefile
new file mode 100644
index 0000000..6336fdc
--- /dev/null
+++ b/xsd/tests/cxx/parser/validation/all/makefile
@@ -0,0 +1,89 @@
+# file : tests/cxx/parser/validation/all/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
+
+tests := 000 001 002 003
+
+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)
+
+genf := $(xsd:.xsd=-pskel.hxx) $(xsd:.xsd=-pskel.ixx) $(xsd:.xsd=-pskel.cxx)
+gen := $(addprefix $(out_base)/,$(genf))
+
+$(gen): xsd := $(out_root)/xsd/xsd
+$(gen): xsd_options := --generate-validation
+$(gen): $(out_root)/xsd/xsd
+
+$(call include-dep,$(dep))
+
+
+# Convenience alias for default target.
+#
+$(out_base)/: $(driver)
+
+
+# Test.
+#
+test_targets := $(addprefix $(out_base)/.test-,$(tests))
+
+$(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.
+#
+$(clean): $(driver).o.clean \
+ $(addsuffix .cxx.clean,$(obj)) \
+ $(addsuffix .cxx.clean,$(dep)) \
+ $(addprefix $(out_base)/,$(xsd:.xsd=-pskel.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)/xsd/parser/xsd-cxx.make)
+
+
+# Dependencies.
+#
+$(call import,$(src_root)/xsd/makefile)
diff --git a/xsd/tests/cxx/parser/validation/all/test-000.std b/xsd/tests/cxx/parser/validation/all/test-000.std
new file mode 100644
index 0000000..b4445f2
--- /dev/null
+++ b/xsd/tests/cxx/parser/validation/all/test-000.std
@@ -0,0 +1,46 @@
+{
+ a = a
+ b = b
+ c = c
+}
+
+{
+ a = a
+ c = c
+ b = b
+}
+
+{
+ b = b
+ a = a
+ c = c
+}
+
+{
+ b = b
+ c = c
+ a = a
+}
+
+{
+ c = c
+ a = a
+ b = b
+}
+
+{
+ c = c
+ b = b
+ a = a
+}
+
+{
+ a = a
+ b = b
+}
+
+{
+ a = a
+ b = b
+}
+
diff --git a/xsd/tests/cxx/parser/validation/all/test-000.xml b/xsd/tests/cxx/parser/validation/all/test-000.xml
new file mode 100644
index 0000000..6e46fae
--- /dev/null
+++ b/xsd/tests/cxx/parser/validation/all/test-000.xml
@@ -0,0 +1,53 @@
+<t:root xmlns:t="test"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- all combinations -->
+ <all>
+ <a>a</a>
+ <b>b</b>
+ <c>c</c>
+ </all>
+
+ <all>
+ <a>a</a>
+ <c>c</c>
+ <b>b</b>
+ </all>
+
+ <all>
+ <b>b</b>
+ <a>a</a>
+ <c>c</c>
+ </all>
+
+ <all>
+ <b>b</b>
+ <c>c</c>
+ <a>a</a>
+ </all>
+
+ <all>
+ <c>c</c>
+ <a>a</a>
+ <b>b</b>
+ </all>
+
+ <all>
+ <c>c</c>
+ <b>b</b>
+ <a>a</a>
+ </all>
+
+ <!-- optional c is not present -->
+ <all>
+ <a>a</a>
+ <b>b</b>
+ </all>
+
+ <all>
+ <a>a</a>
+ <b>b</b>
+ </all>
+
+</t:root>
diff --git a/xsd/tests/cxx/parser/validation/all/test-001.std b/xsd/tests/cxx/parser/validation/all/test-001.std
new file mode 100644
index 0000000..0472ad9
--- /dev/null
+++ b/xsd/tests/cxx/parser/validation/all/test-001.std
@@ -0,0 +1,6 @@
+{
+ a = a
+ c = c
+ :9:9 error: expected element 'b'
+}
+
diff --git a/xsd/tests/cxx/parser/validation/all/test-001.xml b/xsd/tests/cxx/parser/validation/all/test-001.xml
new file mode 100644
index 0000000..3df5600
--- /dev/null
+++ b/xsd/tests/cxx/parser/validation/all/test-001.xml
@@ -0,0 +1,11 @@
+<t:root xmlns:t="test"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- required b is not present (invalid) -->
+ <all>
+ <a>a</a>
+ <c>c</c>
+ </all>
+
+</t:root>
diff --git a/xsd/tests/cxx/parser/validation/all/test-002.std b/xsd/tests/cxx/parser/validation/all/test-002.std
new file mode 100644
index 0000000..c014230
--- /dev/null
+++ b/xsd/tests/cxx/parser/validation/all/test-002.std
@@ -0,0 +1,4 @@
+{
+ :7:9 error: expected element 'a'
+}
+
diff --git a/xsd/tests/cxx/parser/validation/all/test-002.xml b/xsd/tests/cxx/parser/validation/all/test-002.xml
new file mode 100644
index 0000000..aed0c0c
--- /dev/null
+++ b/xsd/tests/cxx/parser/validation/all/test-002.xml
@@ -0,0 +1,9 @@
+<t:root xmlns:t="test"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- invalid -->
+ <all>
+ </all>
+
+</t:root>
diff --git a/xsd/tests/cxx/parser/validation/all/test-003.std b/xsd/tests/cxx/parser/validation/all/test-003.std
new file mode 100644
index 0000000..dd8c0d3
--- /dev/null
+++ b/xsd/tests/cxx/parser/validation/all/test-003.std
@@ -0,0 +1,6 @@
+{
+ a = a
+ b = b
+ :9:7 error: unexpected element 'a'
+}
+
diff --git a/xsd/tests/cxx/parser/validation/all/test-003.xml b/xsd/tests/cxx/parser/validation/all/test-003.xml
new file mode 100644
index 0000000..b147cba
--- /dev/null
+++ b/xsd/tests/cxx/parser/validation/all/test-003.xml
@@ -0,0 +1,12 @@
+<t:root xmlns:t="test"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <!-- invalid -->
+ <all>
+ <a>a</a>
+ <b>b</b>
+ <a>a</a>
+ </all>
+
+</t:root>
diff --git a/xsd/tests/cxx/parser/validation/all/test.xsd b/xsd/tests/cxx/parser/validation/all/test.xsd
new file mode 100644
index 0000000..1f670e3
--- /dev/null
+++ b/xsd/tests/cxx/parser/validation/all/test.xsd
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
+
+ <complexType name="all">
+ <all minOccurs="1">
+ <element name="a" type="string"/>
+ <element name="b" type="string"/>
+ <element name="c" type="string" minOccurs="0"/>
+ </all>
+ </complexType>
+
+ <complexType name="type">
+ <sequence>
+ <element name="all" type="t:all" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+
+ <element name="root" type="t:type"/>
+
+</schema>