aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/parser/driver.cxx57
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/parser/driver.cxx b/tests/parser/driver.cxx
index c5d18f0..e4ecd69 100644
--- a/tests/parser/driver.cxx
+++ b/tests/parser/driver.cxx
@@ -84,6 +84,24 @@ main ()
// cerr << e.what () << endl;
}
+ // Test namespace declarations.
+ //
+ {
+ // Followup end element event that should be precedeeded by end
+ // namespace declaration.
+ //
+ istringstream is ("<root xmlns:a='a'/>");
+ parser p (is,
+ "test",
+ parser::receive_default |
+ parser::receive_namespace_decls);
+
+ p.next_expect (parser::start_element, "root");
+ p.next_expect (parser::start_namespace_decl);
+ p.next_expect (parser::end_namespace_decl);
+ p.next_expect (parser::end_element);
+ }
+
// Test value extraction.
//
{
@@ -269,6 +287,45 @@ main ()
// cerr << e.what () << endl;
}
+ {
+ // Test content accumulation in simple content.
+ //
+ istringstream is ("<root xmlns:a='a'>1&#x32;3</root>");
+ parser p (is,
+ "simple",
+ parser::receive_default |
+ parser::receive_namespace_decls);
+
+ assert (p.next () == parser::start_element);
+ p.next_expect (parser::start_namespace_decl);
+ p.content (parser::simple);
+ assert (p.next () == parser::characters && p.value () == "123");
+ p.next_expect (parser::end_namespace_decl);
+ assert (p.next () == parser::end_element);
+ assert (p.next () == parser::eof);
+ }
+
+ try
+ {
+ // Test error handling in accumulation in simple content.
+ //
+ istringstream is ("<root xmlns:a='a'>1&#x32;<nested/>3</root>");
+ parser p (is,
+ "simple",
+ parser::receive_default |
+ parser::receive_namespace_decls);
+
+ assert (p.next () == parser::start_element);
+ p.next_expect (parser::start_namespace_decl);
+ p.content (parser::simple);
+ p.next ();
+ assert (false);
+ }
+ catch (const xml::exception&)
+ {
+ // cerr << e.what () << endl;
+ }
+
// complex
//
{