summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2014-10-02 03:06:59 +0000
committerArseny Kapoulkine <arseny.kapoulkine@gmail.com>2014-10-02 03:06:59 +0000
commit3fcc530b341709000b7acf4e8b85ad11cac0927d (patch)
tree6e7a82456a3f496fb79c9597fd12908b6c291242 /tests
parent00e1219bec0bd56536fcd8cba7930b426c9601db (diff)
tests: Add missing tests to increase code coverage
git-svn-id: https://pugixml.googlecode.com/svn/trunk@1038 99668b35-9821-0410-8761-19e4c4f06640
Diffstat (limited to 'tests')
-rw-r--r--tests/test_dom_modify.cpp5
-rw-r--r--tests/test_dom_traverse.cpp27
-rw-r--r--tests/test_parse.cpp3
-rw-r--r--tests/test_xpath_functions.cpp14
4 files changed, 47 insertions, 2 deletions
diff --git a/tests/test_dom_modify.cpp b/tests/test_dom_modify.cpp
index a66f56a..cf202e0 100644
--- a/tests/test_dom_modify.cpp
+++ b/tests/test_dom_modify.cpp
@@ -1180,8 +1180,9 @@ TEST_XML(dom_node_insert_move_before, "<node>foo<child>bar</child></node>")
TEST_XML(dom_node_move_recursive, "<root><node>foo<child/></node></root>")
{
xml_node root = doc.child(STR("root"));
- xml_node node = doc.child(STR("node"));
+ xml_node node = root.child(STR("node"));
xml_node foo = node.first_child();
+ xml_node child = node.last_child();
CHECK(node.prepend_move(node) == xml_node());
CHECK(node.prepend_move(root) == xml_node());
@@ -1195,6 +1196,8 @@ TEST_XML(dom_node_move_recursive, "<root><node>foo<child/></node></root>")
CHECK(node.insert_move_after(node, foo) == xml_node());
CHECK(node.insert_move_after(root, foo) == xml_node());
+ CHECK(child.append_move(node) == xml_node());
+
CHECK_NODE(doc, STR("<root><node>foo<child /></node></root>"));
}
diff --git a/tests/test_dom_traverse.cpp b/tests/test_dom_traverse.cpp
index 43fec80..c2437ab 100644
--- a/tests/test_dom_traverse.cpp
+++ b/tests/test_dom_traverse.cpp
@@ -1015,4 +1015,31 @@ TEST_XML(dom_node_named_iterator, "<node><node1><child/></node1><node2><child/><
CHECK(itt-- == r1.end());
CHECK(itt == r1.begin());
+
+ CHECK(itt->offset_debug() == 14);
+}
+
+TEST_XML(dom_node_children_attributes, "<node1 attr1='value1' attr2='value2' /><node2 />")
+{
+ xml_object_range<xml_node_iterator> r1 = doc.children();
+
+ CHECK(r1.begin() == doc.begin());
+ CHECK(r1.end() == doc.end());
+
+ xml_object_range<xml_node_iterator> r2 = xml_node().children();
+
+ CHECK(r2.begin() == xml_node_iterator());
+ CHECK(r2.end() == xml_node_iterator());
+
+ xml_node node = doc.child(STR("node1"));
+
+ xml_object_range<xml_attribute_iterator> r3 = node.attributes();
+
+ CHECK(r3.begin() == node.attributes_begin());
+ CHECK(r3.end() == node.attributes_end());
+
+ xml_object_range<xml_attribute_iterator> r4 = xml_node().attributes();
+
+ CHECK(r4.begin() == xml_attribute_iterator());
+ CHECK(r4.end() == xml_attribute_iterator());
}
diff --git a/tests/test_parse.cpp b/tests/test_parse.cpp
index 38b09f5..2094ef9 100644
--- a/tests/test_parse.cpp
+++ b/tests/test_parse.cpp
@@ -451,7 +451,8 @@ TEST(parse_pcdata_trim)
{ STR("<node>\r\n\t text \r\n\r\n\r\n\r\n\r\n\r\n\r\n more \r\n\t</node>"), STR("text \n\n\n\n\n\n\n more"), parse_eol },
{ STR("<node> test&amp;&amp;&amp;&amp;&amp;&amp;&amp; </node>"), STR("test&amp;&amp;&amp;&amp;&amp;&amp;&amp;"), 0 },
{ STR("<node> test&amp;&amp;&amp;&amp;&amp;&amp;&amp; </node>"), STR("test&&&&&&&"), parse_escapes },
- { STR(" test&amp;&amp;&amp;&amp;&amp;&amp;&amp; "), STR("test&&&&&&&"), parse_fragment | parse_escapes }
+ { STR(" test&amp;&amp;&amp;&amp;&amp;&amp;&amp; "), STR("test&&&&&&&"), parse_fragment | parse_escapes },
+ { STR("<node>\r\n\t text \t\n\r m&amp;&amp;e \r\n\t</node>"), STR("text \t\n\n m&&e"), parse_eol | parse_escapes }
};
for (size_t i = 0; i < sizeof(test_data) / sizeof(test_data[0]); ++i)
diff --git a/tests/test_xpath_functions.cpp b/tests/test_xpath_functions.cpp
index 7245bee..30ba218 100644
--- a/tests/test_xpath_functions.cpp
+++ b/tests/test_xpath_functions.cpp
@@ -414,6 +414,13 @@ TEST(xpath_string_substring_after)
CHECK_XPATH_FAIL(STR("substring-after('a', 'b', 'c')"));
}
+TEST_XML(xpath_string_substring_after_heap, "<node>foo<child/>bar</node>")
+{
+ CHECK_XPATH_STRING(doc, STR("substring-after(node, 'fo')"), STR("obar"));
+ CHECK_XPATH_STRING(doc, STR("substring-after(node, 'fooba')"), STR("r"));
+ CHECK_XPATH_STRING(doc, STR("substring-after(node, 'foobar')"), STR(""));
+}
+
TEST(xpath_string_substring)
{
xml_node c;
@@ -474,6 +481,13 @@ TEST(xpath_string_substring)
CHECK_XPATH_FAIL(STR("substring('', 1, 2, 3)"));
}
+TEST_XML(xpath_string_substring_heap, "<node>foo<child/>bar</node>")
+{
+ CHECK_XPATH_STRING(doc, STR("substring(node, 3)"), STR("obar"));
+ CHECK_XPATH_STRING(doc, STR("substring(node, 6)"), STR("r"));
+ CHECK_XPATH_STRING(doc, STR("substring(node, 7)"), STR(""));
+}
+
TEST_XML(xpath_string_string_length, "<node>123</node>")
{
xml_node c;