summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2010-05-29 13:36:53 +0000
committerarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2010-05-29 13:36:53 +0000
commit162962a7364a6c39a49f7936adee2a6d0cdb8da5 (patch)
tree90c0020017ccc7b2ab2dacc64fd1c56380166163 /tests
parentd3419f2f4bcac79065a8067d41630bd702046eb8 (diff)
tests: Fixed tests for wchar_t mode, disabled some tests on compilers with broken NaN behavior
git-svn-id: http://pugixml.googlecode.com/svn/trunk@463 99668b35-9821-0410-8761-19e4c4f06640
Diffstat (limited to 'tests')
-rw-r--r--tests/test.hpp6
-rw-r--r--tests/test_xpath.cpp20
-rw-r--r--tests/test_xpath_operators.cpp12
-rw-r--r--tests/test_xpath_xalan_1.cpp25
4 files changed, 34 insertions, 29 deletions
diff --git a/tests/test.hpp b/tests/test.hpp
index 5559baa..e99eb57 100644
--- a/tests/test.hpp
+++ b/tests/test.hpp
@@ -134,6 +134,12 @@ struct dummy_fixture {};
#define U_LITERALS // DMC does not understand \x01234 (it parses first three digits), but understands \u01234
#endif
+#if (defined(_MSC_VER) && _MSC_VER == 1200) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER == 800) || defined(__BORLANDC__)
+// NaN comparison on MSVC6 is incorrect, see http://www.nabble.com/assertDoubleEquals,-NaN---Microsoft-Visual-Studio-6-td9137859.html
+// IC8 and BCC are also affected by the same bug
+# define MSVC6_NAN_BUG
+#endif
+
inline wchar_t wchar_cast(unsigned int value)
{
return static_cast<wchar_t>(value); // to avoid C4310 on MSVC
diff --git a/tests/test_xpath.cpp b/tests/test_xpath.cpp
index 6f7f756..3a855cc 100644
--- a/tests/test_xpath.cpp
+++ b/tests/test_xpath.cpp
@@ -186,15 +186,15 @@ TEST_XML(xpath_xsl_list_2, "<TR><TD id='1'>text1</TD><TD id='2'>text2</TD><TD id
{
CHECK_XPATH_FAIL(STR(".[not(.=ancestor::TR/TD[15]/node())]"));
- CHECK_XPATH_NODESET(doc.child("TR").find_child_by_attribute("TD", "id", "1").first_child(), STR("self::node()[not(.=ancestor::TR/TD[3]/node())]")) % 5;
- CHECK_XPATH_NODESET(doc.child("TR").find_child_by_attribute("TD", "id", "2").first_child(), STR("self::node()[not(.=ancestor::TR/TD[3]/node())]")) % 8;
- CHECK_XPATH_NODESET(doc.child("TR").find_child_by_attribute("TD", "id", "3").first_child(), STR("self::node()[not(.=ancestor::TR/TD[3]/node())]"));
- CHECK_XPATH_NODESET(doc.child("TR").find_child_by_attribute("TD", "id", "4").first_child(), STR("self::node()[not(.=ancestor::TR/TD[3]/node())]")) % 14;
+ CHECK_XPATH_NODESET(doc.child(STR("TR")).find_child_by_attribute(STR("TD"), STR("id"), STR("1")).first_child(), STR("self::node()[not(.=ancestor::TR/TD[3]/node())]")) % 5;
+ CHECK_XPATH_NODESET(doc.child(STR("TR")).find_child_by_attribute(STR("TD"), STR("id"), STR("2")).first_child(), STR("self::node()[not(.=ancestor::TR/TD[3]/node())]")) % 8;
+ CHECK_XPATH_NODESET(doc.child(STR("TR")).find_child_by_attribute(STR("TD"), STR("id"), STR("3")).first_child(), STR("self::node()[not(.=ancestor::TR/TD[3]/node())]"));
+ CHECK_XPATH_NODESET(doc.child(STR("TR")).find_child_by_attribute(STR("TD"), STR("id"), STR("4")).first_child(), STR("self::node()[not(.=ancestor::TR/TD[3]/node())]")) % 14;
- CHECK_XPATH_NODESET(doc.child("TR").find_child_by_attribute("TD", "id", "1"), STR("node()[not(.=ancestor::TR/TD[3]/node())]")) % 5;
- CHECK_XPATH_NODESET(doc.child("TR").find_child_by_attribute("TD", "id", "2"), STR("node()[not(.=ancestor::TR/TD[3]/node())]")) % 8;
- CHECK_XPATH_NODESET(doc.child("TR").find_child_by_attribute("TD", "id", "3"), STR("node()[not(.=ancestor::TR/TD[3]/node())]"));
- CHECK_XPATH_NODESET(doc.child("TR").find_child_by_attribute("TD", "id", "4"), STR("node()[not(.=ancestor::TR/TD[3]/node())]")) % 14;
+ CHECK_XPATH_NODESET(doc.child(STR("TR")).find_child_by_attribute(STR("TD"), STR("id"), STR("1")), STR("node()[not(.=ancestor::TR/TD[3]/node())]")) % 5;
+ CHECK_XPATH_NODESET(doc.child(STR("TR")).find_child_by_attribute(STR("TD"), STR("id"), STR("2")), STR("node()[not(.=ancestor::TR/TD[3]/node())]")) % 8;
+ CHECK_XPATH_NODESET(doc.child(STR("TR")).find_child_by_attribute(STR("TD"), STR("id"), STR("3")), STR("node()[not(.=ancestor::TR/TD[3]/node())]"));
+ CHECK_XPATH_NODESET(doc.child(STR("TR")).find_child_by_attribute(STR("TD"), STR("id"), STR("4")), STR("node()[not(.=ancestor::TR/TD[3]/node())]")) % 14;
}
TEST_XML(xpath_star_token, "<node>0.5<section><child/><child/><child/><child/></section><section/></node>")
@@ -206,8 +206,8 @@ TEST_XML(xpath_star_token, "<node>0.5<section><child/><child/><child/><child/></
TEST(xpath_miscellaneous)
{
- CHECK_XPATH_FAIL("/root/child[a=3]/substring(child::text())");
- CHECK_XPATH_NODESET(xml_node(), "foo/@FOO/@bar");
+ CHECK_XPATH_FAIL(STR("/root/child[a=3]/substring(child::text())"));
+ CHECK_XPATH_NODESET(xml_node(), STR("foo/@FOO/@bar"));
}
#endif
diff --git a/tests/test_xpath_operators.cpp b/tests/test_xpath_operators.cpp
index 610e2b2..0355e46 100644
--- a/tests/test_xpath_operators.cpp
+++ b/tests/test_xpath_operators.cpp
@@ -2,18 +2,6 @@
#include "common.hpp"
-#if defined(_MSC_VER) && _MSC_VER == 1200
-# define MSVC6_NAN_BUG // NaN comparison on MSVC6 is incorrect, see http://www.nabble.com/assertDoubleEquals,-NaN---Microsoft-Visual-Studio-6-td9137859.html
-#endif
-
-#if defined(__INTEL_COMPILER) && __INTEL_COMPILER == 800
-# define MSVC6_NAN_BUG // IC8 seems to have the same bug as MSVC6 does
-#endif
-
-#if defined(__BORLANDC__)
-# define MSVC6_NAN_BUG // BCC seems to have the same bug as MSVC6 does
-#endif
-
TEST_XML(xpath_operators_arithmetic, "<node><foo-bar>10</foo-bar><foo>2</foo><bar>3</bar></node>")
{
xml_node c;
diff --git a/tests/test_xpath_xalan_1.cpp b/tests/test_xpath_xalan_1.cpp
index c1d2733..4e685af 100644
--- a/tests/test_xpath_xalan_1.cpp
+++ b/tests/test_xpath_xalan_1.cpp
@@ -103,7 +103,7 @@ TEST_XML(xpath_xalan_boolean_4, "<avj><a>foo</a><b>bar</b><c>foobar</c><d>foo</d
TEST_XML(xpath_xalan_boolean_5, "<doc><j l='12' w='33'>first</j><j l='17' w='45'>second</j><j l='16' w='78'>third</j><j l='12' w='33'>fourth</j></doc>")
{
- xml_node c = doc.child("doc");
+ xml_node c = doc.child(STR("doc"));
CHECK_XPATH_BOOLEAN(c, STR("j[@l='12'] = j[@w='33']"), true);
CHECK_XPATH_BOOLEAN(c, STR("j[@l='12'] = j[@l='17']"), false);
@@ -117,7 +117,7 @@ TEST_XML(xpath_xalan_boolean_5, "<doc><j l='12' w='33'>first</j><j l='17' w='45'
TEST_XML(xpath_xalan_boolean_6, "<doc><avj><good><b>12</b><c>34</c><d>56</d><e>78</e></good></avj></doc>")
{
- xml_node c = doc.child("doc");
+ xml_node c = doc.child(STR("doc"));
CHECK_XPATH_BOOLEAN(c, STR("avj/good/*=34"), true);
CHECK_XPATH_BOOLEAN(c, STR("not(avj/good/*=34)"), false);
@@ -132,7 +132,7 @@ TEST_XML(xpath_xalan_boolean_6, "<doc><avj><good><b>12</b><c>34</c><d>56</d><e>7
TEST_XML(xpath_xalan_boolean_7, "<doc><avj><bool><b>true</b><c></c><d>false?</d><e>1</e><f>0</f></bool></avj></doc>")
{
- xml_node c = doc.child("doc");
+ xml_node c = doc.child(STR("doc"));
CHECK_XPATH_BOOLEAN(c, STR("avj/bool/*=true()"), true);
CHECK_XPATH_BOOLEAN(c, STR("not(avj/bool/*=true())"), false);
@@ -165,7 +165,7 @@ TEST_XML(xpath_xalan_conditional, "<letters>b</letters>")
CHECK_XPATH_BOOLEAN(c, STR("'a'='a'"), true);
CHECK_XPATH_BOOLEAN(c, STR("2+2=4"), true);
- xml_node b = doc.child("letters").first_child();
+ xml_node b = doc.child(STR("letters")).first_child();
CHECK_XPATH_BOOLEAN(b, STR(".='b'"), true);
CHECK_XPATH_BOOLEAN(b, STR("name(..)='letters'"), true);
@@ -194,8 +194,12 @@ TEST_XML(xpath_xalan_math_1, "<a>3</a>")
CHECK_XPATH_BOOLEAN(c, STR("number(string(1.0))=1"), true);
CHECK_XPATH_BOOLEAN(c, STR("number(true())=1"), true);
CHECK_XPATH_BOOLEAN(c, STR("number(false())=0"), true);
+
+#ifndef MSVC6_NAN_BUG
CHECK_XPATH_BOOLEAN(c, STR("number('xxx')=number('xxx')"), false);
CHECK_XPATH_BOOLEAN(c, STR("number('xxx')=0"), false);
+#endif
+
CHECK_XPATH_NUMBER(doc, STR("floor(a)"), 3);
CHECK_XPATH_NUMBER(c, STR("floor(1.9)"), 1);
CHECK_XPATH_NUMBER(c, STR("floor(2.999999)"), 2);
@@ -243,7 +247,7 @@ TEST_XML(xpath_xalan_math_3, "<doc><n v='1'/><n>2</n><n v='3'/><n>4</n><n v='5'>
TEST_XML(xpath_xalan_math_4, "<doc><n1 a='1'>2</n1><n2 a='2'>3</n2><n1-n2>123</n1-n2><n-1>72</n-1><n-2>12</n-2><div a='2'>5</div><mod a='5'>2</mod></doc>")
{
- xml_node c = doc.child("doc");
+ xml_node c = doc.child(STR("doc"));
CHECK_XPATH_NUMBER(c, STR("n1*n2"), 6);
CHECK_XPATH_NUMBER(c, STR("n1/@a*n2/@a"), 2);
@@ -275,8 +279,11 @@ TEST_XML(xpath_xalan_math_4, "<doc><n1 a='1'>2</n1><n2 a='2'>3</n2><n1-n2>123</n
CHECK_XPATH_BOOLEAN(c, STR("1 div -0 = 2 div -0"), true);
CHECK_XPATH_BOOLEAN(c, STR("1 div -0 = 1 div 0"), false);
CHECK_XPATH_BOOLEAN(c, STR("1 div -0 = -1 div 0"), true);
+
+#ifndef MSVC6_NAN_BUG
CHECK_XPATH_BOOLEAN(c, STR("0 div 0 >= 0"), false);
CHECK_XPATH_BOOLEAN(c, STR("0 div 0 < 0"), false);
+#endif
CHECK_XPATH_NUMBER(c, STR("n1 mod n2"), 2);
CHECK_XPATH_NUMBER(c, STR("div mod mod"), 1);
@@ -301,8 +308,12 @@ TEST(xpath_xalan_math_5)
CHECK_XPATH_NUMBER_NAN(c, STR("number('xxx') - 3"));
CHECK_XPATH_NUMBER_NAN(c, STR("2 div number('xxx')"));
CHECK_XPATH_NUMBER_NAN(c, STR("number('xxx') div 3"));
+
+#ifndef __BORLANDC__ // BCC fmod does not propagate NaN correctly
CHECK_XPATH_NUMBER_NAN(c, STR("2 mod number('xxx')"));
CHECK_XPATH_NUMBER_NAN(c, STR("number('xxx') mod 3"));
+#endif
+
CHECK_XPATH_NUMBER_NAN(c, STR("floor(number('xxx'))"));
CHECK_XPATH_NUMBER_NAN(c, STR("ceiling(number('xxx'))"));
CHECK_XPATH_NUMBER_NAN(c, STR("round(number('xxx'))"));
@@ -323,7 +334,7 @@ TEST(xpath_xalan_math_5)
TEST_XML(xpath_xalan_math_6, "<doc><n1>3</n1><n2>7</n2><n3>x</n3></doc>")
{
- xml_node c = doc.child("doc");
+ xml_node c = doc.child(STR("doc"));
CHECK_XPATH_NUMBER(c, STR("-(n1|n2)"), -3);
CHECK_XPATH_NUMBER(c, STR("-(n2|n1)"), -3);
@@ -333,7 +344,7 @@ TEST_XML(xpath_xalan_math_6, "<doc><n1>3</n1><n2>7</n2><n3>x</n3></doc>")
TEST_XML(xpath_xalan_math_7, "<doc><n1>3</n1><n2>7</n2><n3>x</n3></doc>")
{
- xml_node c = doc.child("doc");
+ xml_node c = doc.child(STR("doc"));
CHECK_XPATH_NUMBER(c, STR("-(n1|n2)"), -3);
CHECK_XPATH_NUMBER(c, STR("-(n2|n1)"), -3);