diff options
author | arseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640> | 2010-05-31 12:00:38 +0000 |
---|---|---|
committer | arseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640> | 2010-05-31 12:00:38 +0000 |
commit | d8b256203c01eaa8ce7b54e296ff33bd1afaf583 (patch) | |
tree | e08ed3a93cf4c32538810521925d168b64fcf47e /tests/test_xpath_operators.cpp | |
parent | a2433c90a284d94310ec9955bd37c3009b25104c (diff) |
tests: Added more XPath tests based on recommendation errata
git-svn-id: http://pugixml.googlecode.com/svn/trunk@483 99668b35-9821-0410-8761-19e4c4f06640
Diffstat (limited to 'tests/test_xpath_operators.cpp')
-rw-r--r-- | tests/test_xpath_operators.cpp | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/tests/test_xpath_operators.cpp b/tests/test_xpath_operators.cpp index 5c7c0e9..b834b95 100644 --- a/tests/test_xpath_operators.cpp +++ b/tests/test_xpath_operators.cpp @@ -2,10 +2,9 @@ #include "common.hpp"
-TEST_XML(xpath_operators_arithmetic, "<node><foo-bar>10</foo-bar><foo>2</foo><bar>3</bar></node>")
+TEST(xpath_operators_arithmetic)
{
xml_node c;
- xml_node n = doc.child(STR("node"));
// incorrect unary operator
CHECK_XPATH_FAIL(STR("-"));
@@ -43,6 +42,17 @@ TEST_XML(xpath_operators_arithmetic, "<node><foo-bar>10</foo-bar><foo>2</foo><ba CHECK_XPATH_NUMBER(c, STR("2+-2"), 0);
CHECK_XPATH_NUMBER(c, STR("1-2-3"), -4);
+ // mod, from W3C standard
+ CHECK_XPATH_NUMBER(c, STR("5 mod 2"), 1);
+ CHECK_XPATH_NUMBER(c, STR("5 mod -2"), 1);
+ CHECK_XPATH_NUMBER(c, STR("-5 mod 2"), -1);
+ CHECK_XPATH_NUMBER(c, STR("-5 mod -2"), -1);
+}
+
+TEST(xpath_operators_arithmetic_specials)
+{
+ xml_node c;
+
// infinity/nan
CHECK_XPATH_STRING(c, STR("1 div 0"), STR("Infinity"));
CHECK_XPATH_STRING(c, STR("-1 div 0"), STR("-Infinity"));
@@ -53,12 +63,19 @@ TEST_XML(xpath_operators_arithmetic, "<node><foo-bar>10</foo-bar><foo>2</foo><ba CHECK_XPATH_STRING(c, STR("1 div 0 + 100"), STR("Infinity"));
CHECK_XPATH_STRING(c, STR("-1 div 0 + 100"), STR("-Infinity"));
CHECK_XPATH_STRING(c, STR("0 div 0 + 100"), STR("NaN"));
+
+ // unary - and multiplication clarifications from recommendations errata
+ CHECK_XPATH_STRING(c, STR("1 div -0"), STR("-Infinity"));
+ CHECK_XPATH_STRING(c, STR("-1 div -0"), STR("Infinity"));
+ CHECK_XPATH_STRING(c, STR("1 div (-0 * 1)"), STR("-Infinity"));
+ CHECK_XPATH_STRING(c, STR("-1 div (0 * -1)"), STR("Infinity"));
+ CHECK_XPATH_STRING(c, STR("1 div (-0 div 1)"), STR("-Infinity"));
+ CHECK_XPATH_STRING(c, STR("-1 div (0 div -1)"), STR("Infinity"));
+}
- // mod, from W3C standard
- CHECK_XPATH_NUMBER(c, STR("5 mod 2"), 1);
- CHECK_XPATH_NUMBER(c, STR("5 mod -2"), 1);
- CHECK_XPATH_NUMBER(c, STR("-5 mod 2"), -1);
- CHECK_XPATH_NUMBER(c, STR("-5 mod -2"), -1);
+TEST_XML(xpath_operators_arithmetic_subtraction_parse, "<node><foo-bar>10</foo-bar><foo>2</foo><bar>3</bar></node>")
+{
+ xml_node n = doc.child(STR("node"));
// correct subtraction parsing, from W3C standard
CHECK_XPATH_NUMBER(n, STR("foo-bar"), 10);
|