diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test.cpp | 8 | ||||
-rw-r--r-- | tests/test_xpath_paths.cpp | 42 | ||||
-rw-r--r-- | tests/test_xpath_xalan_1.cpp | 2 | ||||
-rw-r--r-- | tests/test_xpath_xalan_2.cpp | 2 | ||||
-rw-r--r-- | tests/test_xpath_xalan_3.cpp | 7 |
5 files changed, 44 insertions, 17 deletions
diff --git a/tests/test.cpp b/tests/test.cpp index be0d86b..247c714 100644 --- a/tests/test.cpp +++ b/tests/test.cpp @@ -58,8 +58,6 @@ bool test_xpath_string(const pugi::xml_node& node, const pugi::char_t* query, co {
pugi::xpath_query q(query);
- // $$$ q.rettype() == string
-
return q.evaluate_string(node) == expected;
}
@@ -67,8 +65,6 @@ bool test_xpath_boolean(const pugi::xml_node& node, const pugi::char_t* query, b {
pugi::xpath_query q(query);
- // $$$ q.rettype() == boolean
-
return q.evaluate_boolean(node) == expected;
}
@@ -78,8 +74,6 @@ bool test_xpath_number(const pugi::xml_node& node, const pugi::char_t* query, do {
pugi::xpath_query q(query);
- // $$$ q.rettype() == number
-
double value = q.evaluate_number(node);
double absolute_error = fabs(value - expected);
@@ -91,8 +85,6 @@ bool test_xpath_number_nan(const pugi::xml_node& node, const pugi::char_t* query {
pugi::xpath_query q(query);
- // $$$ q.rettype() == number
-
double r = q.evaluate_number(node);
#if defined(_MSC_VER) || defined(__BORLANDC__)
diff --git a/tests/test_xpath_paths.cpp b/tests/test_xpath_paths.cpp index 2d00c34..e58d7b1 100644 --- a/tests/test_xpath_paths.cpp +++ b/tests/test_xpath_paths.cpp @@ -286,10 +286,44 @@ TEST_XML_FLAGS(xpath_paths_nodetest_type, "<node attr='value'>pcdata<child/><?pi CHECK_XPATH_FAIL(STR("processing-instruction('', '')"));
}
-TEST_XML_FLAGS(xpath_paths_nodetest_principal, "<node attr='value'>pcdata<child/><?pi1 value?><?pi2 value?><!--comment--><![CDATA[cdata]]></node>", parse_default | parse_pi | parse_comments)
-{
- // $$$ self::* should not select attribute nodes (?)
- // $$$ name, * and name:* should check type = elem (?)
+TEST_XML_FLAGS(xpath_paths_nodetest_principal, "<node attr='value'>pcdata<child/><?pi1 value?><?pi2 value?><!--comment--><![CDATA[cdata]]></node><abra:cadabra abra:arba=''/>", parse_default | parse_pi | parse_comments)
+{
+ // node() test is true for any node type
+ CHECK_XPATH_NODESET(doc, STR("//node()")) % 2 % 4 % 5 % 6 % 7 % 8 % 9 % 10;
+ CHECK_XPATH_NODESET(doc, STR("//attribute::node()")) % 3 % 11;
+ CHECK_XPATH_NODESET(doc, STR("//attribute::node()/ancestor-or-self::node()")) % 1 % 2 % 3 % 10 % 11;
+
+ // name test is true only for node with principal node type (depends on axis)
+ CHECK_XPATH_NODESET(doc, STR("node/child::child")) % 5;
+ CHECK_XPATH_NODESET(doc, STR("node/attribute::attr")) % 3;
+ CHECK_XPATH_NODESET(doc, STR("node/child::pi1"));
+ CHECK_XPATH_NODESET(doc, STR("node/child::attr"));
+ CHECK_XPATH_NODESET(doc, STR("node/child::child/self::child")) % 5;
+ CHECK_XPATH_NODESET(doc, STR("node/attribute::attr/self::attr")); // attribute is not of element type
+ CHECK_XPATH_NODESET(doc, STR("node/child::child/ancestor-or-self::child")) % 5;
+ CHECK_XPATH_NODESET(doc, STR("node/attribute::attr/ancestor-or-self::attr")); // attribute is not of element type
+ CHECK_XPATH_NODESET(doc, STR("node/child::child/descendant-or-self::child")) % 5;
+ CHECK_XPATH_NODESET(doc, STR("node/attribute::attr/descendant-or-self::attr")); // attribute is not of element type
+
+ // any name test is true only for node with principal node type (depends on axis)
+ CHECK_XPATH_NODESET(doc, STR("node/child::*")) % 5;
+ CHECK_XPATH_NODESET(doc, STR("node/attribute::*")) % 3;
+ CHECK_XPATH_NODESET(doc, STR("node/child::*/self::*")) % 5;
+ CHECK_XPATH_NODESET(doc, STR("node/attribute::*/self::*")); // attribute is not of element type
+ CHECK_XPATH_NODESET(doc, STR("node/child::*/ancestor-or-self::*")) % 5 % 2;
+ CHECK_XPATH_NODESET(doc, STR("node/attribute::*/ancestor-or-self::*")) % 2; // attribute is not of element type
+ CHECK_XPATH_NODESET(doc, STR("node/child::*/descendant-or-self::*")) % 5;
+ CHECK_XPATH_NODESET(doc, STR("node/attribute::*/descendant-or-self::*")); // attribute is not of element type
+
+ // namespace test is true only for node with principal node type (depends on axis)
+ CHECK_XPATH_NODESET(doc, STR("child::abra:*")) % 10;
+ CHECK_XPATH_NODESET(doc, STR("child::abra:*/attribute::abra:*")) % 11;
+ CHECK_XPATH_NODESET(doc, STR("child::abra:*/self::abra:*")) % 10;
+ CHECK_XPATH_NODESET(doc, STR("child::abra:*/attribute::abra:*/self::abra:*")); // attribute is not of element type
+ CHECK_XPATH_NODESET(doc, STR("child::abra:*/ancestor-or-self::abra:*")) % 10;
+ CHECK_XPATH_NODESET(doc, STR("child::abra:*/attribute::abra:*/ancestor-or-self::abra:*")) % 10; // attribute is not of element type
+ CHECK_XPATH_NODESET(doc, STR("child::abra:*/descendant-or-self::abra:*")) % 10;
+ CHECK_XPATH_NODESET(doc, STR("child::abra:*/attribute::abra:*/descendant-or-self::abra:*")); // attribute is not of element type
}
TEST_XML(xpath_paths_absolute, "<node><foo><foo/><foo/></foo></node>")
diff --git a/tests/test_xpath_xalan_1.cpp b/tests/test_xpath_xalan_1.cpp index 4e685af..6114bd2 100644 --- a/tests/test_xpath_xalan_1.cpp +++ b/tests/test_xpath_xalan_1.cpp @@ -388,7 +388,7 @@ TEST(xpath_xalan_math_9) CHECK_XPATH_STRING(c, STR("string(number('0.0004'))"), STR("0.0004"));
CHECK_XPATH_STRING(c, STR("string(-1 * number('0.0004'))"), STR("-0.0004"));
-#if 0 // $$$ commented out temporarily because number formatting is not compliant yet
+#if 0 // $$ commented out temporarily because number formatting is not compliant yet
CHECK_XPATH_STRING(c, STR("string(number('0.0000000000001'))"), STR("0.0000000000001"));
CHECK_XPATH_STRING(c, STR("string(-1 * number('0.0000000000001'))"), STR("-0.0000000000001"));
diff --git a/tests/test_xpath_xalan_2.cpp b/tests/test_xpath_xalan_2.cpp index 13838d1..a4c640a 100644 --- a/tests/test_xpath_xalan_2.cpp +++ b/tests/test_xpath_xalan_2.cpp @@ -166,7 +166,7 @@ TEST(xpath_xalan_string_5) CHECK_XPATH_STRING(xml_node(), query.c_str(), expected.c_str());
}
-#if 0 // number formatting is not precise yet; also some compilers don't have a good CRT implementation that can handle large numbers
+#if 0 // $$ number formatting is not precise yet; also some compilers don't have a good CRT implementation that can handle large numbers
TEST(xpath_xalan_string_6)
{
xml_node c;
diff --git a/tests/test_xpath_xalan_3.cpp b/tests/test_xpath_xalan_3.cpp index e36788a..6514560 100644 --- a/tests/test_xpath_xalan_3.cpp +++ b/tests/test_xpath_xalan_3.cpp @@ -59,7 +59,8 @@ TEST_XML_FLAGS(xpath_xalan_axes_2, "<far-north> Level-1<north-north-west1/><nort CHECK_XPATH_NODESET(center, STR("@*/self::node()")) % 21 % 22 % 23;
CHECK_XPATH_NODESET(center, STR("@*/.")) % 21 % 22 % 23;
CHECK_XPATH_NODESET(center, STR("@*/descendant-or-self::node()")) % 21 % 22 % 23;
- CHECK_XPATH_NODESET(center, STR("@*/ancestor-or-self::*")) % 2 % 9 % 13 % 20 % 21 % 22 % 23;
+ CHECK_XPATH_NODESET(center, STR("@*/ancestor-or-self::node()")) % 1 % 2 % 9 % 13 % 20 % 21 % 22 % 23;
+ CHECK_XPATH_NODESET(center, STR("@*/ancestor-or-self::*")) % 2 % 9 % 13 % 20;
CHECK_XPATH_NODESET(center, STR("@*/preceding-sibling::node()"));
CHECK_XPATH_NODESET(center, STR("@*/following-sibling::*"));
CHECK_XPATH_NODESET(center, STR("@*/ancestor::*/near-north/*[4]/@*/preceding::*")) % 4 % 5 % 14 % 15 % 16;
@@ -318,9 +319,9 @@ TEST_XML(xpath_xalan_axes_18, "<north><center center-attr='here'><south/></cente xml_node center = doc.child(STR("north")).child(STR("center"));
CHECK_XPATH_NODESET(center, STR("@*/self::node()")) % 4;
- CHECK_XPATH_NODESET(center, STR("@*/self::*")) % 4; // $$$ wrong - should be empty, since * test tests for principal node type
+ CHECK_XPATH_NODESET(center, STR("@*/self::*")); // * tests for principal node type
CHECK_XPATH_NODESET(center, STR("@*/self::text()"));
- CHECK_XPATH_NODESET(center, STR("@*/self::center-attr")) % 4; // $$$ wrong - should be empty, since name test tests for principal node type
+ CHECK_XPATH_NODESET(center, STR("@*/self::center-attr")); // * tests for principal node type
}
#endif
|