aboutsummaryrefslogtreecommitdiff
path: root/tests/cxx/serializer/validation/sequence
diff options
context:
space:
mode:
Diffstat (limited to 'tests/cxx/serializer/validation/sequence')
-rw-r--r--tests/cxx/serializer/validation/sequence/driver.cxx102
-rw-r--r--tests/cxx/serializer/validation/sequence/makefile72
-rw-r--r--tests/cxx/serializer/validation/sequence/output1
-rw-r--r--tests/cxx/serializer/validation/sequence/test.xsd21
4 files changed, 196 insertions, 0 deletions
diff --git a/tests/cxx/serializer/validation/sequence/driver.cxx b/tests/cxx/serializer/validation/sequence/driver.cxx
new file mode 100644
index 0000000..562874c
--- /dev/null
+++ b/tests/cxx/serializer/validation/sequence/driver.cxx
@@ -0,0 +1,102 @@
+// file : tests/cxx/serializer/validation/sequence/driver.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test sequence validation.
+//
+
+#include <sstream>
+#include <iostream>
+
+#include "test-sskel.hxx"
+
+using namespace std;
+using namespace test;
+
+struct test_1_simpl: virtual test_1_sskel
+{
+ test_1_simpl (int state)
+ : state_ (state)
+ {
+ }
+
+ virtual bool
+ sequence_next ()
+ {
+ return true;
+ }
+
+ //
+ //
+ virtual bool
+ sequence1_next ()
+ {
+ return false;
+ }
+
+ virtual int
+ a ()
+ {
+ return 123;
+ }
+
+ virtual int
+ b ()
+ {
+ return 234;
+ }
+
+private:
+ int state_;
+};
+
+struct root_simpl: root_sskel
+{
+};
+
+int
+main ()
+{
+ for (int i = 0; i < 1; ++i)
+ {
+#ifdef XSDE_EXCEPTIONS
+ try
+ {
+#endif
+ test_1_simpl test_1_s (i);
+ root_simpl root_s;
+
+ root_s.serializers (test_1_s);
+
+ xml_schema::document_simpl doc_s (root_s, "test", "root");
+
+ root_s.pre ();
+
+ ostringstream os;
+ doc_s.serialize (os);
+
+#ifndef XSDE_EXCEPTIONS
+ if (xml_schema::serializer_error e = doc_s._error ())
+ {
+ if (e.type () == xml_schema::serializer_error::schema)
+ {
+ cout << "schema: " << e.schema_text () << endl;
+ continue;
+ }
+ }
+#endif
+
+ root_s.post ();
+#ifdef XSDE_EXCEPTIONS
+ }
+ catch (xml_schema::serializer_schema const& e)
+ {
+ cout << "schema: " << e.text () << endl;
+ continue;
+ }
+#endif
+
+ cout << "no error" << endl;
+ }
+}
diff --git a/tests/cxx/serializer/validation/sequence/makefile b/tests/cxx/serializer/validation/sequence/makefile
new file mode 100644
index 0000000..e16d8bf
--- /dev/null
+++ b/tests/cxx/serializer/validation/sequence/makefile
@@ -0,0 +1,72 @@
+# file : tests/cxx/serializer/validation/sequence/makefile
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# 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=-sskel.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)
+
+skel := $(out_base)/$(xsd:.xsd=-sskel.hxx) \
+ $(out_base)/$(xsd:.xsd=-sskel.ixx) \
+ $(out_base)/$(xsd:.xsd=-sskel.cxx)
+
+$(skel): xsde := $(out_root)/xsde/xsde
+$(skel): $(out_root)/xsde/xsde
+
+$(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)/output
+ $(call message,test $$1,$$1 | diff -u $(src_base)/output -,$(driver))
+
+# Clean.
+#
+.PHONY: $(clean)
+
+$(clean): $(driver).o.clean \
+ $(addsuffix .cxx.clean,$(obj)) \
+ $(addsuffix .cxx.clean,$(dep)) \
+ $(addprefix $(out_base)/,$(xsd:.xsd=-sskel.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)/xsde/serializer/xsd-cxx.make)
+
+
+# Dependencies.
+#
+$(call import,$(src_root)/xsde/makefile)
+$(call import,$(src_root)/libxsde/xsde/makefile)
diff --git a/tests/cxx/serializer/validation/sequence/output b/tests/cxx/serializer/validation/sequence/output
new file mode 100644
index 0000000..3333a0c
--- /dev/null
+++ b/tests/cxx/serializer/validation/sequence/output
@@ -0,0 +1 @@
+schema: expected element not encountered
diff --git a/tests/cxx/serializer/validation/sequence/test.xsd b/tests/cxx/serializer/validation/sequence/test.xsd
new file mode 100644
index 0000000..d7b2517
--- /dev/null
+++ b/tests/cxx/serializer/validation/sequence/test.xsd
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
+
+ <complexType name="test-1">
+ <sequence maxOccurs="5">
+ <sequence maxOccurs="unbounded"> <!-- 1..unbounded-->
+ <element name="a" type="int"/>
+ <element name="b" type="int"/>
+ </sequence>
+ </sequence>
+ </complexType>
+
+ <complexType name="root">
+ <sequence>
+ <element name="test-1" type="t:test-1"/>
+ </sequence>
+ </complexType>
+
+ <element name="root" type="t:root"/>
+
+</schema>