From 10676b6b8548ddbf9458993062e6a27c2c233d48 Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Sat, 4 Feb 2017 18:43:43 -0800 Subject: 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. --- tests/test_xpath.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/test_xpath.cpp b/tests/test_xpath.cpp index 9cf8bd5..6cae607 100644 --- a/tests/test_xpath.cpp +++ b/tests/test_xpath.cpp @@ -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, "") +{ + 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 query; -- cgit v1.2.3