summaryrefslogtreecommitdiff
path: root/xsd-tests/cxx/parser/validation/built-in/qname
diff options
context:
space:
mode:
Diffstat (limited to 'xsd-tests/cxx/parser/validation/built-in/qname')
-rw-r--r--xsd-tests/cxx/parser/validation/built-in/qname/buildfile10
-rw-r--r--xsd-tests/cxx/parser/validation/built-in/qname/driver.cxx105
2 files changed, 115 insertions, 0 deletions
diff --git a/xsd-tests/cxx/parser/validation/built-in/qname/buildfile b/xsd-tests/cxx/parser/validation/built-in/qname/buildfile
new file mode 100644
index 0000000..47d644c
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/built-in/qname/buildfile
@@ -0,0 +1,10 @@
+# file : cxx/parser/validation/built-in/qname/buildfile
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+import libs = libxsd%lib{xsd}
+
+exe{driver}: {hxx cxx}{*} $libs
+
+# Define XSD_CXX11 since we include libxsd headers directly.
+#
+cxx.poptions += -DXSD_CXX11
diff --git a/xsd-tests/cxx/parser/validation/built-in/qname/driver.cxx b/xsd-tests/cxx/parser/validation/built-in/qname/driver.cxx
new file mode 100644
index 0000000..85acd1c
--- /dev/null
+++ b/xsd-tests/cxx/parser/validation/built-in/qname/driver.cxx
@@ -0,0 +1,105 @@
+// file : cxx/parser/validation/built-in/qname/driver.cxx
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test the built-in QName type validation.
+//
+#include <cassert>
+
+#include <xsd/cxx/parser/validating/exceptions.hxx>
+#include <xsd/cxx/parser/validating/xml-schema-pimpl.hxx>
+
+using namespace xsd::cxx::parser::validating;
+
+bool
+test_post_fail (qname_pimpl<char>& p)
+{
+ try
+ {
+ p._post ();
+ }
+ catch (invalid_value<char> const&)
+ {
+ return true;
+ }
+
+ return false;
+}
+
+int
+main ()
+{
+ typedef xsd::cxx::parser::qname<char> qname;
+
+ // Good.
+ //
+ {
+ qname_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (" xsi");
+ p._characters (":");
+ p._characters ("schemaLocation");
+ p._post ();
+ assert (p.post_qname () == qname ("xsi", "schemaLocation"));
+ }
+
+ {
+ qname_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("schemaLocation");
+ p._post ();
+ assert (p.post_qname () == qname ("schemaLocation"));
+ }
+
+
+ // Bad
+ //
+ {
+ qname_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ //p._characters ("");
+ assert (test_post_fail (p));
+ }
+
+ {
+ qname_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (":");
+ assert (test_post_fail (p));
+ }
+
+ {
+ qname_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("xsi:");
+ assert (test_post_fail (p));
+ }
+
+ {
+ qname_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters (":schemaLocation");
+ assert (test_post_fail (p));
+ }
+
+ {
+ qname_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("x?i:schemaLocation");
+ assert (test_post_fail (p));
+ }
+
+ {
+ qname_pimpl<char> p;
+ p.pre ();
+ p._pre ();
+ p._characters ("xsi:schema Location");
+ assert (test_post_fail (p));
+ }
+}