diff options
author | Eike Rathke <erack@redhat.com> | 2016-06-27 21:59:06 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2016-06-27 21:59:13 +0200 |
commit | 2d6a88135ef107e5927c7a6cd2542ad1bc8bbe09 (patch) | |
tree | 8777e4809ab13676c17b8a4af8b169a8af7b6715 /sal | |
parent | 9a6527a98fb968b3fe6bc293ff7520a9480d43d0 (diff) |
unit tests for stringToDouble() separator without digits
Change-Id: I85cfe8123a6ef1c3a1aa1b1085e2961055dfa907
Diffstat (limited to 'sal')
-rw-r--r-- | sal/qa/rtl/math/test-rtl-math.cxx | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/sal/qa/rtl/math/test-rtl-math.cxx b/sal/qa/rtl/math/test-rtl-math.cxx index 58b27b0801cc..7dd492db30aa 100644 --- a/sal/qa/rtl/math/test-rtl-math.cxx +++ b/sal/qa/rtl/math/test-rtl-math.cxx @@ -86,6 +86,20 @@ public: CPPUNIT_ASSERT_EQUAL(rtl_math_ConversionStatus_OutOfRange, status); CPPUNIT_ASSERT_EQUAL(sal_Int32(3), end); CPPUNIT_ASSERT_EQUAL(rtl::math::isInf(res), true); + + res = rtl::math::stringToDouble( + rtl::OUString(".5"), + '.', ',', &status, &end); + CPPUNIT_ASSERT_EQUAL(rtl_math_ConversionStatus_Ok, status); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), end); + CPPUNIT_ASSERT_EQUAL(0.5, res); + + res = rtl::math::stringToDouble( + rtl::OUString("5."), + '.', ',', &status, &end); + CPPUNIT_ASSERT_EQUAL(rtl_math_ConversionStatus_Ok, status); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), end); + CPPUNIT_ASSERT_EQUAL(5.0, res); } void test_stringToDouble_bad() { @@ -97,6 +111,27 @@ public: CPPUNIT_ASSERT_EQUAL(rtl_math_ConversionStatus_Ok, status); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), end); CPPUNIT_ASSERT_EQUAL(0.0, res); + + res = rtl::math::stringToDouble( + rtl::OUString("."), + '.', ',', &status, &end); + CPPUNIT_ASSERT_EQUAL(rtl_math_ConversionStatus_Ok, status); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), end); + CPPUNIT_ASSERT_EQUAL(0.0, res); + + res = rtl::math::stringToDouble( + rtl::OUString(" +.Efoo"), + '.', ',', &status, &end); + CPPUNIT_ASSERT_EQUAL(rtl_math_ConversionStatus_Ok, status); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), end); + CPPUNIT_ASSERT_EQUAL(0.0, res); + + res = rtl::math::stringToDouble( + rtl::OUString(" +,.Efoo"), + '.', ',', &status, &end); + CPPUNIT_ASSERT_EQUAL(rtl_math_ConversionStatus_Ok, status); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), end); + CPPUNIT_ASSERT_EQUAL(0.0, res); } void test_stringToDouble_exponent_without_digit() { |