From f889bf88c09ecfe7f68deab6db53fa979110824c Mon Sep 17 00:00:00 2001 From: "arseny.kapoulkine" Date: Thu, 22 Jul 2010 08:04:02 +0000 Subject: tests: Removed invalid document order test, improved document order coverage by adding tests that are not subject to document order optimization git-svn-id: http://pugixml.googlecode.com/svn/trunk@615 99668b35-9821-0410-8761-19e4c4f06640 --- tests/test_xpath.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'tests/test_xpath.cpp') diff --git a/tests/test_xpath.cpp b/tests/test_xpath.cpp index 608859f..c615f36 100644 --- a/tests/test_xpath.cpp +++ b/tests/test_xpath.cpp @@ -8,6 +8,14 @@ #include +static void load_document_copy(xml_document& doc, const char_t* text) +{ + xml_document source; + CHECK(source.load(text)); + + doc.append_copy(source.first_child()); +} + TEST(xpath_allocator_many_pages) { pugi::string_t query = STR("0"); @@ -41,6 +49,24 @@ TEST_XML(xpath_sort_complex, "test"); + + // just some random union order, it should not matter probably? + xpath_node_set ns = doc.child(STR("node")).select_nodes(STR("child1 | child2 | child1/@* | . | child2/@* | child2/text()")); + + ns.sort(false); + xpath_node_set sorted = ns; + + ns.sort(true); + xpath_node_set reverse_sorted = ns; + + xpath_node_set_tester(sorted, "sorted order failed") % 2 % 3 % 4 % 5 % 6 % 7 % 8; + xpath_node_set_tester(reverse_sorted, "reverse sorted order failed") % 8 % 7 % 6 % 5 % 4 % 3 % 2; +} + TEST_XML(xpath_sort_children, "") { xpath_node_set ns = doc.child(STR("node")).select_nodes(STR("child/subchild[@id=1] | child/subchild[@id=2]")); @@ -55,6 +81,23 @@ TEST_XML(xpath_sort_children, ""); + + xpath_node_set ns = doc.child(STR("node")).select_nodes(STR("child/subchild[@id=1] | child/subchild[@id=2]")); + + ns.sort(false); + xpath_node_set sorted = ns; + + ns.sort(true); + xpath_node_set reverse_sorted = ns; + + xpath_node_set_tester(sorted, "sorted order failed") % 4 % 7; + xpath_node_set_tester(reverse_sorted, "reverse sorted order failed") % 7 % 4; +} + TEST_XML(xpath_sort_attributes, "") { xml_node n = doc.child(STR("node")); -- cgit v1.2.3