summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2010-09-14 05:43:13 +0000
committerarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2010-09-14 05:43:13 +0000
commit91f097d34d4a0b15fad37b61f53021e17930174c (patch)
treef2f4972f860dd98c5848ce5e22842bbdf6b79ed8
parent9f1ae76452d237bd486d7399f9f2c46530a5ad86 (diff)
tests: Improved XPath sort coverage
git-svn-id: http://pugixml.googlecode.com/svn/trunk@730 99668b35-9821-0410-8761-19e4c4f06640
-rw-r--r--tests/test_xpath.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/test_xpath.cpp b/tests/test_xpath.cpp
index 1c1629f..e6ac2cf 100644
--- a/tests/test_xpath.cpp
+++ b/tests/test_xpath.cpp
@@ -7,6 +7,8 @@
#include <wchar.h>
#include <string>
+#include <vector>
+#include <algorithm>
static void load_document_copy(xml_document& doc, const char_t* text)
{
@@ -120,6 +122,24 @@ TEST_XML(xpath_sort_attributes, "<node/>")
xpath_node_set_tester(reverse_sorted, "reverse sorted order failed") % 5 % 4 % 3;
}
+TEST(xpath_sort_random_large)
+{
+ xml_document doc;
+ load_document_copy(doc, STR("<node><child1 attr1='value1' attr2='value2'/><child2 attr1='value1'>test</child2><child1 attr1='value1' attr2='value2'/><child2 attr1='value1'>test</child2><child1 attr1='value1' attr2='value2'/><child2 attr1='value1'>test</child2><child1 attr1='value1' attr2='value2'/><child2 attr1='value1'>test</child2><child1 attr1='value1' attr2='value2'/><child2 attr1='value1'>test</child2><child1 attr1='value1' attr2='value2'/><child2 attr1='value1'>test</child2><child1 attr1='value1' attr2='value2'/><child2 attr1='value1'>test</child2><child1 attr1='value1' attr2='value2'/><child2 attr1='value1'>test</child2><child1 attr1='value1' attr2='value2'/><child2 attr1='value1'>test</child2><child1 attr1='value1' attr2='value2'/><child2 attr1='value1'>test</child2><child1 attr1='value1' attr2='value2'/><child2 attr1='value1'>test</child2><child1 attr1='value1' attr2='value2'/><child2 attr1='value1'>test</child2><child1 attr1='value1' attr2='value2'/><child2 attr1='value1'>test</child2><child1 attr1='value1' attr2='value2'/><child2 attr1='value1'>test</child2><child1 attr1='value1' attr2='value2'/><child2 attr1='value1'>test</child2><child1 attr1='value1' attr2='value2'/><child2 attr1='value1'>test</child2><child1 attr1='value1' attr2='value2'/><child2 attr1='value1'>test</child2><child1 attr1='value1' attr2='value2'/><child2 attr1='value1'>test</child2><child1 attr1='value1' attr2='value2'/><child2 attr1='value1'>test</child2><child1 attr1='value1' attr2='value2'/><child2 attr1='value1'>test</child2><child1 attr1='value1' attr2='value2'/><child2 attr1='value1'>test</child2></node>"));
+
+ xpath_node_set ns = doc.select_nodes(STR("//node() | //@*"));
+
+ std::vector<xpath_node> nsv(ns.begin(), ns.end());
+ std::random_shuffle(nsv.begin(), nsv.end());
+
+ xpath_node_set copy(&nsv[0], &nsv[0] + nsv.size());
+ copy.sort();
+
+ xpath_node_set_tester tester(copy, "sorted order failed");
+
+ for (unsigned int i = 2; i < 129; ++i) tester % i;
+}
+
TEST(xpath_long_numbers_parse)
{
const pugi::char_t* str_flt_max = STR("340282346638528860000000000000000000000");