summaryrefslogtreecommitdiff
path: root/sal/qa
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2016-06-27 20:13:40 +0200
committerEike Rathke <erack@redhat.com>2016-06-27 20:28:25 +0200
commit08d8642491771577bfadeaedf3e03bdcea404d26 (patch)
tree2a3b0266117a5817e6c1a6e9f01ffb4ebe93d814 /sal/qa
parent1df394503f1e62b091453c95c05a212892ae8d58 (diff)
stringToDouble() fix broken reverse logic for NaN and INF
... and do not test up to three characters if the string is shorter.. Change-Id: I52b74cbde10c14c991cc8c68760c87c1e08ab7e4
Diffstat (limited to 'sal/qa')
-rw-r--r--sal/qa/rtl/math/test-rtl-math.cxx28
1 files changed, 28 insertions, 0 deletions
diff --git a/sal/qa/rtl/math/test-rtl-math.cxx b/sal/qa/rtl/math/test-rtl-math.cxx
index bdfd19710b2e..dc40b22f80e6 100644
--- a/sal/qa/rtl/math/test-rtl-math.cxx
+++ b/sal/qa/rtl/math/test-rtl-math.cxx
@@ -58,6 +58,34 @@ public:
CPPUNIT_ASSERT_EQUAL(rtl_math_ConversionStatus_Ok, status);
CPPUNIT_ASSERT_EQUAL(sal_Int32(RTL_CONSTASCII_LENGTH(" +1.E01")), end);
CPPUNIT_ASSERT_EQUAL(10.0, res);
+
+ res = rtl::math::stringToDouble(
+ rtl::OUString("NaN"),
+ '.', ',', &status, &end);
+ CPPUNIT_ASSERT_EQUAL(rtl_math_ConversionStatus_Ok, status);
+ CPPUNIT_ASSERT_EQUAL(3, end);
+ CPPUNIT_ASSERT_EQUAL(rtl::math::isNan(res), true);
+
+ res = rtl::math::stringToDouble(
+ rtl::OUString("NaN1.23"),
+ '.', ',', &status, &end);
+ CPPUNIT_ASSERT_EQUAL(rtl_math_ConversionStatus_Ok, status);
+ CPPUNIT_ASSERT_EQUAL(3, end);
+ CPPUNIT_ASSERT_EQUAL(rtl::math::isNan(res), true);
+
+ res = rtl::math::stringToDouble(
+ rtl::OUString("INF"),
+ '.', ',', &status, &end);
+ CPPUNIT_ASSERT_EQUAL(rtl_math_ConversionStatus_OutOfRange, status);
+ CPPUNIT_ASSERT_EQUAL(3, end);
+ CPPUNIT_ASSERT_EQUAL(rtl::math::isInf(res), true);
+
+ res = rtl::math::stringToDouble(
+ rtl::OUString("INF1.23"),
+ '.', ',', &status, &end);
+ CPPUNIT_ASSERT_EQUAL(rtl_math_ConversionStatus_OutOfRange, status);
+ CPPUNIT_ASSERT_EQUAL(3, end);
+ CPPUNIT_ASSERT_EQUAL(rtl::math::isInf(res), true);
}
void test_stringToDouble_bad() {