summaryrefslogtreecommitdiff
path: root/tests/test_xpath_operators.cpp
diff options
context:
space:
mode:
authorarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2010-05-30 18:21:49 +0000
committerarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2010-05-30 18:21:49 +0000
commitd567700d19cc94141e5cd792b2009baab18d2501 (patch)
treef5cbe6535d436a102cd08ec678d1b9880ce872e4 /tests/test_xpath_operators.cpp
parent724a3775440be418eca2617bc970ad1bb35a67c4 (diff)
tests: Added more tests (including a couple of failing ones)
git-svn-id: http://pugixml.googlecode.com/svn/trunk@474 99668b35-9821-0410-8761-19e4c4f06640
Diffstat (limited to 'tests/test_xpath_operators.cpp')
-rw-r--r--tests/test_xpath_operators.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/test_xpath_operators.cpp b/tests/test_xpath_operators.cpp
index 0355e46..5c7c0e9 100644
--- a/tests/test_xpath_operators.cpp
+++ b/tests/test_xpath_operators.cpp
@@ -406,4 +406,51 @@ TEST_XML(xpath_operators_union, "<node><employee/><employee secretary=''/><emplo
CHECK_XPATH_NODESET(n, STR(". | tail/preceding-sibling::employee | .")) % 2 % 3 % 4 % 6 % 8 % 11;
}
+TEST(xpath_operators_union_error)
+{
+ CHECK_XPATH_FAIL(STR(". | true()"));
+ CHECK_XPATH_FAIL(STR(". | 1"));
+ CHECK_XPATH_FAIL(STR(". | '1'"));
+ CHECK_XPATH_FAIL(STR(". | count(.)"));
+ CHECK_XPATH_FAIL(STR("true() | ."));
+ CHECK_XPATH_FAIL(STR("1 | ."));
+ CHECK_XPATH_FAIL(STR("'1' | ."));
+ CHECK_XPATH_FAIL(STR("count(.) | ."));
+}
+
+TEST(xpath_operators_associativity_boolean)
+{
+ xml_node c;
+
+ CHECK_XPATH_BOOLEAN(c, STR("false() or true() and true() and false()"), false);
+ CHECK_XPATH_BOOLEAN(c, STR("3 > 2 > 1"), false);
+ CHECK_XPATH_BOOLEAN(c, STR("4 > 3 > 2 > 1"), false);
+ CHECK_XPATH_BOOLEAN(c, STR("5 > 4 > 3 > 2 > 1"), false);
+ CHECK_XPATH_BOOLEAN(c, STR("1 < 2 < 3 < 4 < 5"), true);
+ CHECK_XPATH_BOOLEAN(c, STR("1 <= 2 <= 3 <= 4 <= 5"), true);
+ CHECK_XPATH_BOOLEAN(c, STR("5 >= 4 >= 3 >= 2 >= 1"), false);
+ CHECK_XPATH_BOOLEAN(c, STR("3 >= 2 >= 1"), true);
+ CHECK_XPATH_BOOLEAN(c, STR("2 >= 1"), true);
+ CHECK_XPATH_BOOLEAN(c, STR("4 >= 3 >= 2 >= 1"), false);
+ CHECK_XPATH_BOOLEAN(c, STR("((((5 > 4) > 3) > 2) > 1)"), false);
+ CHECK_XPATH_BOOLEAN(c, STR("2 != 3 != 1 != 4 != 0"), true);
+ CHECK_XPATH_BOOLEAN(c, STR("(((2 != 3) != 1) != 4) != 0"), true);
+ CHECK_XPATH_BOOLEAN(c, STR("2 != 3 != 1 != 4 != 1"), false);
+ CHECK_XPATH_BOOLEAN(c, STR("(((2 != 3) != 1) != 4) != 1"), false);
+ CHECK_XPATH_BOOLEAN(c, STR("2 = 3 = 1 = 4 = 0"), true);
+ CHECK_XPATH_BOOLEAN(c, STR("(((2 = 3) = 1) = 4) = 0"), true);
+ CHECK_XPATH_BOOLEAN(c, STR("2 = 3 = 1 = 4 = 1"), false);
+ CHECK_XPATH_BOOLEAN(c, STR("(((2 = 3) = 1) = 4) = 1"), false);
+}
+
+TEST(xpath_operators_associativity_arithmetic)
+{
+ xml_node c;
+
+ CHECK_XPATH_NUMBER(c, STR("2+1-1+1"), 3);
+ CHECK_XPATH_NUMBER(c, STR("1+2+1-1+1"), 4);
+ CHECK_XPATH_NUMBER(c, STR("1+1+2+1-1+1"), 5);
+ CHECK_XPATH_NUMBER(c, STR("1-1+1"), 1);
+}
+
#endif