From e2ac08d5b40cfa3e4d001be35178ea0e4ef75aad Mon Sep 17 00:00:00 2001 From: "arseny.kapoulkine" Date: Wed, 28 Oct 2009 21:15:05 +0000 Subject: tests: Fixed NaN tests for MSVC6 git-svn-id: http://pugixml.googlecode.com/svn/trunk@189 99668b35-9821-0410-8761-19e4c4f06640 --- tests/test.hpp | 5 +++++ tests/test_xpath_operators.cpp | 23 +++++++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/test.hpp b/tests/test.hpp index 166cce5..5bbfbbd 100644 --- a/tests/test.hpp +++ b/tests/test.hpp @@ -3,6 +3,7 @@ #include #include +#include #include #include "../src/pugixml.hpp" @@ -52,7 +53,11 @@ inline bool test_xpath_number_nan(const pugi::xml_node& node, const char* query) double r = q.evaluate_number(node); +#ifdef _MSC_VER + return _isnan(r) != 0; +#else return r != r; +#endif } inline bool test_xpath_fail_compile(const char* query) diff --git a/tests/test_xpath_operators.cpp b/tests/test_xpath_operators.cpp index 7ff2f70..db834cd 100644 --- a/tests/test_xpath_operators.cpp +++ b/tests/test_xpath_operators.cpp @@ -1,5 +1,9 @@ #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 + TEST_XML(xpath_operators_arithmetic, "1023") { xml_node c; @@ -125,9 +129,12 @@ TEST(xpath_operators_equality_primitive_number) // infinity/nan CHECK_XPATH_BOOLEAN(c, "1 div 0 = 2 div 0", true); CHECK_XPATH_BOOLEAN(c, "-1 div 0 != 2 div 0", true); + +#ifndef MSVC6_NAN_BUG CHECK_XPATH_BOOLEAN(c, "0 div 0 = 1", false); CHECK_XPATH_BOOLEAN(c, "0 div 0 != 1", true); CHECK_XPATH_BOOLEAN(c, "0 div 0 = 0 div 0", false); +#endif // upcast to number CHECK_XPATH_BOOLEAN(c, "2 = '2'", true); @@ -190,14 +197,17 @@ TEST_XML(xpath_operators_equality_node_set_primitive, "1-1 2 div 0", false); +#ifndef MSVC6_NAN_BUG CHECK_XPATH_BOOLEAN(c, "0 div 0 < 1", false); CHECK_XPATH_BOOLEAN(c, "0 div 0 <= 1", false); CHECK_XPATH_BOOLEAN(c, "0 div 0 > 1", false); CHECK_XPATH_BOOLEAN(c, "0 div 0 >= 1", false); +#endif // upcast to number CHECK_XPATH_BOOLEAN(c, "2 < '2'", false); @@ -277,7 +289,7 @@ TEST(xpath_operators_inequality_primitive) CHECK_XPATH_BOOLEAN(c, "1 > true()", false); } -TEST_XML(xpath_operators_inequality_node_set_node_set, "1-1-1001nan") +TEST_XML(xpath_operators_inequality_node_set_node_set, "1-1-1001nan1-4") { xml_node c; xml_node n = doc.child("node"); @@ -298,10 +310,17 @@ TEST_XML(xpath_operators_inequality_node_set_node_set, "1-1< CHECK_XPATH_BOOLEAN(n, "x >= c1/v", false); CHECK_XPATH_BOOLEAN(n, "x <= c1/v", false); + CHECK_XPATH_BOOLEAN(n, "c1/v > c3/v", true); + CHECK_XPATH_BOOLEAN(n, "c1/v >= c3/v", true); + CHECK_XPATH_BOOLEAN(n, "c1/v < c3/v", true); + CHECK_XPATH_BOOLEAN(n, "c1/v <= c3/v", true); + +#ifndef MSVC6_NAN_BUG CHECK_XPATH_BOOLEAN(n, "c1/v > c2/v", false); CHECK_XPATH_BOOLEAN(n, "c1/v >= c2/v", true); CHECK_XPATH_BOOLEAN(n, "c1/v < c2/v", true); CHECK_XPATH_BOOLEAN(n, "c1/v <= c2/v", true); +#endif } TEST_XML(xpath_operators_inequality_node_set_primitive, "1-1-1001nan") -- cgit v1.2.3