0
0
mirror of https://github.com/zeux/pugixml.git synced 2024-12-28 06:10:55 +08:00

tests: Add more XPath sorting tests

Cover empty node case - no XPath query can result in that but it's
possible to create a node set with empty nodes manually.
This commit is contained in:
Arseny Kapoulkine 2017-02-04 18:43:43 -08:00
parent bcc7ed57a2
commit 10676b6b85

View File

@ -672,6 +672,17 @@ TEST(xpath_sort_crossdoc_different_depth)
CHECK((ns[0] == ns1[0] && ns[1] == ns2[0]) || (ns[0] == ns2[0] && ns[1] == ns1[0]));
}
TEST_XML(xpath_sort_empty_node, "<node><child1/><child2/></node>")
{
xml_node n = doc.child(STR("node"));
xpath_node nodes[] = { n.child(STR("child2")), xml_node(), n.child(STR("child1")), xml_node() };
xpath_node_set ns(nodes, nodes + sizeof(nodes) / sizeof(nodes[0]));
ns.sort();
CHECK(!ns[0] && !ns[1] && ns[2] == nodes[2] && ns[3] == nodes[0]);
}
TEST(xpath_allocate_string_out_of_memory)
{
std::basic_string<char_t> query;