summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2010-05-09 20:37:49 +0000
committerarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2010-05-09 20:37:49 +0000
commit5ff56a6d68ce6fbab0980232d95b5d190e2ecdcf (patch)
tree734c2f28e532135fe7a2088be48f98c7b44cc5fd /tests
parente96af87b5dc678a64aad061cc2955eaa463c09a2 (diff)
Removed document order optimization (it helps on a tiny percentage of queries), XPath tests now compute their own order
git-svn-id: http://pugixml.googlecode.com/svn/trunk@400 99668b35-9821-0410-8761-19e4c4f06640
Diffstat (limited to 'tests')
-rw-r--r--tests/test.cpp64
-rw-r--r--tests/test.hpp6
-rw-r--r--tests/test_xpath.cpp24
-rw-r--r--tests/test_xpath_api.cpp18
-rw-r--r--tests/test_xpath_functions.cpp4
-rw-r--r--tests/test_xpath_operators.cpp2
-rw-r--r--tests/test_xpath_paths.cpp60
-rw-r--r--tests/test_xpath_paths_abbrev_w3c.cpp46
-rw-r--r--tests/test_xpath_paths_w3c.cpp66
9 files changed, 65 insertions, 225 deletions
diff --git a/tests/test.cpp b/tests/test.cpp
index ebd4bf4..1744e4f 100644
--- a/tests/test.cpp
+++ b/tests/test.cpp
@@ -1,3 +1,5 @@
+#define _SCL_SECURE_NO_WARNINGS
+
#include "test.hpp"
#include "writer_string.hpp"
@@ -5,6 +7,38 @@
#include <math.h>
#include <float.h>
+#include <algorithm>
+#include <vector>
+
+#ifndef PUGIXML_NO_XPATH
+static void build_document_order(std::vector<pugi::xpath_node>& result, pugi::xml_node root)
+{
+ result.push_back(pugi::xpath_node());
+
+ pugi::xml_node cur = root;
+
+ for (;;)
+ {
+ result.push_back(cur);
+
+ for (pugi::xml_attribute a = cur.first_attribute(); a; a = a.next_attribute())
+ result.push_back(pugi::xpath_node(a, cur));
+
+ if (cur.first_child())
+ cur = cur.first_child();
+ else if (cur.next_sibling())
+ cur = cur.next_sibling();
+ else
+ {
+ while (cur && !cur.next_sibling()) cur = cur.parent();
+ cur = cur.next_sibling();
+
+ if (!cur) break;
+ }
+ }
+}
+#endif
+
bool test_string_equal(const pugi::char_t* lhs, const pugi::char_t* rhs)
{
return (!lhs || !rhs) ? lhs == rhs : pugi::impl::strequal(lhs, rhs);
@@ -82,21 +116,33 @@ void xpath_node_set_tester::check(bool condition)
}
}
-xpath_node_set_tester::xpath_node_set_tester(const pugi::xml_node& node, const pugi::char_t* query, const char* message): last(0), message(message)
-{
- pugi::xpath_query q(query);
- result = q.evaluate_node_set(node);
-}
-
xpath_node_set_tester::xpath_node_set_tester(const pugi::xpath_node_set& set, const char* message): last(0), message(message)
{
result = set;
+
+ if (result.empty())
+ {
+ document_order = 0;
+ document_size = 0;
+ }
+ else
+ {
+ std::vector<pugi::xpath_node> order;
+ build_document_order(order, (result[0].attribute() ? result[0].parent() : result[0].node()).root());
+
+ document_order = new pugi::xpath_node[order.size()];
+ std::copy(order.begin(), order.end(), document_order);
+
+ document_size = order.size();
+ }
}
xpath_node_set_tester::~xpath_node_set_tester()
{
// check that we processed everything
check(last == result.size());
+
+ delete[] document_order;
}
xpath_node_set_tester& xpath_node_set_tester::operator%(unsigned int expected)
@@ -105,10 +151,8 @@ xpath_node_set_tester& xpath_node_set_tester::operator%(unsigned int expected)
check(last < result.size());
// check document order
- pugi::xpath_node node = result.begin()[last];
- unsigned int order = node.attribute() ? node.attribute().document_order() : node.node().document_order();
-
- check(order == expected);
+ check(expected < document_size);
+ check(result.begin()[last] == document_order[expected]);
// continue to the next element
last++;
diff --git a/tests/test.hpp b/tests/test.hpp
index be42b8b..49fd3a1 100644
--- a/tests/test.hpp
+++ b/tests/test.hpp
@@ -45,13 +45,15 @@ bool test_xpath_fail_compile(const pugi::char_t* query);
struct xpath_node_set_tester
{
+ pugi::xpath_node* document_order;
+ size_t document_size;
+
pugi::xpath_node_set result;
unsigned int last;
const char* message;
void check(bool condition);
- xpath_node_set_tester(const pugi::xml_node& node, const pugi::char_t* query, const char* message);
xpath_node_set_tester(const pugi::xpath_node_set& set, const char* message);
~xpath_node_set_tester();
@@ -123,7 +125,7 @@ struct dummy_fixture {};
#define CHECK_XPATH_NUMBER(node, query, expected) CHECK_TEXT(test_xpath_number(node, query, expected), STRINGIZE(query) " does not evaluate to " STRINGIZE(expected) " in context " STRINGIZE(node))
#define CHECK_XPATH_NUMBER_NAN(node, query) CHECK_TEXT(test_xpath_number_nan(node, query), STRINGIZE(query) " does not evaluate to NaN in context " STRINGIZE(node))
#define CHECK_XPATH_FAIL(query) CHECK_TEXT(test_xpath_fail_compile(query), STRINGIZE(query) " should not compile")
-#define CHECK_XPATH_NODESET(node, query) xpath_node_set_tester(node, query, CHECK_JOIN2(STRINGIZE(query) " does not evaluate to expected set in context " STRINGIZE(node), " at "__FILE__ ":", __LINE__))
+#define CHECK_XPATH_NODESET(node, query) xpath_node_set_tester(node.select_nodes(query), CHECK_JOIN2(STRINGIZE(query) " does not evaluate to expected set in context " STRINGIZE(node), " at "__FILE__ ":", __LINE__))
#endif
#define STR(text) PUGIXML_TEXT(text)
diff --git a/tests/test_xpath.cpp b/tests/test_xpath.cpp
index 7ef34ec..e2c5edb 100644
--- a/tests/test_xpath.cpp
+++ b/tests/test_xpath.cpp
@@ -8,24 +8,6 @@
#include <string>
-TEST_XML(xpath_document_order, "<node><child1 attr1='value1' attr2='value2'/><child2 attr1='value1'>test</child2></node>")
-{
- CHECK(xml_node().document_order() == 0);
- CHECK(doc.child(STR("node")).document_order() == 0);
- CHECK(doc.document_order() == 0);
-
- doc.precompute_document_order();
-
- CHECK(doc.document_order() == 1);
- CHECK(doc.child(STR("node")).document_order() == 2);
- CHECK(doc.child(STR("node")).child(STR("child1")).document_order() == 3);
- CHECK(doc.child(STR("node")).child(STR("child1")).attribute(STR("attr1")).document_order() == 4);
- CHECK(doc.child(STR("node")).child(STR("child1")).attribute(STR("attr2")).document_order() == 5);
- CHECK(doc.child(STR("node")).child(STR("child2")).document_order() == 6);
- CHECK(doc.child(STR("node")).child(STR("child2")).attribute(STR("attr1")).document_order() == 7);
- CHECK(doc.child(STR("node")).child(STR("child2")).first_child().document_order() == 8);
-}
-
TEST(xpath_allocator_many_pages)
{
pugi::string_t query = STR("0");
@@ -55,8 +37,6 @@ TEST_XML(xpath_sort_complex, "<node><child1 attr1='value1' attr2='value2'/><chil
ns.sort(true);
xpath_node_set reverse_sorted = ns;
- doc.precompute_document_order();
-
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;
}
@@ -71,8 +51,6 @@ TEST_XML(xpath_sort_children, "<node><child><subchild id='1'/></child><child><su
ns.sort(true);
xpath_node_set reverse_sorted = ns;
- doc.precompute_document_order();
-
xpath_node_set_tester(sorted, "sorted order failed") % 4 % 7;
xpath_node_set_tester(reverse_sorted, "reverse sorted order failed") % 7 % 4;
}
@@ -95,8 +73,6 @@ TEST_XML(xpath_sort_attributes, "<node/>")
ns.sort(false);
xpath_node_set sorted = ns;
- doc.precompute_document_order();
-
xpath_node_set_tester(sorted, "sorted order failed") % 3 % 4 % 5;
xpath_node_set_tester(reverse_sorted, "reverse sorted order failed") % 5 % 4 % 3;
}
diff --git a/tests/test_xpath_api.cpp b/tests/test_xpath_api.cpp
index d7cc094..453220d 100644
--- a/tests/test_xpath_api.cpp
+++ b/tests/test_xpath_api.cpp
@@ -8,28 +8,24 @@
TEST_XML(xpath_api_select_nodes, "<node><head/><foo/><foo/><tail/></node>")
{
- doc.precompute_document_order();
-
xpath_node_set ns1 = doc.select_nodes(STR("node/foo"));
xpath_query q(STR("node/foo"));
xpath_node_set ns2 = doc.select_nodes(q);
- CHECK(ns1.size() == 2 && ns1[0].node().document_order() == 4 && ns1[1].node().document_order() == 5);
- CHECK(ns2.size() == 2 && ns2[0].node().document_order() == 4 && ns2[1].node().document_order() == 5);
+ xpath_node_set_tester(ns1, "ns1") % 4 % 5;
+ xpath_node_set_tester(ns2, "ns2") % 4 % 5;
}
-TEST_XML(xpath_api_select_single_node, "<node><head/><foo/><foo/><tail/></node>")
+TEST_XML(xpath_api_select_single_node, "<node><head/><foo id='1'/><foo/><tail/></node>")
{
- doc.precompute_document_order();
-
xpath_node n1 = doc.select_single_node(STR("node/foo"));
xpath_query q(STR("node/foo"));
xpath_node n2 = doc.select_single_node(q);
- CHECK(n1.node().document_order() == 4);
- CHECK(n2.node().document_order() == 4);
+ CHECK(n1.node().attribute(STR("id")).as_int() == 1);
+ CHECK(n2.node().attribute(STR("id")).as_int() == 1);
xpath_node n3 = doc.select_single_node(STR("node/bar"));
@@ -38,8 +34,8 @@ TEST_XML(xpath_api_select_single_node, "<node><head/><foo/><foo/><tail/></node>"
xpath_node n4 = doc.select_single_node(STR("node/head/following-sibling::foo"));
xpath_node n5 = doc.select_single_node(STR("node/tail/preceding-sibling::foo"));
- CHECK(n4.node().document_order() == 4);
- CHECK(n5.node().document_order() == 4);
+ CHECK(n4.node().attribute(STR("id")).as_int() == 1);
+ CHECK(n5.node().attribute(STR("id")).as_int() == 1);
}
TEST(xpath_api_exception_what)
diff --git a/tests/test_xpath_functions.cpp b/tests/test_xpath_functions.cpp
index ed18e5f..7e98181 100644
--- a/tests/test_xpath_functions.cpp
+++ b/tests/test_xpath_functions.cpp
@@ -504,8 +504,6 @@ TEST(xpath_string_translate)
TEST_XML(xpath_nodeset_last, "<node><c1/><c1/><c2/><c3/><c3/><c3/><c3/></node>")
{
- doc.precompute_document_order();
-
xml_node n = doc.child(STR("node"));
// last with 0 arguments
@@ -520,8 +518,6 @@ TEST_XML(xpath_nodeset_last, "<node><c1/><c1/><c2/><c3/><c3/><c3/><c3/></node>")
TEST_XML(xpath_nodeset_position, "<node><c1/><c1/><c2/><c3/><c3/><c3/><c3/></node>")
{
- doc.precompute_document_order();
-
xml_node n = doc.child(STR("node"));
// position with 0 arguments
diff --git a/tests/test_xpath_operators.cpp b/tests/test_xpath_operators.cpp
index 79202a7..3c1f69c 100644
--- a/tests/test_xpath_operators.cpp
+++ b/tests/test_xpath_operators.cpp
@@ -404,8 +404,6 @@ TEST(xpath_operators_boolean_precedence)
TEST_XML(xpath_operators_union, "<node><employee/><employee secretary=''/><employee assistant=''/><employee secretary='' assistant=''/><employee assistant='' secretary=''/><tail/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
diff --git a/tests/test_xpath_paths.cpp b/tests/test_xpath_paths.cpp
index 47ebada..4da3989 100644
--- a/tests/test_xpath_paths.cpp
+++ b/tests/test_xpath_paths.cpp
@@ -4,8 +4,6 @@
TEST_XML(xpath_paths_axes_child, "<node attr='value'><child attr='value'><subchild/></child><another/><last/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -17,8 +15,6 @@ TEST_XML(xpath_paths_axes_child, "<node attr='value'><child attr='value'><subchi
TEST_XML(xpath_paths_axes_descendant, "<node attr='value'><child attr='value'><subchild/></child><another><subchild/></another><last/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -32,8 +28,6 @@ TEST_XML(xpath_paths_axes_descendant, "<node attr='value'><child attr='value'><s
TEST_XML(xpath_paths_axes_parent, "<node attr='value'><child attr='value'><subchild/></child><another><subchild/></another><last/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -48,8 +42,6 @@ TEST_XML(xpath_paths_axes_parent, "<node attr='value'><child attr='value'><subch
TEST_XML(xpath_paths_axes_ancestor, "<node attr='value'><child attr='value'><subchild/></child><another><subchild/></another><last/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -64,8 +56,6 @@ TEST_XML(xpath_paths_axes_ancestor, "<node attr='value'><child attr='value'><sub
TEST_XML(xpath_paths_axes_following_sibling, "<node attr1='value' attr2='value'><child attr='value'><subchild/></child><another><subchild/></another><last/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -78,8 +68,6 @@ TEST_XML(xpath_paths_axes_following_sibling, "<node attr1='value' attr2='value'>
TEST_XML(xpath_paths_axes_preceding_sibling, "<node attr1='value' attr2='value'><child attr='value'><subchild/></child><another><subchild/></another><last/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -92,8 +80,6 @@ TEST_XML(xpath_paths_axes_preceding_sibling, "<node attr1='value' attr2='value'>
TEST_XML(xpath_paths_axes_following, "<node attr1='value' attr2='value'><child attr='value'><subchild/></child><another><subchild/></another><almost/><last/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -107,8 +93,6 @@ TEST_XML(xpath_paths_axes_following, "<node attr1='value' attr2='value'><child a
TEST_XML(xpath_paths_axes_preceding, "<node attr1='value' attr2='value'><child attr='value'><subchild/></child><another><subchild/></another><almost/><last/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -122,8 +106,6 @@ TEST_XML(xpath_paths_axes_preceding, "<node attr1='value' attr2='value'><child a
TEST_XML(xpath_paths_axes_attribute, "<node attr1='value' attr2='value'><child attr='value'><subchild/></child><another xmlns:foo='bar'><subchild/></another><last/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -145,8 +127,6 @@ TEST_XML(xpath_paths_axes_namespace, "<node xmlns:foo='bar'/>")
TEST_XML(xpath_paths_axes_self, "<node attr='value'><child attr='value'><subchild/></child><another><subchild/></another><last/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -161,8 +141,6 @@ TEST_XML(xpath_paths_axes_self, "<node attr='value'><child attr='value'><subchil
TEST_XML(xpath_paths_axes_descendant_or_self, "<node attr='value'><child attr='value'><subchild/></child><another><subchild/></another><last/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -176,8 +154,6 @@ TEST_XML(xpath_paths_axes_descendant_or_self, "<node attr='value'><child attr='v
TEST_XML(xpath_paths_axes_ancestor_or_self, "<node attr='value'><child attr='value'><subchild/></child><another><subchild/></another><last/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -192,8 +168,6 @@ TEST_XML(xpath_paths_axes_ancestor_or_self, "<node attr='value'><child attr='val
TEST_XML(xpath_paths_axes_abbrev, "<node attr='value'><foo/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -213,8 +187,6 @@ TEST_XML(xpath_paths_axes_abbrev, "<node attr='value'><foo/></node>")
TEST_XML(xpath_paths_nodetest_all, "<node a1='v1' x:a2='v2'><c1/><x:c2/><c3/><x:c4/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -228,8 +200,6 @@ TEST_XML(xpath_paths_nodetest_all, "<node a1='v1' x:a2='v2'><c1/><x:c2/><c3/><x:
TEST_XML_FLAGS(xpath_paths_nodetest_name, "<node a1='v1' x:a2='v2'><c1/><x:c2/><c3/><x:c4/><?c1?></node>", parse_default | parse_pi)
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -249,8 +219,6 @@ TEST_XML_FLAGS(xpath_paths_nodetest_name, "<node a1='v1' x:a2='v2'><c1/><x:c2/><
TEST_XML(xpath_paths_nodetest_all_in_namespace, "<node a1='v1' x:a2='v2'><c1/><x:c2/><c3/><x:c4/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -269,8 +237,6 @@ TEST_XML(xpath_paths_nodetest_all_in_namespace, "<node a1='v1' x:a2='v2'><c1/><x
TEST_XML_FLAGS(xpath_paths_nodetest_type, "<node attr='value'>pcdata<child/><?pi1 value?><?pi2 value?><!--comment--><![CDATA[cdata]]></node>", parse_default | parse_pi | parse_comments)
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -305,8 +271,6 @@ TEST_XML_FLAGS(xpath_paths_nodetest_type, "<node attr='value'>pcdata<child/><?pi
TEST_XML(xpath_paths_absolute, "<node><foo><foo/><foo/></foo></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -322,8 +286,6 @@ TEST_XML(xpath_paths_absolute, "<node><foo><foo/><foo/></foo></node>")
TEST_XML(xpath_paths_step_abbrev, "<node><foo/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -341,8 +303,6 @@ TEST_XML(xpath_paths_step_abbrev, "<node><foo/></node>")
TEST_XML(xpath_paths_relative_abbrev, "<node><foo><foo/><foo/></foo></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -355,8 +315,6 @@ TEST_XML(xpath_paths_relative_abbrev, "<node><foo><foo/><foo/></foo></node>")
TEST_XML(xpath_paths_absolute_abbrev, "<node><foo><foo/><foo/></foo></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -369,8 +327,6 @@ TEST_XML(xpath_paths_absolute_abbrev, "<node><foo><foo/><foo/></foo></node>")
TEST_XML(xpath_paths_predicate_boolean, "<node><chapter/><chapter/><chapter/><chapter/><chapter/></node>")
{
- doc.precompute_document_order();
-
xml_node n = doc.child(STR("node")).child(STR("chapter")).next_sibling().next_sibling();
CHECK_XPATH_NODESET(n, STR("following-sibling::chapter[position()=1]")) % 6;
@@ -381,8 +337,6 @@ TEST_XML(xpath_paths_predicate_boolean, "<node><chapter/><chapter/><chapter/><ch
TEST_XML(xpath_paths_predicate_number, "<node><chapter/><chapter/><chapter/><chapter/><chapter/></node>")
{
- doc.precompute_document_order();
-
xml_node n = doc.child(STR("node")).child(STR("chapter")).next_sibling().next_sibling();
CHECK_XPATH_NODESET(n, STR("following-sibling::chapter[1]")) % 6;
@@ -393,8 +347,6 @@ TEST_XML(xpath_paths_predicate_number, "<node><chapter/><chapter/><chapter/><cha
TEST_XML(xpath_paths_predicate_several, "<node><employee/><employee secretary=''/><employee assistant=''/><employee secretary='' assistant=''/><employee assistant='' secretary=''/></node>")
{
- doc.precompute_document_order();
-
xml_node n = doc.child(STR("node"));
CHECK_XPATH_NODESET(n, STR("employee")) % 3 % 4 % 6 % 8 % 11;
@@ -407,8 +359,6 @@ TEST_XML(xpath_paths_predicate_several, "<node><employee/><employee secretary=''
TEST_XML(xpath_paths_predicate_filter_boolean, "<node><chapter/><chapter/><chapter/><chapter/><chapter/></node>")
{
- doc.precompute_document_order();
-
xml_node n = doc.child(STR("node")).child(STR("chapter")).next_sibling().next_sibling();
CHECK_XPATH_NODESET(n, STR("(following-sibling::chapter)[position()=1]")) % 6;
@@ -419,8 +369,6 @@ TEST_XML(xpath_paths_predicate_filter_boolean, "<node><chapter/><chapter/><chapt
TEST_XML(xpath_paths_predicate_filter_number, "<node><chapter/><chapter/><chapter/><chapter/><chapter/></node>")
{
- doc.precompute_document_order();
-
xml_node n = doc.child(STR("node")).child(STR("chapter")).next_sibling().next_sibling();
CHECK_XPATH_NODESET(n, STR("(following-sibling::chapter)[1]")) % 6;
@@ -431,8 +379,6 @@ TEST_XML(xpath_paths_predicate_filter_number, "<node><chapter/><chapter/><chapte
TEST_XML(xpath_paths_predicate_filter_posinv, "<node><employee/><employee secretary=''/><employee assistant=''/><employee secretary='' assistant=''/><employee assistant='' secretary=''/></node>")
{
- doc.precompute_document_order();
-
xml_node n = doc.child(STR("node"));
CHECK_XPATH_NODESET(n, STR("employee")) % 3 % 4 % 6 % 8 % 11;
@@ -442,8 +388,6 @@ TEST_XML(xpath_paths_predicate_filter_posinv, "<node><employee/><employee secret
TEST_XML(xpath_paths_step_compose, "<node><foo><foo/><foo/></foo><foo/></node>")
{
- doc.precompute_document_order();
-
xml_node n = doc.child(STR("node"));
CHECK_XPATH_NODESET(n, STR("(.)/foo")) % 3 % 6;
@@ -456,8 +400,6 @@ TEST_XML(xpath_paths_step_compose, "<node><foo><foo/><foo/></foo><foo/></node>")
TEST_XML(xpath_paths_descendant_double_slash_w3c, "<node><para><para/><para/><para><para/></para></para><para/></node>")
{
- doc.precompute_document_order();
-
CHECK_XPATH_NODESET(doc, STR("//para")) % 3 % 4 % 5 % 6 % 7 % 8;
CHECK_XPATH_NODESET(doc, STR("/descendant::para")) % 3 % 4 % 5 % 6 % 7 % 8;
CHECK_XPATH_NODESET(doc, STR("//para[1]")) % 3 % 4 % 7;
@@ -466,8 +408,6 @@ TEST_XML(xpath_paths_descendant_double_slash_w3c, "<node><para><para/><para/><pa
TEST_XML(xpath_paths_needs_sorting, "<node><child/><child/><child><subchild/><subchild/></child></node>")
{
- doc.precompute_document_order();
-
CHECK_XPATH_NODESET(doc, STR("(node/child/subchild)[2]")) % 7;
}
diff --git a/tests/test_xpath_paths_abbrev_w3c.cpp b/tests/test_xpath_paths_abbrev_w3c.cpp
index 7fd092c..ebd13aa 100644
--- a/tests/test_xpath_paths_abbrev_w3c.cpp
+++ b/tests/test_xpath_paths_abbrev_w3c.cpp
@@ -4,8 +4,6 @@
TEST_XML(xpath_paths_abbrev_w3c_1, "<node><para/><foo/><para/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -15,8 +13,6 @@ TEST_XML(xpath_paths_abbrev_w3c_1, "<node><para/><foo/><para/></node>")
TEST_XML(xpath_paths_abbrev_w3c_2, "<node><para/><foo/><para/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -26,8 +22,6 @@ TEST_XML(xpath_paths_abbrev_w3c_2, "<node><para/><foo/><para/></node>")
TEST_XML(xpath_paths_abbrev_w3c_3, "<node>pcdata<child/><![CDATA[cdata]]></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -37,8 +31,6 @@ TEST_XML(xpath_paths_abbrev_w3c_3, "<node>pcdata<child/><![CDATA[cdata]]></node>
TEST_XML(xpath_paths_abbrev_w3c_4, "<node name='value' foo='bar' />")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -48,8 +40,6 @@ TEST_XML(xpath_paths_abbrev_w3c_4, "<node name='value' foo='bar' />")
TEST_XML(xpath_paths_abbrev_w3c_5, "<node name='value' foo='bar' />")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -59,8 +49,6 @@ TEST_XML(xpath_paths_abbrev_w3c_5, "<node name='value' foo='bar' />")
TEST_XML(xpath_paths_abbrev_w3c_6, "<node><para/><para/><para/><para/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -70,8 +58,6 @@ TEST_XML(xpath_paths_abbrev_w3c_6, "<node><para/><para/><para/><para/></node>")
TEST_XML(xpath_paths_abbrev_w3c_7, "<node><para/><para/><para/><para/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -81,8 +67,6 @@ TEST_XML(xpath_paths_abbrev_w3c_7, "<node><para/><para/><para/><para/></node>")
TEST_XML(xpath_paths_abbrev_w3c_8, "<node><para><para/><para/><foo><para/></foo></para><foo/><para/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
CHECK_XPATH_NODESET(c, STR("*/para"));
@@ -91,8 +75,6 @@ TEST_XML(xpath_paths_abbrev_w3c_8, "<node><para><para/><para/><foo><para/></foo>
TEST_XML(xpath_paths_abbrev_w3c_9, "<doc><chapter/><chapter/><chapter/><chapter/><chapter><section/><section/><section/></chapter><chapter/></doc>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("doc")).child(STR("chapter"));
@@ -103,8 +85,6 @@ TEST_XML(xpath_paths_abbrev_w3c_9, "<doc><chapter/><chapter/><chapter/><chapter/
TEST_XML(xpath_paths_abbrev_w3c_10, "<chapter><para><para/><para/><foo><para/></foo></para><foo/><para/></chapter>")
{
- doc.precompute_document_order();
-
xml_node c;
CHECK_XPATH_NODESET(c, STR("chapter//para"));
@@ -113,8 +93,6 @@ TEST_XML(xpath_paths_abbrev_w3c_10, "<chapter><para><para/><para/><foo><para/></
TEST_XML(xpath_paths_abbrev_w3c_11, "<node><para><para/><para/><foo><para/></foo></para><foo/><para/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -125,8 +103,6 @@ TEST_XML(xpath_paths_abbrev_w3c_11, "<node><para><para/><para/><foo><para/></foo
TEST_XML(xpath_paths_abbrev_w3c_12, "<node><olist><item/></olist><item/><olist><olist><item/><item/></olist></olist></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -137,8 +113,6 @@ TEST_XML(xpath_paths_abbrev_w3c_12, "<node><olist><item/></olist><item/><olist><
TEST_XML(xpath_paths_abbrev_w3c_13, "<node><child/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -149,8 +123,6 @@ TEST_XML(xpath_paths_abbrev_w3c_13, "<node><child/></node>")
TEST_XML(xpath_paths_abbrev_w3c_14, "<node><para><para/><para/><foo><para/></foo></para><foo/><para/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -161,8 +133,6 @@ TEST_XML(xpath_paths_abbrev_w3c_14, "<node><para><para/><para/><foo><para/></foo
TEST_XML(xpath_paths_abbrev_w3c_15, "<node lang='en'><child/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -173,8 +143,6 @@ TEST_XML(xpath_paths_abbrev_w3c_15, "<node lang='en'><child/></node>")
TEST_XML(xpath_paths_abbrev_w3c_16, "<node lang='en'><child/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -185,8 +153,6 @@ TEST_XML(xpath_paths_abbrev_w3c_16, "<node lang='en'><child/></node>")
TEST_XML(xpath_paths_abbrev_w3c_17, "<node><para/><para type='warning'/><para type='warning'/><para/><para type='error'/><para type='warning'/><para type='warning'/><para type='warning'/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -196,8 +162,6 @@ TEST_XML(xpath_paths_abbrev_w3c_17, "<node><para/><para type='warning'/><para ty
TEST_XML(xpath_paths_abbrev_w3c_18, "<node><para/><para type='warning'/><para type='warning'/><para/><para type='error'/><para type='warning'/><para type='warning'/><para type='warning'/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -207,8 +171,6 @@ TEST_XML(xpath_paths_abbrev_w3c_18, "<node><para/><para type='warning'/><para ty
TEST_XML(xpath_paths_abbrev_w3c_19a, "<node><para/><para type='warning'/><para type='warning'/><para/><para type='error'/><para type='warning'/><para type='warning'/><para type='warning'/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -218,8 +180,6 @@ TEST_XML(xpath_paths_abbrev_w3c_19a, "<node><para/><para type='warning'/><para t
TEST_XML(xpath_paths_abbrev_w3c_19b, "<node><para/><para type='warning'/><para type='warning'/><para/><para type='warning'/><para type='warning'/><para type='warning'/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -229,8 +189,6 @@ TEST_XML(xpath_paths_abbrev_w3c_19b, "<node><para/><para type='warning'/><para t
TEST_XML(xpath_paths_abbrev_w3c_20, "<node><chapter><title>foo</title></chapter><chapter><title>Introduction</title></chapter><chapter><title>introduction</title></chapter><chapter/><chapter><title>Introduction</title><title>foo</title></chapter></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -240,8 +198,6 @@ TEST_XML(xpath_paths_abbrev_w3c_20, "<node><chapter><title>foo</title></chapter>
TEST_XML(xpath_paths_abbrev_w3c_21, "<node><chapter><title>foo</title></chapter><chapter><title>Introduction</title></chapter><chapter><title>introduction</title></chapter><chapter/><chapter><title>Introduction</title><title>foo</title></chapter></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -251,8 +207,6 @@ TEST_XML(xpath_paths_abbrev_w3c_21, "<node><chapter><title>foo</title></chapter>
TEST_XML(xpath_paths_abbrev_w3c_22, "<node><employee/><employee secretary=''/><employee assistant=''/><employee secretary='' assistant=''/><employee assistant='' secretary=''/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
diff --git a/tests/test_xpath_paths_w3c.cpp b/tests/test_xpath_paths_w3c.cpp
index 75b9637..d3f1554 100644
--- a/tests/test_xpath_paths_w3c.cpp
+++ b/tests/test_xpath_paths_w3c.cpp
@@ -4,8 +4,6 @@
TEST_XML(xpath_paths_w3c_1, "<node><para/><foo/><para/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -15,8 +13,6 @@ TEST_XML(xpath_paths_w3c_1, "<node><para/><foo/><para/></node>")
TEST_XML(xpath_paths_w3c_2, "<node><para/><foo/><para/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -26,8 +22,6 @@ TEST_XML(xpath_paths_w3c_2, "<node><para/><foo/><para/></node>")
TEST_XML(xpath_paths_w3c_3, "<node>pcdata<child/><![CDATA[cdata]]></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -37,8 +31,6 @@ TEST_XML(xpath_paths_w3c_3, "<node>pcdata<child/><![CDATA[cdata]]></node>")
TEST_XML(xpath_paths_w3c_4, "<node>pcdata<child/><![CDATA[cdata]]></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -48,8 +40,6 @@ TEST_XML(xpath_paths_w3c_4, "<node>pcdata<child/><![CDATA[cdata]]></node>")
TEST_XML(xpath_paths_w3c_5, "<node name='value' foo='bar' />")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -59,8 +49,6 @@ TEST_XML(xpath_paths_w3c_5, "<node name='value' foo='bar' />")
TEST_XML(xpath_paths_w3c_6, "<node name='value' foo='bar' />")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -70,8 +58,6 @@ TEST_XML(xpath_paths_w3c_6, "<node name='value' foo='bar' />")
TEST_XML(xpath_paths_w3c_7, "<node><para><para/><para/><foo><para/></foo></para><foo/><para/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -82,8 +68,6 @@ TEST_XML(xpath_paths_w3c_7, "<node><para><para/><para/><foo><para/></foo></para>
TEST_XML(xpath_paths_w3c_8, "<node><div><font><div><div/></div></font></div></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -93,8 +77,6 @@ TEST_XML(xpath_paths_w3c_8, "<node><div><font><div><div/></div></font></div></no
TEST_XML(xpath_paths_w3c_9, "<node><div><font><div><div/></div></font></div></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -104,8 +86,6 @@ TEST_XML(xpath_paths_w3c_9, "<node><div><font><div><div/></div></font></div></no
TEST_XML(xpath_paths_w3c_10, "<node><para><para/><para/><foo><para/></foo></para><foo/><para/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -116,8 +96,6 @@ TEST_XML(xpath_paths_w3c_10, "<node><para><para/><para/><foo><para/></foo></para
TEST_XML(xpath_paths_w3c_11, "<node><para><para/><para/><foo><para/></foo></para><foo/><para/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -128,8 +106,6 @@ TEST_XML(xpath_paths_w3c_11, "<node><para><para/><para/><foo><para/></foo></para
TEST_XML(xpath_paths_w3c_12, "<chapter><para><para/><para/><foo><para/></foo></para><foo/><para/></chapter>")
{
- doc.precompute_document_order();
-
xml_node c;
CHECK_XPATH_NODESET(c, STR("child::chapter/descendant::para"));
@@ -138,8 +114,6 @@ TEST_XML(xpath_paths_w3c_12, "<chapter><para><para/><para/><foo><para/></foo></p
TEST_XML(xpath_paths_w3c_13, "<node><para><para/><para/><foo><para/></foo></para><foo/><para/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
CHECK_XPATH_NODESET(c, STR("child::*/child::para"));
@@ -148,8 +122,6 @@ TEST_XML(xpath_paths_w3c_13, "<node><para><para/><para/><foo><para/></foo></para
TEST_XML(xpath_paths_w3c_14, "<node><para><para/><para/><foo><para/></foo></para><foo/><para/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -162,8 +134,6 @@ TEST_XML(xpath_paths_w3c_14, "<node><para><para/><para/><foo><para/></foo></para
TEST_XML(xpath_paths_w3c_15, "<node><para><para/><para/><foo><para/></foo></para><foo/><para/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -174,8 +144,6 @@ TEST_XML(xpath_paths_w3c_15, "<node><para><para/><para/><foo><para/></foo></para
TEST_XML(xpath_paths_w3c_16, "<node><olist><item/></olist><item/><olist><olist><item/><item/></olist></olist></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -186,8 +154,6 @@ TEST_XML(xpath_paths_w3c_16, "<node><olist><item/></olist><item/><olist><olist><
TEST_XML(xpath_paths_w3c_17, "<node><para/><para/><para/><para/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -197,8 +163,6 @@ TEST_XML(xpath_paths_w3c_17, "<node><para/><para/><para/><para/></node>")
TEST_XML(xpath_paths_w3c_18, "<node><para/><para/><para/><para/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -208,8 +172,6 @@ TEST_XML(xpath_paths_w3c_18, "<node><para/><para/><para/><para/></node>")
TEST_XML(xpath_paths_w3c_19, "<node><para/><para/><para/><para/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -219,8 +181,6 @@ TEST_XML(xpath_paths_w3c_19, "<node><para/><para/><para/><para/></node>")
TEST_XML(xpath_paths_w3c_20, "<node><para/><para/><para/><para/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -230,8 +190,6 @@ TEST_XML(xpath_paths_w3c_20, "<node><para/><para/><para/><para/></node>")
TEST_XML(xpath_paths_w3c_21, "<node><chapter/><chapter/><chapter/><chapter/><chapter/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node")).child(STR("chapter")).next_sibling().next_sibling();
@@ -241,8 +199,6 @@ TEST_XML(xpath_paths_w3c_21, "<node><chapter/><chapter/><chapter/><chapter/><cha
TEST_XML(xpath_paths_w3c_22, "<node><chapter/><chapter/><chapter/><chapter/><chapter/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node")).child(STR("chapter")).next_sibling().next_sibling();
@@ -252,8 +208,6 @@ TEST_XML(xpath_paths_w3c_22, "<node><chapter/><chapter/><chapter/><chapter/><cha
TEST_XML(xpath_paths_w3c_23, "<node><figure><figure/><figure/><foo><figure/></foo></figure><foo/><figure/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -264,8 +218,6 @@ TEST_XML(xpath_paths_w3c_23, "<node><figure><figure/><figure/><foo><figure/></fo
TEST_XML(xpath_paths_w3c_24, "<doc><chapter/><chapter/><chapter/><chapter/><chapter><section/><section/><section/></chapter><chapter/></doc>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("doc")).child(STR("chapter"));
@@ -276,8 +228,6 @@ TEST_XML(xpath_paths_w3c_24, "<doc><chapter/><chapter/><chapter/><chapter/><chap
TEST_XML(xpath_paths_w3c_25, "<node><para/><para type='warning'/><para type='warning'/><para/><para type='error'/><para type='warning'/><para type='warning'/><para type='warning'/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -287,8 +237,6 @@ TEST_XML(xpath_paths_w3c_25, "<node><para/><para type='warning'/><para type='war
TEST_XML(xpath_paths_w3c_26, "<node><para/><para type='warning'/><para type='warning'/><para/><para type='error'/><para type='warning'/><para type='warning'/><para type='warning'/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -298,8 +246,6 @@ TEST_XML(xpath_paths_w3c_26, "<node><para/><para type='warning'/><para type='war
TEST_XML(xpath_paths_w3c_27a, "<node><para/><para type='warning'/><para type='warning'/><para/><para type='error'/><para type='warning'/><para type='warning'/><para type='warning'/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -309,8 +255,6 @@ TEST_XML(xpath_paths_w3c_27a, "<node><para/><para type='warning'/><para type='wa
TEST_XML(xpath_paths_w3c_27b, "<node><para/><para type='warning'/><para type='warning'/><para/><para type='warning'/><para type='warning'/><para type='warning'/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -320,8 +264,6 @@ TEST_XML(xpath_paths_w3c_27b, "<node><para/><para type='warning'/><para type='wa
TEST_XML(xpath_paths_w3c_28, "<node><chapter><title>foo</title></chapter><chapter><title>Introduction</title></chapter><chapter><title>introduction</title></chapter><chapter/><chapter><title>Introduction</title><title>foo</title></chapter></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -331,8 +273,6 @@ TEST_XML(xpath_paths_w3c_28, "<node><chapter><title>foo</title></chapter><chapte
TEST_XML(xpath_paths_w3c_29, "<node><chapter><title>foo</title></chapter><chapter><title>Introduction</title></chapter><chapter><title>introduction</title></chapter><chapter/><chapter><title>Introduction</title><title>foo</title></chapter></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -342,8 +282,6 @@ TEST_XML(xpath_paths_w3c_29, "<node><chapter><title>foo</title></chapter><chapte
TEST_XML(xpath_paths_w3c_30, "<node><abstract/><chapter/><chapter/><references/><appendix/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -353,8 +291,6 @@ TEST_XML(xpath_paths_w3c_30, "<node><abstract/><chapter/><chapter/><references/>
TEST_XML(xpath_paths_w3c_31a, "<node><abstract/><chapter/><chapter/><references/><appendix/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));
@@ -364,8 +300,6 @@ TEST_XML(xpath_paths_w3c_31a, "<node><abstract/><chapter/><chapter/><references/
TEST_XML(xpath_paths_w3c_31b, "<node><abstract/><chapter/><chapter/><references/><appendix/><chapter/></node>")
{
- doc.precompute_document_order();
-
xml_node c;
xml_node n = doc.child(STR("node"));