summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2017-02-04 18:43:43 -0800
committerArseny Kapoulkine <arseny.kapoulkine@gmail.com>2017-02-05 21:12:55 -0800
commit10676b6b8548ddbf9458993062e6a27c2c233d48 (patch)
tree85c96e92afb2e3437b0eb20c805227b91e5e69f2 /tests
parentbcc7ed57a2b6155c30ec871bb12ffae110fcf558 (diff)
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.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_xpath.cpp11
1 files changed, 11 insertions, 0 deletions
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, "<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;