mirror of
https://github.com/zeux/pugixml.git
synced 2024-12-26 21:04:25 +08:00
tests: Add missing tests to increase code coverage
git-svn-id: https://pugixml.googlecode.com/svn/trunk@1038 99668b35-9821-0410-8761-19e4c4f06640
This commit is contained in:
parent
00e1219bec
commit
3fcc530b34
@ -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>"));
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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&&&&&&& </node>"), STR("test&&&&&&&"), 0 },
|
||||
{ STR("<node> test&&&&&&& </node>"), STR("test&&&&&&&"), parse_escapes },
|
||||
{ STR(" test&&&&&&& "), STR("test&&&&&&&"), parse_fragment | parse_escapes }
|
||||
{ STR(" test&&&&&&& "), STR("test&&&&&&&"), parse_fragment | parse_escapes },
|
||||
{ STR("<node>\r\n\t text \t\n\r m&&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)
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user