summaryrefslogtreecommitdiff
path: root/tests/test_xpath.cpp
diff options
context:
space:
mode:
authorarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2010-06-14 18:03:50 +0000
committerarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2010-06-14 18:03:50 +0000
commit4394a588c2d8f07b12201592054234cb321f37e5 (patch)
treee21b03e83893d3df0b5656ad793548a16c41f058 /tests/test_xpath.cpp
parent30fbb3e32807a856659e8b4d5fa4b5003519a43d (diff)
XPath: Rewritten number->string conversion using CRT scientific format (much better XPath REC compliance)
git-svn-id: http://pugixml.googlecode.com/svn/trunk@523 99668b35-9821-0410-8761-19e4c4f06640
Diffstat (limited to 'tests/test_xpath.cpp')
-rw-r--r--tests/test_xpath.cpp26
1 files changed, 20 insertions, 6 deletions
diff --git a/tests/test_xpath.cpp b/tests/test_xpath.cpp
index 3a855cc..7b52437 100644
--- a/tests/test_xpath.cpp
+++ b/tests/test_xpath.cpp
@@ -118,13 +118,27 @@ TEST(xpath_long_numbers_stringize)
xml_node c;
- CHECK(test_xpath_string_prefix(c, str_flt_max, str_flt_max, 16));
- CHECK(test_xpath_string_prefix(c, str_flt_max_dec, str_flt_max, 16));
+ CHECK(test_xpath_string_prefix(c, str_flt_max, str_flt_max, 15));
+ CHECK(test_xpath_string_prefix(c, str_flt_max_dec, str_flt_max, 15));
-#ifndef __BORLANDC__ // printf with %f format still results in 1.xxxe+308 form
- CHECK(test_xpath_string_prefix(c, str_dbl_max, str_dbl_max, 16));
- CHECK(test_xpath_string_prefix(c, str_dbl_max_dec, str_dbl_max, 16));
-#endif
+ CHECK(test_xpath_string_prefix(c, str_dbl_max, str_dbl_max, 15));
+ CHECK(test_xpath_string_prefix(c, str_dbl_max_dec, str_dbl_max, 15));
+}
+
+#include <stdio.h>
+
+TEST(xpath_denorm_numbers)
+{
+ pugi::string_t query;
+
+ // 10^-318 - double denormal
+ for (int i = 0; i < 106; ++i)
+ {
+ if (i != 0) query += STR(" * ");
+ query += STR("0.001");
+ }
+
+ CHECK_XPATH_STRING(xml_node(), query.c_str(), STR("0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009999987484955998"));
}
TEST_XML(xpath_rexml_1, "<a><b><c id='a'/></b><c id='b'/></a>")