[Libreoffice-commits] core.git: sal/qa sal/rtl
Eike Rathke
erack at redhat.com
Mon Jun 27 18:28:50 UTC 2016
sal/qa/rtl/math/test-rtl-math.cxx | 28 ++++++++++++++++++++++++++++
sal/rtl/math.cxx | 2 +-
2 files changed, 29 insertions(+), 1 deletion(-)
New commits:
commit 08d8642491771577bfadeaedf3e03bdcea404d26
Author: Eike Rathke <erack at redhat.com>
Date: Mon Jun 27 20:13:40 2016 +0200
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
diff --git a/sal/qa/rtl/math/test-rtl-math.cxx b/sal/qa/rtl/math/test-rtl-math.cxx
index bdfd197..dc40b22 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() {
diff --git a/sal/rtl/math.cxx b/sal/rtl/math.cxx
index 63aa657..92de8b6 100644
--- a/sal/rtl/math.cxx
+++ b/sal/rtl/math.cxx
@@ -669,7 +669,7 @@ inline double stringToDouble(CharT const * pBegin, CharT const * pEnd,
bool bDone = false;
// #i112652# XMLSchema-2
- if (3 >= (pEnd - p))
+ if (3 <= (pEnd - p))
{
if ((CharT('N') == p[0]) && (CharT('a') == p[1])
&& (CharT('N') == p[2]))
More information about the Libreoffice-commits
mailing list