aboutsummaryrefslogtreecommitdiff
path: root/tests/cxx/serializer/validation/built-in
diff options
context:
space:
mode:
Diffstat (limited to 'tests/cxx/serializer/validation/built-in')
-rw-r--r--tests/cxx/serializer/validation/built-in/date-time/driver.cxx398
-rw-r--r--tests/cxx/serializer/validation/built-in/date-time/makefile61
-rw-r--r--tests/cxx/serializer/validation/built-in/decimal/driver.cxx46
-rw-r--r--tests/cxx/serializer/validation/built-in/decimal/makefile61
-rw-r--r--tests/cxx/serializer/validation/built-in/integer/driver.cxx63
-rw-r--r--tests/cxx/serializer/validation/built-in/integer/makefile61
-rw-r--r--tests/cxx/serializer/validation/built-in/makefile20
-rw-r--r--tests/cxx/serializer/validation/built-in/qname/driver.cxx70
-rw-r--r--tests/cxx/serializer/validation/built-in/qname/makefile61
-rw-r--r--tests/cxx/serializer/validation/built-in/string/driver.cxx485
-rw-r--r--tests/cxx/serializer/validation/built-in/string/makefile61
11 files changed, 1387 insertions, 0 deletions
diff --git a/tests/cxx/serializer/validation/built-in/date-time/driver.cxx b/tests/cxx/serializer/validation/built-in/date-time/driver.cxx
new file mode 100644
index 0000000..bdc196e
--- /dev/null
+++ b/tests/cxx/serializer/validation/built-in/date-time/driver.cxx
@@ -0,0 +1,398 @@
+// file : tests/cxx/serializer/validation/built-in/date-time/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 the built-in date and time types validation.
+//
+#include <cassert>
+
+#include <xsde/cxx/serializer/validating/xml-schema-simpl.hxx>
+
+using namespace xsde::cxx;
+using namespace xsde::cxx::serializer;
+using namespace xsde::cxx::serializer::validating;
+
+int
+main ()
+{
+ using xsde::cxx::time; // Conflicts with system time.
+
+ // gday & time zone
+ //
+ {
+ gday_simpl s;
+ context c (0);
+ s.pre (gday (0));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_gday_value);
+ }
+
+ {
+ gday_simpl s;
+ context c (0);
+ s.pre (gday (32));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_gday_value);
+ }
+
+ {
+ gday_simpl s;
+ context c (0);
+ s.pre (gday (15, 15, 0));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_gday_value);
+ }
+
+ {
+ gday_simpl s;
+ context c (0);
+ s.pre (gday (15, 12, 60));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_gday_value);
+ }
+
+ {
+ gday_simpl s;
+ context c (0);
+ s.pre (gday (15, -12, 30));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_gday_value);
+ }
+
+ {
+ gday_simpl s;
+ context c (0);
+ s.pre (gday (15, 12, -30));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_gday_value);
+ }
+
+ {
+ gday_simpl s;
+ context c (0);
+ s.pre (gday (15, 14, 1));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_gday_value);
+ }
+
+ // gmonth
+ //
+ {
+ gmonth_simpl s;
+ context c (0);
+ s.pre (gmonth (0));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_gmonth_value);
+ }
+
+ {
+ gmonth_simpl s;
+ context c (0);
+ s.pre (gmonth (13));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_gmonth_value);
+ }
+
+ // gyear
+ //
+ {
+ gyear_simpl s;
+ context c (0);
+ s.pre (gyear (0));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_gyear_value);
+ }
+
+ // gmonth_day
+ //
+ {
+ gmonth_day_simpl s;
+ context c (0);
+ s.pre (gmonth_day (0, 15));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_gmonth_day_value);
+ }
+
+ {
+ gmonth_day_simpl s;
+ context c (0);
+ s.pre (gmonth_day (6, 0));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_gmonth_day_value);
+ }
+
+ {
+ gmonth_day_simpl s;
+ context c (0);
+ s.pre (gmonth_day (13, 15));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_gmonth_day_value);
+ }
+
+ {
+ gmonth_day_simpl s;
+ context c (0);
+ s.pre (gmonth_day (6, 32));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_gmonth_day_value);
+ }
+
+ // gyear_month
+ //
+ {
+ gyear_month_simpl s;
+ context c (0);
+ s.pre (gyear_month (0, 6));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_gyear_month_value);
+ }
+
+ {
+ gyear_month_simpl s;
+ context c (0);
+ s.pre (gyear_month (2007, 0));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_gyear_month_value);
+ }
+
+ {
+ gyear_month_simpl s;
+ context c (0);
+ s.pre (gyear_month (2007, 32));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_gyear_month_value);
+ }
+
+ // date
+ //
+ {
+ date_simpl s;
+ context c (0);
+ s.pre (date (0, 6, 15));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_date_value);
+ }
+
+ {
+ date_simpl s;
+ context c (0);
+ s.pre (date (2007, 0, 15));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_date_value);
+ }
+
+ {
+ date_simpl s;
+ context c (0);
+ s.pre (date (2007, 13, 15));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_date_value);
+ }
+
+ {
+ date_simpl s;
+ context c (0);
+ s.pre (date (2007, 6, 0));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_date_value);
+ }
+
+ {
+ date_simpl s;
+ context c (0);
+ s.pre (date (2007, 6, 32));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_date_value);
+ }
+
+ // time
+ //
+ {
+ time_simpl s;
+ context c (0);
+ s.pre (time (25, 30, 30.0));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_time_value);
+ }
+
+ {
+ time_simpl s;
+ context c (0);
+ s.pre (time (24, 1, 0));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_time_value);
+ }
+
+ {
+ time_simpl s;
+ context c (0);
+ s.pre (time (24, 0, 0.1));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_time_value);
+ }
+
+ {
+ time_simpl s;
+ context c (0);
+ s.pre (time (12, 60, 30));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_time_value);
+ }
+
+ {
+ time_simpl s;
+ context c (0);
+ s.pre (time (12, 30, 60.1));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_time_value);
+ }
+
+ {
+ time_simpl s;
+ context c (0);
+ s.pre (time (12, 30, -30.0));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_time_value);
+ }
+
+ // date_time
+ //
+ {
+ date_time_simpl s;
+ context c (0);
+ s.pre (date_time (0, 6, 32, 12, 30, 30.0));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ date_time_simpl s;
+ context c (0);
+ s.pre (date_time (2007, 0, 32, 12, 30, 30.0));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ date_time_simpl s;
+ context c (0);
+ s.pre (date_time (2007, 13, 32, 12, 30, 30.0));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ date_time_simpl s;
+ context c (0);
+ s.pre (date_time (2007, 6, 0, 12, 30, 30.0));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ date_time_simpl s;
+ context c (0);
+ s.pre (date_time (2007, 6, 32, 12, 30, 30.0));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ date_time_simpl s;
+ context c (0);
+ s.pre (date_time (2007, 6, 15, 25, 30, 30.0));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ date_time_simpl s;
+ context c (0);
+ s.pre (date_time (2007, 6, 15, 24, 1, 0));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ date_time_simpl s;
+ context c (0);
+ s.pre (date_time (2007, 6, 15, 24, 0, 0.1));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ date_time_simpl s;
+ context c (0);
+ s.pre (date_time (2007, 6, 15, 12, 60, 30));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ date_time_simpl s;
+ context c (0);
+ s.pre (date_time (2007, 6, 15, 12, 30, 60.1));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ {
+ date_time_simpl s;
+ context c (0);
+ s.pre (date_time (2007, 6, 15, 12, 30, -30.0));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_date_time_value);
+ }
+
+ // duration
+ //
+ {
+ duration_simpl s;
+ context c (0);
+ s.pre (duration (false, 2007, 6, 15, 12, 30, -30.0));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_duration_value);
+ }
+}
diff --git a/tests/cxx/serializer/validation/built-in/date-time/makefile b/tests/cxx/serializer/validation/built-in/date-time/makefile
new file mode 100644
index 0000000..aa45e21
--- /dev/null
+++ b/tests/cxx/serializer/validation/built-in/date-time/makefile
@@ -0,0 +1,61 @@
+# file : tests/cxx/serializer/validation/built-in/date-time/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
+
+cxx := driver.cxx
+
+obj := $(addprefix $(out_base)/,$(cxx:.cxx=.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)
+
+$(call include-dep,$(dep))
+
+# Convenience alias for default target.
+#
+.PHONY: $(out_base)/
+$(out_base)/: $(driver)
+
+
+# Test.
+#
+.PHONY: $(test)
+
+$(test): driver := $(driver)
+$(test): $(driver)
+ $(call message,test $$1,$$1,$(driver))
+
+# Clean.
+#
+.PHONY: $(clean)
+
+$(clean): $(driver).o.clean \
+ $(addsuffix .cxx.clean,$(obj)) \
+ $(addsuffix .cxx.clean,$(dep))
+
+
+# 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)
+
+
+# Dependencies.
+#
+$(call import,$(src_root)/libxsde/xsde/makefile)
diff --git a/tests/cxx/serializer/validation/built-in/decimal/driver.cxx b/tests/cxx/serializer/validation/built-in/decimal/driver.cxx
new file mode 100644
index 0000000..9349e6b
--- /dev/null
+++ b/tests/cxx/serializer/validation/built-in/decimal/driver.cxx
@@ -0,0 +1,46 @@
+// file : tests/cxx/serializer/validation/built-in/decimal/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 the built-in decimal type validation.
+//
+#include <stdlib.h> // strtod
+#include <cassert>
+
+#include <xsde/cxx/serializer/validating/decimal.hxx>
+
+using namespace xsde::cxx;
+using namespace xsde::cxx::serializer;
+using namespace xsde::cxx::serializer::validating;
+
+int
+main ()
+{
+ {
+ decimal_simpl s;
+ context c (0);
+ s.pre (strtod ("NAN", 0));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_decimal_value);
+ }
+
+ {
+ decimal_simpl s;
+ context c (0);
+ s.pre (strtod ("INF", 0));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_decimal_value);
+ }
+
+ {
+ decimal_simpl s;
+ context c (0);
+ s.pre (strtod ("-INF", 0));
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_decimal_value);
+ }
+}
diff --git a/tests/cxx/serializer/validation/built-in/decimal/makefile b/tests/cxx/serializer/validation/built-in/decimal/makefile
new file mode 100644
index 0000000..e4517b6
--- /dev/null
+++ b/tests/cxx/serializer/validation/built-in/decimal/makefile
@@ -0,0 +1,61 @@
+# file : tests/cxx/serializer/validation/built-in/decimal/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
+
+cxx := driver.cxx
+
+obj := $(addprefix $(out_base)/,$(cxx:.cxx=.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)
+
+$(call include-dep,$(dep))
+
+# Convenience alias for default target.
+#
+.PHONY: $(out_base)/
+$(out_base)/: $(driver)
+
+
+# Test.
+#
+.PHONY: $(test)
+
+$(test): driver := $(driver)
+$(test): $(driver)
+ $(call message,test $$1,$$1,$(driver))
+
+# Clean.
+#
+.PHONY: $(clean)
+
+$(clean): $(driver).o.clean \
+ $(addsuffix .cxx.clean,$(obj)) \
+ $(addsuffix .cxx.clean,$(dep))
+
+
+# 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)
+
+
+# Dependencies.
+#
+$(call import,$(src_root)/libxsde/xsde/makefile)
diff --git a/tests/cxx/serializer/validation/built-in/integer/driver.cxx b/tests/cxx/serializer/validation/built-in/integer/driver.cxx
new file mode 100644
index 0000000..e20a561
--- /dev/null
+++ b/tests/cxx/serializer/validation/built-in/integer/driver.cxx
@@ -0,0 +1,63 @@
+// file : tests/cxx/serializer/validation/built-in/int/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 the built-in integer & friends types validation.
+//
+
+#include <cassert>
+
+#include <xsde/cxx/serializer/validating/negative-integer.hxx>
+#include <xsde/cxx/serializer/validating/non-positive-integer.hxx>
+#include <xsde/cxx/serializer/validating/positive-integer.hxx>
+
+using namespace xsde::cxx::serializer;
+using namespace xsde::cxx::serializer::validating;
+using namespace std;
+
+int
+main ()
+{
+ // negative_integer
+ //
+ {
+ negative_integer_simpl s;
+ context c (0);
+ s.pre (0);
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error ());
+ }
+
+ {
+ negative_integer_simpl s;
+ context c (0);
+ s.pre (1);
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error ());
+ }
+
+ // non_positive_integer
+ //
+ {
+ non_positive_integer_simpl s;
+ context c (0);
+ s.pre (1);
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error ());
+ }
+
+ // positive_integer
+ //
+ {
+ positive_integer_simpl s;
+ context c (0);
+ s.pre (0);
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error ());
+ }
+}
diff --git a/tests/cxx/serializer/validation/built-in/integer/makefile b/tests/cxx/serializer/validation/built-in/integer/makefile
new file mode 100644
index 0000000..37bd439
--- /dev/null
+++ b/tests/cxx/serializer/validation/built-in/integer/makefile
@@ -0,0 +1,61 @@
+# file : tests/cxx/serializer/validation/built-in/integer/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
+
+cxx := driver.cxx
+
+obj := $(addprefix $(out_base)/,$(cxx:.cxx=.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)
+
+$(call include-dep,$(dep))
+
+# Convenience alias for default target.
+#
+.PHONY: $(out_base)/
+$(out_base)/: $(driver)
+
+
+# Test.
+#
+.PHONY: $(test)
+
+$(test): driver := $(driver)
+$(test): $(driver)
+ $(call message,test $$1,$$1,$(driver))
+
+# Clean.
+#
+.PHONY: $(clean)
+
+$(clean): $(driver).o.clean \
+ $(addsuffix .cxx.clean,$(obj)) \
+ $(addsuffix .cxx.clean,$(dep))
+
+
+# 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)
+
+
+# Dependencies.
+#
+$(call import,$(src_root)/libxsde/xsde/makefile)
diff --git a/tests/cxx/serializer/validation/built-in/makefile b/tests/cxx/serializer/validation/built-in/makefile
new file mode 100644
index 0000000..7fdeec7
--- /dev/null
+++ b/tests/cxx/serializer/validation/built-in/makefile
@@ -0,0 +1,20 @@
+# file : tests/cxx/serializer/validation/built-in/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
+
+tests := date-time decimal integer qname string
+
+default := $(out_base)/
+test := $(out_base)/.test
+clean := $(out_base)/.clean
+
+.PHONY: $(default) $(test) $(clean)
+
+$(default): $(addprefix $(out_base)/,$(addsuffix /,$(tests)))
+$(test): $(addprefix $(out_base)/,$(addsuffix /.test,$(tests)))
+$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(tests)))
+
+$(foreach t,$(tests),$(call import,$(src_base)/$t/makefile))
diff --git a/tests/cxx/serializer/validation/built-in/qname/driver.cxx b/tests/cxx/serializer/validation/built-in/qname/driver.cxx
new file mode 100644
index 0000000..33ccdc1
--- /dev/null
+++ b/tests/cxx/serializer/validation/built-in/qname/driver.cxx
@@ -0,0 +1,70 @@
+// file : tests/cxx/serializer/validation/built-in/qname/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 the built-in QName type validation.
+//
+#include <cassert>
+
+#include <xsde/config.h>
+
+// Let the runtime header sort out which version (stl/no-stl) to
+// include.
+//
+#include <xsde/cxx/serializer/validating/xml-schema-simpl.hxx>
+
+using namespace xsde::cxx;
+using namespace xsde::cxx::serializer;
+using namespace xsde::cxx::serializer::validating;
+
+int
+main ()
+{
+ {
+ qname_simpl s;
+ context c (0);
+#ifdef XSDE_STL
+ s.pre (qname ("a b"));
+#else
+ qname qn;
+ qn.name_copy ("a b");
+ s.pre (&qn);
+#endif
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_qname_value);
+ }
+
+ {
+ qname_simpl s;
+ context c (0);
+#ifdef XSDE_STL
+ s.pre (qname ("ab", "a b"));
+#else
+ qname qn;
+ qn.name_copy ("a b");
+ qn.prefix_copy ("ab");
+ s.pre (&qn);
+#endif
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_qname_value);
+ }
+
+ {
+ qname_simpl s;
+ context c (0);
+#ifdef XSDE_STL
+ s.pre (qname ("a b", "ab"));
+#else
+ qname qn;
+ qn.name_copy ("ab");
+ qn.prefix_copy ("a b");
+ s.pre (&qn);
+#endif
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_qname_value);
+ }
+}
diff --git a/tests/cxx/serializer/validation/built-in/qname/makefile b/tests/cxx/serializer/validation/built-in/qname/makefile
new file mode 100644
index 0000000..ec2d802
--- /dev/null
+++ b/tests/cxx/serializer/validation/built-in/qname/makefile
@@ -0,0 +1,61 @@
+# file : tests/cxx/serializer/validation/built-in/qname/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
+
+cxx := driver.cxx
+
+obj := $(addprefix $(out_base)/,$(cxx:.cxx=.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)
+
+$(call include-dep,$(dep))
+
+# Convenience alias for default target.
+#
+.PHONY: $(out_base)/
+$(out_base)/: $(driver)
+
+
+# Test.
+#
+.PHONY: $(test)
+
+$(test): driver := $(driver)
+$(test): $(driver)
+ $(call message,test $$1,$$1,$(driver))
+
+# Clean.
+#
+.PHONY: $(clean)
+
+$(clean): $(driver).o.clean \
+ $(addsuffix .cxx.clean,$(obj)) \
+ $(addsuffix .cxx.clean,$(dep))
+
+
+# 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)
+
+
+# Dependencies.
+#
+$(call import,$(src_root)/libxsde/xsde/makefile)
diff --git a/tests/cxx/serializer/validation/built-in/string/driver.cxx b/tests/cxx/serializer/validation/built-in/string/driver.cxx
new file mode 100644
index 0000000..c1cfe21
--- /dev/null
+++ b/tests/cxx/serializer/validation/built-in/string/driver.cxx
@@ -0,0 +1,485 @@
+// file : tests/cxx/serializer/validation/built-in/string/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 the built-in string & friends types validation.
+//
+#include <string>
+#include <cassert>
+
+#include <xsde/config.h>
+
+// Let the runtime header sort out which version (stl/no-stl) to
+// include.
+//
+#include <xsde/cxx/serializer/validating/xml-schema-simpl.hxx>
+
+using namespace xsde::cxx;
+using namespace xsde::cxx::serializer;
+using namespace xsde::cxx::serializer::validating;
+
+int
+main ()
+{
+ // normalized_string
+ //
+ {
+ normalized_string_simpl s;
+ context c (0);
+ s.pre ("aaa\nbbb");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_normalized_string_value);
+ }
+
+ {
+ normalized_string_simpl s;
+ context c (0);
+ s.pre ("aaa\tbbb");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_normalized_string_value);
+ }
+
+ {
+ normalized_string_simpl s;
+ context c (0);
+ s.pre ("aaa\rbbb");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_normalized_string_value);
+ }
+
+ // token
+ //
+ {
+ token_simpl s;
+ context c (0);
+ s.pre ("aaa\nbbb");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_token_value);
+ }
+
+ {
+ token_simpl s;
+ context c (0);
+ s.pre ("aaa\tbbb");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_token_value);
+ }
+
+ {
+ token_simpl s;
+ context c (0);
+ s.pre ("aaa\rbbb");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_token_value);
+ }
+
+ {
+ token_simpl s;
+ context c (0);
+ s.pre ("aaa bbb");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_token_value);
+ }
+
+ {
+ token_simpl s;
+ context c (0);
+ s.pre (" aaa bbb");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_token_value);
+ }
+
+ {
+ token_simpl s;
+ context c (0);
+ s.pre ("aaa bbb ");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_token_value);
+ }
+
+ // name
+ //
+ {
+ name_simpl s;
+ context c (0);
+ s.pre ("");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_name_value);
+ }
+
+ {
+ name_simpl s;
+ context c (0);
+ s.pre (".a");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_name_value);
+ }
+
+ {
+ name_simpl s;
+ context c (0);
+ s.pre ("-a");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_name_value);
+ }
+
+ {
+ name_simpl s;
+ context c (0);
+ s.pre ("1a");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_name_value);
+ }
+
+ {
+ name_simpl s;
+ context c (0);
+ s.pre (" a");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_name_value);
+ }
+
+ {
+ name_simpl s;
+ context c (0);
+ s.pre ("a,b");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_name_value);
+ }
+
+ {
+ name_simpl s;
+ context c (0);
+ s.pre ("a b");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_name_value);
+ }
+
+ {
+ name_simpl s;
+ context c (0);
+ s.pre ("a<b");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_name_value);
+ }
+
+ {
+ name_simpl s;
+ context c (0);
+ s.pre ("a ");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_name_value);
+ }
+
+ // nmtoken
+ //
+ {
+ nmtoken_simpl s;
+ context c (0);
+ s.pre ("");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_nmtoken_value);
+ }
+
+ {
+ nmtoken_simpl s;
+ context c (0);
+ s.pre (" a");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_nmtoken_value);
+ }
+
+ {
+ nmtoken_simpl s;
+ context c (0);
+ s.pre ("a,b");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_nmtoken_value);
+ }
+
+ {
+ nmtoken_simpl s;
+ context c (0);
+ s.pre ("a b");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_nmtoken_value);
+ }
+
+ {
+ nmtoken_simpl s;
+ context c (0);
+ s.pre ("a<b");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_nmtoken_value);
+ }
+
+ {
+ nmtoken_simpl s;
+ context c (0);
+ s.pre ("a ");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_nmtoken_value);
+ }
+
+ // nmtokens
+ //
+ {
+ nmtokens_simpl s;
+ context c (0);
+ string_sequence seq;
+ s.pre (&seq);
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_nmtokens_value);
+ }
+
+ {
+ nmtokens_simpl s;
+ context c (0);
+ string_sequence seq;
+#ifdef XSDE_STL
+ seq.push_back ("a,b");
+ seq.push_back ("ab");
+#else
+ seq.push_back_copy ("a,b");
+ seq.push_back_copy ("ab");
+#endif
+ s.pre (&seq);
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_nmtoken_value);
+ }
+
+ // ncname
+ //
+ {
+ ncname_simpl s;
+ context c (0);
+ s.pre ("");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_ncname_value);
+ }
+
+ {
+ ncname_simpl s;
+ context c (0);
+ s.pre (" a");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_ncname_value);
+ }
+
+ {
+ ncname_simpl s;
+ context c (0);
+ s.pre (".a");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_ncname_value);
+ }
+
+ {
+ ncname_simpl s;
+ context c (0);
+ s.pre ("-a");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_ncname_value);
+ }
+
+ {
+ ncname_simpl s;
+ context c (0);
+ s.pre (":a");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_ncname_value);
+ }
+
+ {
+ ncname_simpl s;
+ context c (0);
+ s.pre ("1a");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_ncname_value);
+ }
+
+ {
+ ncname_simpl s;
+ context c (0);
+ s.pre ("a,b");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_ncname_value);
+ }
+
+ {
+ ncname_simpl s;
+ context c (0);
+ s.pre ("a b");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_ncname_value);
+ }
+
+ {
+ ncname_simpl s;
+ context c (0);
+ s.pre ("a:b");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_ncname_value);
+ }
+
+ {
+ ncname_simpl s;
+ context c (0);
+ s.pre ("a<b");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_ncname_value);
+ }
+
+ {
+ ncname_simpl s;
+ context c (0);
+ s.pre ("a ");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_ncname_value);
+ }
+
+ // id
+ //
+ {
+ id_simpl s;
+ context c (0);
+ s.pre ("a b");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_id_value);
+ }
+
+ // idref
+ //
+ {
+ idref_simpl s;
+ context c (0);
+ s.pre ("a b");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_idref_value);
+ }
+
+ // idrefs
+ //
+ {
+ idrefs_simpl s;
+ context c (0);
+ string_sequence seq;
+ s.pre (&seq);
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_idrefs_value);
+ }
+
+ {
+ idrefs_simpl s;
+ context c (0);
+ string_sequence seq;
+#ifdef XSDE_STL
+ seq.push_back ("a,b");
+ seq.push_back ("ab");
+#else
+ seq.push_back_copy ("a,b");
+ seq.push_back_copy ("ab");
+#endif
+ s.pre (&seq);
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_idref_value);
+ }
+
+ // language
+ //
+ {
+ language_simpl s;
+ context c (0);
+ s.pre ("");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_language_value);
+ }
+
+ {
+ language_simpl s;
+ context c (0);
+ s.pre (" ");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_language_value);
+ }
+
+ {
+ language_simpl s;
+ context c (0);
+ s.pre ("en-");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_language_value);
+ }
+
+ {
+ language_simpl s;
+ context c (0);
+ s.pre ("a1");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_language_value);
+ }
+
+ {
+ language_simpl s;
+ context c (0);
+ s.pre ("en+us");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_language_value);
+ }
+
+ {
+ language_simpl s;
+ context c (0);
+ s.pre ("en-nine99999");
+ s._pre_impl (c);
+ s._serialize_content ();
+ assert (c.schema_error () == schema_error::invalid_language_value);
+ }
+}
diff --git a/tests/cxx/serializer/validation/built-in/string/makefile b/tests/cxx/serializer/validation/built-in/string/makefile
new file mode 100644
index 0000000..42a7d81
--- /dev/null
+++ b/tests/cxx/serializer/validation/built-in/string/makefile
@@ -0,0 +1,61 @@
+# file : tests/cxx/serializer/validation/built-in/string/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
+
+cxx := driver.cxx
+
+obj := $(addprefix $(out_base)/,$(cxx:.cxx=.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)
+
+$(call include-dep,$(dep))
+
+# Convenience alias for default target.
+#
+.PHONY: $(out_base)/
+$(out_base)/: $(driver)
+
+
+# Test.
+#
+.PHONY: $(test)
+
+$(test): driver := $(driver)
+$(test): $(driver)
+ $(call message,test $$1,$$1,$(driver))
+
+# Clean.
+#
+.PHONY: $(clean)
+
+$(clean): $(driver).o.clean \
+ $(addsuffix .cxx.clean,$(obj)) \
+ $(addsuffix .cxx.clean,$(dep))
+
+
+# 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)
+
+
+# Dependencies.
+#
+$(call import,$(src_root)/libxsde/xsde/makefile)