diff options
Diffstat (limited to 'xsd-tests/cxx/parser/validation/built-in/qname/driver.cxx')
-rw-r--r-- | xsd-tests/cxx/parser/validation/built-in/qname/driver.cxx | 106 |
1 files changed, 106 insertions, 0 deletions
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..8845b38 --- /dev/null +++ b/xsd-tests/cxx/parser/validation/built-in/qname/driver.cxx @@ -0,0 +1,106 @@ +// 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 <xsd/cxx/parser/validating/exceptions.hxx> +#include <xsd/cxx/parser/validating/xml-schema-pimpl.hxx> + +#undef NDEBUG +#include <cassert> + +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)); + } +} |