aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2014-04-29 13:06:50 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2014-04-29 13:06:50 +0200
commitf6313f17cb87d62c4a73f9d135baafd076431311 (patch)
tree1acd7c0ee273f2f423a835641f2d100a3a0d6202 /tests
parent818bedc799073966a4c56fd83ab1df358b9e9c24 (diff)
Accumulate characters in simple content
This makes the high-level data extraction (e.g., value<T>()) much more usable since without this functionality the content can be delivered in multiple chunks.
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
//
{