summaryrefslogtreecommitdiff
path: root/tests/test_xpath_paths.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_xpath_paths.cpp')
-rw-r--r--tests/test_xpath_paths.cpp396
1 files changed, 198 insertions, 198 deletions
diff --git a/tests/test_xpath_paths.cpp b/tests/test_xpath_paths.cpp
index d64fdc6..47ebada 100644
--- a/tests/test_xpath_paths.cpp
+++ b/tests/test_xpath_paths.cpp
@@ -7,12 +7,12 @@ TEST_XML(xpath_paths_axes_child, "<node attr='value'><child attr='value'><subchi
doc.precompute_document_order();
xml_node c;
- xml_node n = doc.child("node");
+ xml_node n = doc.child(STR("node"));
- CHECK_XPATH_NODESET(c, "child:: node()");
+ CHECK_XPATH_NODESET(c, STR("child:: node()"));
- CHECK_XPATH_NODESET(n, "child:: node()") % 4 % 7 % 8; // child, another, last
- CHECK_XPATH_NODESET(n, "another/child:: node()");
+ CHECK_XPATH_NODESET(n, STR("child:: node()")) % 4 % 7 % 8; // child, another, last
+ CHECK_XPATH_NODESET(n, STR("another/child:: node()"));
}
TEST_XML(xpath_paths_axes_descendant, "<node attr='value'><child attr='value'><subchild/></child><another><subchild/></another><last/></node>")
@@ -20,14 +20,14 @@ TEST_XML(xpath_paths_axes_descendant, "<node attr='value'><child attr='value'><s
doc.precompute_document_order();
xml_node c;
- xml_node n = doc.child("node");
+ xml_node n = doc.child(STR("node"));
- CHECK_XPATH_NODESET(c, "descendant:: node()");
+ CHECK_XPATH_NODESET(c, STR("descendant:: node()"));
- CHECK_XPATH_NODESET(n, "descendant:: node()") % 4 % 6 % 7 % 8 % 9; // child, subchild, another, subchild, last
- CHECK_XPATH_NODESET(doc, "descendant:: node()") % 2 % 4 % 6 % 7 % 8 % 9; // node, child, subchild, another, subchild, last
- CHECK_XPATH_NODESET(n, "another/descendant:: node()") % 8; // subchild
- CHECK_XPATH_NODESET(n, "last/descendant:: node()");
+ CHECK_XPATH_NODESET(n, STR("descendant:: node()")) % 4 % 6 % 7 % 8 % 9; // child, subchild, another, subchild, last
+ CHECK_XPATH_NODESET(doc, STR("descendant:: node()")) % 2 % 4 % 6 % 7 % 8 % 9; // node, child, subchild, another, subchild, last
+ CHECK_XPATH_NODESET(n, STR("another/descendant:: node()")) % 8; // subchild
+ CHECK_XPATH_NODESET(n, STR("last/descendant:: node()"));
}
TEST_XML(xpath_paths_axes_parent, "<node attr='value'><child attr='value'><subchild/></child><another><subchild/></another><last/></node>")
@@ -35,15 +35,15 @@ TEST_XML(xpath_paths_axes_parent, "<node attr='value'><child attr='value'><subch
doc.precompute_document_order();
xml_node c;
- xml_node n = doc.child("node");
+ xml_node n = doc.child(STR("node"));
- CHECK_XPATH_NODESET(c, "parent:: node()");
+ CHECK_XPATH_NODESET(c, STR("parent:: node()"));
- CHECK_XPATH_NODESET(n.child("child"), "parent:: node()") % 2; // node
- CHECK_XPATH_NODESET(n, "child/subchild/parent:: node()") % 4; // child
- CHECK_XPATH_NODESET(n, "@attr/parent:: node()") % 2; // node
- CHECK_XPATH_NODESET(n, "parent:: node()") % 1; // root
- CHECK_XPATH_NODESET(doc, "parent:: node()");
+ CHECK_XPATH_NODESET(n.child(STR("child")), STR("parent:: node()")) % 2; // node
+ CHECK_XPATH_NODESET(n, STR("child/subchild/parent:: node()")) % 4; // child
+ CHECK_XPATH_NODESET(n, STR("@attr/parent:: node()")) % 2; // node
+ CHECK_XPATH_NODESET(n, STR("parent:: node()")) % 1; // root
+ CHECK_XPATH_NODESET(doc, STR("parent:: node()"));
}
TEST_XML(xpath_paths_axes_ancestor, "<node attr='value'><child attr='value'><subchild/></child><another><subchild/></another><last/></node>")
@@ -51,15 +51,15 @@ TEST_XML(xpath_paths_axes_ancestor, "<node attr='value'><child attr='value'><sub
doc.precompute_document_order();
xml_node c;
- xml_node n = doc.child("node");
+ xml_node n = doc.child(STR("node"));
- CHECK_XPATH_NODESET(c, "ancestor:: node()");
+ CHECK_XPATH_NODESET(c, STR("ancestor:: node()"));
- CHECK_XPATH_NODESET(n.child("child"), "ancestor:: node()") % 2 % 1; // node, root
- CHECK_XPATH_NODESET(n, "child/subchild/ancestor:: node()") % 4 % 2 % 1; // child, node, root
- CHECK_XPATH_NODESET(n, "child/@attr/ancestor:: node()") % 4 % 2 % 1; // child, node, root
- CHECK_XPATH_NODESET(n, "ancestor:: node()") % 1; // root
- CHECK_XPATH_NODESET(doc, "ancestor:: node()");
+ CHECK_XPATH_NODESET(n.child(STR("child")), STR("ancestor:: node()")) % 2 % 1; // node, root
+ CHECK_XPATH_NODESET(n, STR("child/subchild/ancestor:: node()")) % 4 % 2 % 1; // child, node, root
+ CHECK_XPATH_NODESET(n, STR("child/@attr/ancestor:: node()")) % 4 % 2 % 1; // child, node, root
+ CHECK_XPATH_NODESET(n, STR("ancestor:: node()")) % 1; // root
+ CHECK_XPATH_NODESET(doc, STR("ancestor:: node()"));
}
TEST_XML(xpath_paths_axes_following_sibling, "<node attr1='value' attr2='value'><child attr='value'><subchild/></child><another><subchild/></another><last/></node>")
@@ -67,13 +67,13 @@ TEST_XML(xpath_paths_axes_following_sibling, "<node attr1='value' attr2='value'>
doc.precompute_document_order();
xml_node c;
- xml_node n = doc.child("node");
+ xml_node n = doc.child(STR("node"));
- CHECK_XPATH_NODESET(c, "following-sibling:: node()");
+ CHECK_XPATH_NODESET(c, STR("following-sibling:: node()"));
- CHECK_XPATH_NODESET(n.child("child"), "following-sibling:: node()") % 8 % 10; // another, last
- CHECK_XPATH_NODESET(n.child("last"), "following-sibling:: node()");
- CHECK_XPATH_NODESET(n, "@attr1/following-sibling:: node()"); // attributes are not siblings
+ CHECK_XPATH_NODESET(n.child(STR("child")), STR("following-sibling:: node()")) % 8 % 10; // another, last
+ CHECK_XPATH_NODESET(n.child(STR("last")), STR("following-sibling:: node()"));
+ CHECK_XPATH_NODESET(n, STR("@attr1/following-sibling:: node()")); // attributes are not siblings
}
TEST_XML(xpath_paths_axes_preceding_sibling, "<node attr1='value' attr2='value'><child attr='value'><subchild/></child><another><subchild/></another><last/></node>")
@@ -81,13 +81,13 @@ TEST_XML(xpath_paths_axes_preceding_sibling, "<node attr1='value' attr2='value'>
doc.precompute_document_order();
xml_node c;
- xml_node n = doc.child("node");
+ xml_node n = doc.child(STR("node"));
- CHECK_XPATH_NODESET(c, "preceding-sibling:: node()");
+ CHECK_XPATH_NODESET(c, STR("preceding-sibling:: node()"));
- CHECK_XPATH_NODESET(n.child("child"), "preceding-sibling:: node()");
- CHECK_XPATH_NODESET(n.child("last"), "preceding-sibling:: node()") % 8 % 5; // another, child
- CHECK_XPATH_NODESET(n, "@attr2/following-sibling:: node()"); // attributes are not siblings
+ CHECK_XPATH_NODESET(n.child(STR("child")), STR("preceding-sibling:: node()"));
+ CHECK_XPATH_NODESET(n.child(STR("last")), STR("preceding-sibling:: node()")) % 8 % 5; // another, child
+ CHECK_XPATH_NODESET(n, STR("@attr2/following-sibling:: node()")); // attributes are not siblings
}
TEST_XML(xpath_paths_axes_following, "<node attr1='value' attr2='value'><child attr='value'><subchild/></child><another><subchild/></another><almost/><last/></node>")
@@ -95,14 +95,14 @@ TEST_XML(xpath_paths_axes_following, "<node attr1='value' attr2='value'><child a
doc.precompute_document_order();
xml_node c;
- xml_node n = doc.child("node");
+ xml_node n = doc.child(STR("node"));
- CHECK_XPATH_NODESET(c, "following:: node()");
+ CHECK_XPATH_NODESET(c, STR("following:: node()"));
- CHECK_XPATH_NODESET(n, "following:: node()"); // no descendants
- CHECK_XPATH_NODESET(n.child("child"), "following:: node()") % 8 % 9 % 10 % 11; // another, subchild, almost, last
- CHECK_XPATH_NODESET(n.child("child").child("subchild"), "following:: node()") % 8 % 9 % 10 % 11; // another, subchild, almost, last
- CHECK_XPATH_NODESET(n.child("last"), "following:: node()");
+ CHECK_XPATH_NODESET(n, STR("following:: node()")); // no descendants
+ CHECK_XPATH_NODESET(n.child(STR("child")), STR("following:: node()")) % 8 % 9 % 10 % 11; // another, subchild, almost, last
+ CHECK_XPATH_NODESET(n.child(STR("child")).child(STR("subchild")), STR("following:: node()")) % 8 % 9 % 10 % 11; // another, subchild, almost, last
+ CHECK_XPATH_NODESET(n.child(STR("last")), STR("following:: node()"));
}
TEST_XML(xpath_paths_axes_preceding, "<node attr1='value' attr2='value'><child attr='value'><subchild/></child><another><subchild/></another><almost/><last/></node>")
@@ -110,14 +110,14 @@ TEST_XML(xpath_paths_axes_preceding, "<node attr1='value' attr2='value'><child a
doc.precompute_document_order();
xml_node c;
- xml_node n = doc.child("node");
+ xml_node n = doc.child(STR("node"));
- CHECK_XPATH_NODESET(c, "preceding:: node()");
+ CHECK_XPATH_NODESET(c, STR("preceding:: node()"));
- CHECK_XPATH_NODESET(n.child("child"), "preceding:: node()"); // no ancestors
- CHECK_XPATH_NODESET(n.child("last"), "preceding:: node()") % 10 % 9 % 8 % 7 % 5; // almost, subchild, another, subchild, child
- CHECK_XPATH_NODESET(n.child("another").child("subchild"), "preceding:: node()") % 7 % 5; // subchild, child
- CHECK_XPATH_NODESET(n, "preceding:: node()");
+ CHECK_XPATH_NODESET(n.child(STR("child")), STR("preceding:: node()")); // no ancestors
+ CHECK_XPATH_NODESET(n.child(STR("last")), STR("preceding:: node()")) % 10 % 9 % 8 % 7 % 5; // almost, subchild, another, subchild, child
+ CHECK_XPATH_NODESET(n.child(STR("another")).child(STR("subchild")), STR("preceding:: node()")) % 7 % 5; // subchild, child
+ CHECK_XPATH_NODESET(n, STR("preceding:: node()"));
}
TEST_XML(xpath_paths_axes_attribute, "<node attr1='value' attr2='value'><child attr='value'><subchild/></child><another xmlns:foo='bar'><subchild/></another><last/></node>")
@@ -125,22 +125,22 @@ TEST_XML(xpath_paths_axes_attribute, "<node attr1='value' attr2='value'><child a
doc.precompute_document_order();
xml_node c;
- xml_node n = doc.child("node");
+ xml_node n = doc.child(STR("node"));
- CHECK_XPATH_NODESET(c, "attribute:: node()");
+ CHECK_XPATH_NODESET(c, STR("attribute:: node()"));
- CHECK_XPATH_NODESET(n.child("child"), "attribute:: node()") % 6; // child/@attr
- CHECK_XPATH_NODESET(n.child("last"), "attribute:: node()");
- CHECK_XPATH_NODESET(n, "attribute:: node()") % 3 % 4; // node/@attr1 node/@attr2
- CHECK_XPATH_NODESET(doc, "descendant-or-self:: node()/attribute:: node()") % 3 % 4 % 6; // all attributes
- CHECK_XPATH_NODESET(n.child("another"), "attribute:: node()"); // namespace nodes are not attributes
+ CHECK_XPATH_NODESET(n.child(STR("child")), STR("attribute:: node()")) % 6; // child/@attr
+ CHECK_XPATH_NODESET(n.child(STR("last")), STR("attribute:: node()"));
+ CHECK_XPATH_NODESET(n, STR("attribute:: node()")) % 3 % 4; // node/@attr1 node/@attr2
+ CHECK_XPATH_NODESET(doc, STR("descendant-or-self:: node()/attribute:: node()")) % 3 % 4 % 6; // all attributes
+ CHECK_XPATH_NODESET(n.child(STR("another")), STR("attribute:: node()")); // namespace nodes are not attributes
}
TEST_XML(xpath_paths_axes_namespace, "<node xmlns:foo='bar'/>")
{
- xml_node n = doc.child("node");
+ xml_node n = doc.child(STR("node"));
- CHECK_XPATH_NODESET(n, "namespace:: node()"); // namespace nodes are not supported
+ CHECK_XPATH_NODESET(n, STR("namespace:: node()")); // namespace nodes are not supported
}
TEST_XML(xpath_paths_axes_self, "<node attr='value'><child attr='value'><subchild/></child><another><subchild/></another><last/></node>")
@@ -148,15 +148,15 @@ TEST_XML(xpath_paths_axes_self, "<node attr='value'><child attr='value'><subchil
doc.precompute_document_order();
xml_node c;
- xml_node n = doc.child("node");
+ xml_node n = doc.child(STR("node"));
- CHECK_XPATH_NODESET(c, "self:: node()");
+ CHECK_XPATH_NODESET(c, STR("self:: node()"));
- CHECK_XPATH_NODESET(n.child("child"), "self:: node()") % 4; // child
- CHECK_XPATH_NODESET(n, "self:: node()") % 2; // node
- CHECK_XPATH_NODESET(n, "child/self:: node()") % 4; // child
- CHECK_XPATH_NODESET(n, "child/@attr/self:: node()") % 5; // @attr
- CHECK_XPATH_NODESET(doc, "self:: node()") % 1; // root
+ CHECK_XPATH_NODESET(n.child(STR("child")), STR("self:: node()")) % 4; // child
+ CHECK_XPATH_NODESET(n, STR("self:: node()")) % 2; // node
+ CHECK_XPATH_NODESET(n, STR("child/self:: node()")) % 4; // child
+ CHECK_XPATH_NODESET(n, STR("child/@attr/self:: node()")) % 5; // @attr
+ CHECK_XPATH_NODESET(doc, STR("self:: node()")) % 1; // root
}
TEST_XML(xpath_paths_axes_descendant_or_self, "<node attr='value'><child attr='value'><subchild/></child><another><subchild/></another><last/></node>")
@@ -164,14 +164,14 @@ TEST_XML(xpath_paths_axes_descendant_or_self, "<node attr='value'><child attr='v
doc.precompute_document_order();
xml_node c;
- xml_node n = doc.child("node");
+ xml_node n = doc.child(STR("node"));
- CHECK_XPATH_NODESET(c, "descendant-or-self:: node()");
+ CHECK_XPATH_NODESET(c, STR("descendant-or-self:: node()"));
- CHECK_XPATH_NODESET(n, "descendant-or-self:: node()") % 2 % 4 % 6 % 7 % 8 % 9; // node, child, subchild, another, subchild, last
- CHECK_XPATH_NODESET(doc, "descendant-or-self:: node()") % 1 % 2 % 4 % 6 % 7 % 8 % 9; // root, node, child, subchild, another, subchild, last
- CHECK_XPATH_NODESET(n, "another/descendant-or-self:: node()") % 7 % 8; // another, subchild
- CHECK_XPATH_NODESET(n, "last/descendant-or-self:: node()") % 9; // last
+ CHECK_XPATH_NODESET(n, STR("descendant-or-self:: node()")) % 2 % 4 % 6 % 7 % 8 % 9; // node, child, subchild, another, subchild, last
+ CHECK_XPATH_NODESET(doc, STR("descendant-or-self:: node()")) % 1 % 2 % 4 % 6 % 7 % 8 % 9; // root, node, child, subchild, another, subchild, last
+ CHECK_XPATH_NODESET(n, STR("another/descendant-or-self:: node()")) % 7 % 8; // another, subchild
+ CHECK_XPATH_NODESET(n, STR("last/descendant-or-self:: node()")) % 9; // last
}
TEST_XML(xpath_paths_axes_ancestor_or_self, "<node attr='value'><child attr='value'><subchild/></child><another><subchild/></another><last/></node>")
@@ -179,15 +179,15 @@ TEST_XML(xpath_paths_axes_ancestor_or_self, "<node attr='value'><child attr='val
doc.precompute_document_order();
xml_node c;
- xml_node n = doc.child("node");
+ xml_node n = doc.child(STR("node"));
- CHECK_XPATH_NODESET(c, "ancestor-or-self:: node()");
+ CHECK_XPATH_NODESET(c, STR("ancestor-or-self:: node()"));
- CHECK_XPATH_NODESET(n.child("child"), "ancestor-or-self:: node()") % 4 % 2 % 1; // child, node, root
- CHECK_XPATH_NODESET(n, "child/subchild/ancestor-or-self:: node()") % 6 % 4 % 2 % 1; // subchild, child, node, root
- CHECK_XPATH_NODESET(n, "child/@attr/ancestor-or-self:: node()") % 5 % 4 % 2 % 1; // @attr, child, node, root
- CHECK_XPATH_NODESET(n, "ancestor-or-self:: node()") % 2 % 1; // root, node
- CHECK_XPATH_NODESET(doc, "ancestor-or-self:: node()") % 1; // root
+ CHECK_XPATH_NODESET(n.child(STR("child")), STR("ancestor-or-self:: node()")) % 4 % 2 % 1; // child, node, root
+ CHECK_XPATH_NODESET(n, STR("child/subchild/ancestor-or-self:: node()")) % 6 % 4 % 2 % 1; // subchild, child, node, root
+ CHECK_XPATH_NODESET(n, STR("child/@attr/ancestor-or-self:: node()")) % 5 % 4 % 2 % 1; // @attr, child, node, root
+ CHECK_XPATH_NODESET(n, STR("ancestor-or-self:: node()")) % 2 % 1; // root, node
+ CHECK_XPATH_NODESET(doc, STR("ancestor-or-self:: node()")) % 1; // root
}
TEST_XML(xpath_paths_axes_abbrev, "<node attr='value'><foo/></node>")
@@ -195,20 +195,20 @@ TEST_XML(xpath_paths_axes_abbrev, "<node attr='value'><foo/></node>")
doc.precompute_document_order();
xml_node c;
- xml_node n = doc.child("node");
+ xml_node n = doc.child(STR("node"));
// @ axis
- CHECK_XPATH_NODESET(c, "@attr");
- CHECK_XPATH_NODESET(n, "@attr") % 3;
+ CHECK_XPATH_NODESET(c, STR("@attr"));
+ CHECK_XPATH_NODESET(n, STR("@attr")) % 3;
// no axis - child implied
- CHECK_XPATH_NODESET(c, "foo");
- CHECK_XPATH_NODESET(n, "foo") % 4;
- CHECK_XPATH_NODESET(doc, "node()") % 2;
+ CHECK_XPATH_NODESET(c, STR("foo"));
+ CHECK_XPATH_NODESET(n, STR("foo")) % 4;
+ CHECK_XPATH_NODESET(doc, STR("node()")) % 2;
// @ axis should disable all other axis specifiers
- CHECK_XPATH_FAIL("@child::foo");
- CHECK_XPATH_FAIL("@attribute::foo");
+ CHECK_XPATH_FAIL(STR("@child::foo"));
+ CHECK_XPATH_FAIL(STR("@attribute::foo"));
}
TEST_XML(xpath_paths_nodetest_all, "<node a1='v1' x:a2='v2'><c1/><x:c2/><c3/><x:c4/></node>")
@@ -216,14 +216,14 @@ TEST_XML(xpath_paths_nodetest_all, "<node a1='v1' x:a2='v2'><c1/><x:c2/><c3/><x:
doc.precompute_document_order();
xml_node c;
- xml_node n = doc.child("node");
+ xml_node n = doc.child(STR("node"));
- CHECK_XPATH_NODESET(c, "*");
- CHECK_XPATH_NODESET(c, "child::*");
+ CHECK_XPATH_NODESET(c, STR("*"));
+ CHECK_XPATH_NODESET(c, STR("child::*"));
- CHECK_XPATH_NODESET(n, "*") % 5 % 6 % 7 % 8;
- CHECK_XPATH_NODESET(n, "child::*") % 5 % 6 % 7 % 8;
- CHECK_XPATH_NODESET(n, "attribute::*") % 3 % 4;
+ CHECK_XPATH_NODESET(n, STR("*")) % 5 % 6 % 7 % 8;
+ CHECK_XPATH_NODESET(n, STR("child::*")) % 5 % 6 % 7 % 8;
+ CHECK_XPATH_NODESET(n, STR("attribute::*")) % 3 % 4;
}
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)
@@ -231,20 +231,20 @@ TEST_XML_FLAGS(xpath_paths_nodetest_name, "<node a1='v1' x:a2='v2'><c1/><x:c2/><
doc.precompute_document_order();
xml_node c;
- xml_node n = doc.child("node");
+ xml_node n = doc.child(STR("node"));
- CHECK_XPATH_NODESET(c, "c1");
- CHECK_XPATH_NODESET(c, "child::c1");
+ CHECK_XPATH_NODESET(c, STR("c1"));
+ CHECK_XPATH_NODESET(c, STR("child::c1"));
- CHECK_XPATH_NODESET(n, "c1") % 5;
- CHECK_XPATH_NODESET(n, "x:c2") % 6;
+ CHECK_XPATH_NODESET(n, STR("c1")) % 5;
+ CHECK_XPATH_NODESET(n, STR("x:c2")) % 6;
- CHECK_XPATH_NODESET(n, "child::c1") % 5;
- CHECK_XPATH_NODESET(n, "child::x:c2") % 6;
+ CHECK_XPATH_NODESET(n, STR("child::c1")) % 5;
+ CHECK_XPATH_NODESET(n, STR("child::x:c2")) % 6;
- CHECK_XPATH_NODESET(n, "attribute::a1") % 3;
- CHECK_XPATH_NODESET(n, "attribute::x:a2") % 4;
- CHECK_XPATH_NODESET(n, "@x:a2") % 4;
+ CHECK_XPATH_NODESET(n, STR("attribute::a1")) % 3;
+ CHECK_XPATH_NODESET(n, STR("attribute::x:a2")) % 4;
+ CHECK_XPATH_NODESET(n, STR("@x:a2")) % 4;
}
TEST_XML(xpath_paths_nodetest_all_in_namespace, "<node a1='v1' x:a2='v2'><c1/><x:c2/><c3/><x:c4/></node>")
@@ -252,19 +252,19 @@ TEST_XML(xpath_paths_nodetest_all_in_namespace, "<node a1='v1' x:a2='v2'><c1/><x
doc.precompute_document_order();
xml_node c;
- xml_node n = doc.child("node");
+ xml_node n = doc.child(STR("node"));
- CHECK_XPATH_NODESET(c, "x:*");
- CHECK_XPATH_NODESET(c, "child::x:*");
+ CHECK_XPATH_NODESET(c, STR("x:*"));
+ CHECK_XPATH_NODESET(c, STR("child::x:*"));
- CHECK_XPATH_NODESET(n, "x:*") % 6 % 8;
- CHECK_XPATH_NODESET(n, "child::x:*") % 6 % 8;
+ CHECK_XPATH_NODESET(n, STR("x:*")) % 6 % 8;
+ CHECK_XPATH_NODESET(n, STR("child::x:*")) % 6 % 8;
- CHECK_XPATH_NODESET(n, "attribute::x:*") % 4;
- CHECK_XPATH_NODESET(n, "@x:*") % 4;
+ CHECK_XPATH_NODESET(n, STR("attribute::x:*")) % 4;
+ CHECK_XPATH_NODESET(n, STR("@x:*")) % 4;
- CHECK_XPATH_FAIL(":*");
- CHECK_XPATH_FAIL("@:*");
+ CHECK_XPATH_FAIL(STR(":*"));
+ CHECK_XPATH_FAIL(STR("@:*"));
}
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)
@@ -272,35 +272,35 @@ TEST_XML_FLAGS(xpath_paths_nodetest_type, "<node attr='value'>pcdata<child/><?pi
doc.precompute_document_order();
xml_node c;
- xml_node n = doc.child("node");
+ xml_node n = doc.child(STR("node"));
// check on empty nodes
- CHECK_XPATH_NODESET(c, "node()");
- CHECK_XPATH_NODESET(c, "text()");
- CHECK_XPATH_NODESET(c, "comment()");
- CHECK_XPATH_NODESET(c, "processing-instruction()");
- CHECK_XPATH_NODESET(c, "processing-instruction('foobar')");
+ CHECK_XPATH_NODESET(c, STR("node()"));
+ CHECK_XPATH_NODESET(c, STR("text()"));
+ CHECK_XPATH_NODESET(c, STR("comment()"));
+ CHECK_XPATH_NODESET(c, STR("processing-instruction()"));
+ CHECK_XPATH_NODESET(c, STR("processing-instruction('foobar')"));
// child axis
- CHECK_XPATH_NODESET(n, "node()") % 4 % 5 % 6 % 7 % 8 % 9;
- CHECK_XPATH_NODESET(n, "text()") % 4 % 9;
- CHECK_XPATH_NODESET(n, "comment()") % 8;
- CHECK_XPATH_NODESET(n, "processing-instruction()") % 6 % 7;
- CHECK_XPATH_NODESET(n, "processing-instruction('pi2')") % 7;
+ CHECK_XPATH_NODESET(n, STR("node()")) % 4 % 5 % 6 % 7 % 8 % 9;
+ CHECK_XPATH_NODESET(n, STR("text()")) % 4 % 9;
+ CHECK_XPATH_NODESET(n, STR("comment()")) % 8;
+ CHECK_XPATH_NODESET(n, STR("processing-instruction()")) % 6 % 7;
+ CHECK_XPATH_NODESET(n, STR("processing-instruction('pi2')")) % 7;
// attribute axis
- CHECK_XPATH_NODESET(n, "@node()") % 3;
- CHECK_XPATH_NODESET(n, "@text()");
- CHECK_XPATH_NODESET(n, "@comment()");
- CHECK_XPATH_NODESET(n, "@processing-instruction()");
- CHECK_XPATH_NODESET(n, "@processing-instruction('pi2')");
+ CHECK_XPATH_NODESET(n, STR("@node()")) % 3;
+ CHECK_XPATH_NODESET(n, STR("@text()"));
+ CHECK_XPATH_NODESET(n, STR("@comment()"));
+ CHECK_XPATH_NODESET(n, STR("@processing-instruction()"));
+ CHECK_XPATH_NODESET(n, STR("@processing-instruction('pi2')"));
// incorrect 'argument' number
- CHECK_XPATH_FAIL("node('')");
- CHECK_XPATH_FAIL("text('')");
- CHECK_XPATH_FAIL("comment('')");
- CHECK_XPATH_FAIL("processing-instruction(1)");
- CHECK_XPATH_FAIL("processing-instruction('', '')");
+ CHECK_XPATH_FAIL(STR("node('')"));
+ CHECK_XPATH_FAIL(STR("text('')"));
+ CHECK_XPATH_FAIL(STR("comment('')"));
+ CHECK_XPATH_FAIL(STR("processing-instruction(1)"));
+ CHECK_XPATH_FAIL(STR("processing-instruction('', '')"));
}
TEST_XML(xpath_paths_absolute, "<node><foo><foo/><foo/></foo></node>")
@@ -308,16 +308,16 @@ TEST_XML(xpath_paths_absolute, "<node><foo><foo/><foo/></foo></node>")
doc.precompute_document_order();
xml_node c;
- xml_node n = doc.child("node");
+ xml_node n = doc.child(STR("node"));
- CHECK_XPATH_NODESET(c, "/foo");
- CHECK_XPATH_NODESET(n, "/foo");
- CHECK_XPATH_NODESET(n, "/node/foo") % 3;
- CHECK_XPATH_NODESET(n.child("foo"), "/node/foo") % 3;
+ CHECK_XPATH_NODESET(c, STR("/foo"));
+ CHECK_XPATH_NODESET(n, STR("/foo"));
+ CHECK_XPATH_NODESET(n, STR("/node/foo")) % 3;
+ CHECK_XPATH_NODESET(n.child(STR("foo")), STR("/node/foo")) % 3;
- CHECK_XPATH_NODESET(c, "/");
- CHECK_XPATH_NODESET(n, "/") % 1;
- CHECK_XPATH_NODESET(n.child("foo"), "/") % 1;
+ CHECK_XPATH_NODESET(c, STR("/"));
+ CHECK_XPATH_NODESET(n, STR("/")) % 1;
+ CHECK_XPATH_NODESET(n.child(STR("foo")), STR("/")) % 1;
}
TEST_XML(xpath_paths_step_abbrev, "<node><foo/></node>")
@@ -325,18 +325,18 @@ TEST_XML(xpath_paths_step_abbrev, "<node><foo/></node>")
doc.precompute_document_order();
xml_node c;
- xml_node n = doc.child("node");
+ xml_node n = doc.child(STR("node"));
- CHECK_XPATH_NODESET(c, ".");
- CHECK_XPATH_NODESET(c, "..");
+ CHECK_XPATH_NODESET(c, STR("."));
+ CHECK_XPATH_NODESET(c, STR(".."));
- CHECK_XPATH_NODESET(n, ".") % 2;
- CHECK_XPATH_NODESET(n, "..") % 1;
- CHECK_XPATH_NODESET(n, "../node") % 2;
- CHECK_XPATH_NODESET(n.child("foo"), "..") % 2;
+ CHECK_XPATH_NODESET(n, STR(".")) % 2;
+ CHECK_XPATH_NODESET(n, STR("..")) % 1;
+ CHECK_XPATH_NODESET(n, STR("../node")) % 2;
+ CHECK_XPATH_NODESET(n.child(STR("foo")), STR("..")) % 2;
- CHECK_XPATH_FAIL(".node");
- CHECK_XPATH_FAIL("..node");
+ CHECK_XPATH_FAIL(STR(".node"));
+ CHECK_XPATH_FAIL(STR("..node"));
}
TEST_XML(xpath_paths_relative_abbrev, "<node><foo><foo/><foo/></foo></node>")
@@ -344,13 +344,13 @@ TEST_XML(xpath_paths_relative_abbrev, "<node><foo><foo/><foo/></foo></node>")
doc.precompute_document_order();
xml_node c;
- xml_node n = doc.child("node");
+ xml_node n = doc.child(STR("node"));
- CHECK_XPATH_NODESET(c, "foo//bar");
+ CHECK_XPATH_NODESET(c, STR("foo//bar"));
- CHECK_XPATH_NODESET(n, "foo/foo") % 4 % 5;
- CHECK_XPATH_NODESET(n, "foo//foo") % 4 % 5;
- CHECK_XPATH_NODESET(n, ".//foo") % 3 % 4 % 5;
+ CHECK_XPATH_NODESET(n, STR("foo/foo")) % 4 % 5;
+ CHECK_XPATH_NODESET(n, STR("foo//foo")) % 4 % 5;
+ CHECK_XPATH_NODESET(n, STR(".//foo")) % 3 % 4 % 5;
}
TEST_XML(xpath_paths_absolute_abbrev, "<node><foo><foo/><foo/></foo></node>")
@@ -358,117 +358,117 @@ TEST_XML(xpath_paths_absolute_abbrev, "<node><foo><foo/><foo/></foo></node>")
doc.precompute_document_order();
xml_node c;
- xml_node n = doc.child("node");
+ xml_node n = doc.child(STR("node"));
- CHECK_XPATH_NODESET(c, "//bar");
+ CHECK_XPATH_NODESET(c, STR("//bar"));
- CHECK_XPATH_NODESET(n, "//foo") % 3 % 4 % 5;
- CHECK_XPATH_NODESET(n.child("foo"), "//foo") % 3 % 4 % 5;
- CHECK_XPATH_NODESET(doc, "//foo") % 3 % 4 % 5;
+ CHECK_XPATH_NODESET(n, STR("//foo")) % 3 % 4 % 5;
+ CHECK_XPATH_NODESET(n.child(STR("foo")), STR("//foo")) % 3 % 4 % 5;
+ CHECK_XPATH_NODESET(doc, STR("//foo")) % 3 % 4 % 5;
}
TEST_XML(xpath_paths_predicate_boolean, "<node><chapter/><chapter/><chapter/><chapter/><chapter/></node>")
{
doc.precompute_document_order();
- xml_node n = doc.child("node").child("chapter").next_sibling().next_sibling();
+ xml_node n = doc.child(STR("node")).child(STR("chapter")).next_sibling().next_sibling();
- CHECK_XPATH_NODESET(n, "following-sibling::chapter[position()=1]") % 6;
- CHECK_XPATH_NODESET(n, "following-sibling::chapter[position()=2]") % 7;
- CHECK_XPATH_NODESET(n, "preceding-sibling::chapter[position()=1]") % 4;
- CHECK_XPATH_NODESET(n, "preceding-sibling::chapter[position()=2]") % 3;
+ CHECK_XPATH_NODESET(n, STR("following-sibling::chapter[position()=1]")) % 6;
+ CHECK_XPATH_NODESET(n, STR("following-sibling::chapter[position()=2]")) % 7;
+ CHECK_XPATH_NODESET(n, STR("preceding-sibling::chapter[position()=1]")) % 4;
+ CHECK_XPATH_NODESET(n, STR("preceding-sibling::chapter[position()=2]")) % 3;
}
TEST_XML(xpath_paths_predicate_number, "<node><chapter/><chapter/><chapter/><chapter/><chapter/></node>")
{
doc.precompute_document_order();
- xml_node n = doc.child("node").child("chapter").next_sibling().next_sibling();
+ xml_node n = doc.child(STR("node")).child(STR("chapter")).next_sibling().next_sibling();
- CHECK_XPATH_NODESET(n, "following-sibling::chapter[1]") % 6;
- CHECK_XPATH_NODESET(n, "following-sibling::chapter[2]") % 7;
- CHECK_XPATH_NODESET(n, "preceding-sibling::chapter[1]") % 4;
- CHECK_XPATH_NODESET(n, "preceding-sibling::chapter[2]") % 3;
+ CHECK_XPATH_NODESET(n, STR("following-sibling::chapter[1]")) % 6;
+ CHECK_XPATH_NODESET(n, STR("following-sibling::chapter[2]")) % 7;
+ CHECK_XPATH_NODESET(n, STR("preceding-sibling::chapter[1]")) % 4;
+ CHECK_XPATH_NODESET(n, STR("preceding-sibling::chapter[2]")) % 3;
}
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("node");
+ xml_node n = doc.child(STR("node"));
- CHECK_XPATH_NODESET(n, "employee") % 3 % 4 % 6 % 8 % 11;
- CHECK_XPATH_NODESET(n, "employee[@secretary]") % 4 % 8 % 11;
- CHECK_XPATH_NODESET(n, "employee[@assistant]") % 6 % 8 % 11;
- CHECK_XPATH_NODESET(n, "employee[@secretary][@assistant]") % 8 % 11;
- CHECK_XPATH_NODESET(n, "employee[@assistant][@secretary]") % 8 % 11;
- CHECK_XPATH_NODESET(n, "employee[@secretary and @assistant]") % 8 % 11;
+ CHECK_XPATH_NODESET(n, STR("employee")) % 3 % 4 % 6 % 8 % 11;
+ CHECK_XPATH_NODESET(n, STR("employee[@secretary]")) % 4 % 8 % 11;
+ CHECK_XPATH_NODESET(n, STR("employee[@assistant]")) % 6 % 8 % 11;
+ CHECK_XPATH_NODESET(n, STR("employee[@secretary][@assistant]")) % 8 % 11;
+ CHECK_XPATH_NODESET(n, STR("employee[@assistant][@secretary]")) % 8 % 11;
+ CHECK_XPATH_NODESET(n, STR("employee[@secretary and @assistant]")) % 8 % 11;
}
TEST_XML(xpath_paths_predicate_filter_boolean, "<node><chapter/><chapter/><chapter/><chapter/><chapter/></node>")
{
doc.precompute_document_order();
- xml_node n = doc.child("node").child("chapter").next_sibling().next_sibling();
+ xml_node n = doc.child(STR("node")).child(STR("chapter")).next_sibling().next_sibling();
- CHECK_XPATH_NODESET(n, "(following-sibling::chapter)[position()=1]") % 6;
- CHECK_XPATH_NODESET(n, "(following-sibling::chapter)[position()=2]") % 7;
- CHECK_XPATH_NODESET(n, "(preceding-sibling::chapter)[position()=1]") % 3;
- CHECK_XPATH_NODESET(n, "(preceding-sibling::chapter)[position()=2]") % 4;
+ CHECK_XPATH_NODESET(n, STR("(following-sibling::chapter)[position()=1]")) % 6;
+ CHECK_XPATH_NODESET(n, STR("(following-sibling::chapter)[position()=2]")) % 7;
+ CHECK_XPATH_NODESET(n, STR("(preceding-sibling::chapter)[position()=1]")) % 3;
+ CHECK_XPATH_NODESET(n, STR("(preceding-sibling::chapter)[position()=2]")) % 4;
}
TEST_XML(xpath_paths_predicate_filter_number, "<node><chapter/><chapter/><chapter/><chapter/><chapter/></node>")
{
doc.precompute_document_order();
- xml_node n = doc.child("node").child("chapter").next_sibling().next_sibling();
+ xml_node n = doc.child(STR("node")).child(STR("chapter")).next_sibling().next_sibling();
- CHECK_XPATH_NODESET(n, "(following-sibling::chapter)[1]") % 6;
- CHECK_XPATH_NODESET(n, "(following-sibling::chapter)[2]") % 7;
- CHECK_XPATH_NODESET(n, "(preceding-sibling::chapter)[1]") % 3;
- CHECK_XPATH_NODESET(n, "(preceding-sibling::chapter)[2]") % 4;
+ CHECK_XPATH_NODESET(n, STR("(following-sibling::chapter)[1]")) % 6;
+ CHECK_XPATH_NODESET(n, STR("(following-sibling::chapter)[2]")) % 7;
+ CHECK_XPATH_NODESET(n, STR("(preceding-sibling::chapter)[1]")) % 3;
+ CHECK_XPATH_NODESET(n, STR("(preceding-sibling::chapter)[2]")) % 4;
}
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("node");
+ xml_node n = doc.child(STR("node"));
- CHECK_XPATH_NODESET(n, "employee") % 3 % 4 % 6 % 8 % 11;
- CHECK_XPATH_NODESET(n, "(employee[@secretary])[@assistant]") % 8 % 11;
- CHECK_XPATH_NODESET(n, "((employee)[@assistant])[@secretary]") % 8 % 11;
+ CHECK_XPATH_NODESET(n, STR("employee")) % 3 % 4 % 6 % 8 % 11;
+ CHECK_XPATH_NODESET(n, STR("(employee[@secretary])[@assistant]")) % 8 % 11;
+ CHECK_XPATH_NODESET(n, STR("((employee)[@assistant])[@secretary]")) % 8 % 11;
}
TEST_XML(xpath_paths_step_compose, "<node><foo><foo/><foo/></foo><foo/></node>")
{
doc.precompute_document_order();
- xml_node n = doc.child("node");
+ xml_node n = doc.child(STR("node"));
- CHECK_XPATH_NODESET(n, "(.)/foo") % 3 % 6;
- CHECK_XPATH_NODESET(n, "(.)//foo") % 3 % 4 % 5 % 6;
- CHECK_XPATH_NODESET(n, "(./..)//*") % 2 % 3 % 4 % 5 % 6;
+ CHECK_XPATH_NODESET(n, STR("(.)/foo")) % 3 % 6;
+ CHECK_XPATH_NODESET(n, STR("(.)//foo")) % 3 % 4 % 5 % 6;
+ CHECK_XPATH_NODESET(n, STR("(./..)//*")) % 2 % 3 % 4 % 5 % 6;
- CHECK_XPATH_FAIL("(1)/foo");
- CHECK_XPATH_FAIL("(1)//foo");
+ CHECK_XPATH_FAIL(STR("(1)/foo"));
+ CHECK_XPATH_FAIL(STR("(1)//foo"));
}
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, "//para") % 3 % 4 % 5 % 6 % 7 % 8;
- CHECK_XPATH_NODESET(doc, "/descendant::para") % 3 % 4 % 5 % 6 % 7 % 8;
- CHECK_XPATH_NODESET(doc, "//para[1]") % 3 % 4 % 7;
- CHECK_XPATH_NODESET(doc, "/descendant::para[1]") % 3;
+ 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;
+ CHECK_XPATH_NODESET(doc, STR("/descendant::para[1]")) % 3;
}
TEST_XML(xpath_paths_needs_sorting, "<node><child/><child/><child><subchild/><subchild/></child></node>")
{
doc.precompute_document_order();
- CHECK_XPATH_NODESET(doc, "(node/child/subchild)[2]") % 7;
+ CHECK_XPATH_NODESET(doc, STR("(node/child/subchild)[2]")) % 7;
}
#endif