summaryrefslogtreecommitdiff
path: root/tests/test_xpath_paths.cpp
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2014-10-05 08:39:44 +0000
committerArseny Kapoulkine <arseny.kapoulkine@gmail.com>2014-10-05 08:39:44 +0000
commit9e6dcc292da05781c50822ce2966ac932e5e7438 (patch)
tree31a2bc01b1095825acb4621afca48d86bd01c57a /tests/test_xpath_paths.cpp
parent89f2f00da45dd213890a7f38247399b5b8a3eb78 (diff)
tests: Add XPath sorting test
git-svn-id: https://pugixml.googlecode.com/svn/trunk@1054 99668b35-9821-0410-8761-19e4c4f06640
Diffstat (limited to 'tests/test_xpath_paths.cpp')
-rw-r--r--tests/test_xpath_paths.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/test_xpath_paths.cpp b/tests/test_xpath_paths.cpp
index 45579a9..c18acd2 100644
--- a/tests/test_xpath_paths.cpp
+++ b/tests/test_xpath_paths.cpp
@@ -539,4 +539,20 @@ TEST_XML(xpath_paths_precision, "<node><para/><para/><para/><para/><para/></node
CHECK_XPATH_NODESET(doc, STR("//para[6 * (1 div 3) - 1]")) % 3;
}
+TEST_XML(xpath_paths_unsorted_child, "<node><foo><bar/></foo><node><foo><bar/></foo></node><foo><bar/></foo></node>")
+{
+ CHECK_XPATH_NODESET(doc, STR("//node/foo")) % 3 % 6 % 8;
+ CHECK_XPATH_NODESET(doc, STR("//node/foo/bar")) % 4 % 7 % 9;
+
+ xpath_node_set ns = doc.select_nodes(STR("//node/foo/bar"));
+ CHECK(ns.type() == xpath_node_set::type_unsorted);
+
+ xpath_node_set nss = ns;
+ nss.sort();
+
+ CHECK(ns[0] == nss[0]);
+ CHECK(ns[1] == nss[2]);
+ CHECK(ns[2] == nss[1]);
+}
+
#endif