[Libreoffice-commits] core.git: sal/qa

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sat Dec 1 01:04:38 UTC 2018


 sal/qa/rtl/math/test-rtl-math.cxx |   56 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)

New commits:
commit d43e48cabce7fa8235207288e66a06fce1c58975
Author:     Eike Rathke <erack at redhat.com>
AuthorDate: Fri Nov 30 21:37:58 2018 +0100
Commit:     Eike Rathke <erack at redhat.com>
CommitDate: Sat Dec 1 02:04:11 2018 +0100

    Unit test for leading and trailing group separator characters
    
    Change-Id: I10ff8b59ba707d5795338ff5e9037473d31337bc
    Reviewed-on: https://gerrit.libreoffice.org/64361
    Tested-by: Jenkins
    Reviewed-by: Eike Rathke <erack at redhat.com>

diff --git a/sal/qa/rtl/math/test-rtl-math.cxx b/sal/qa/rtl/math/test-rtl-math.cxx
index 214ddb035177..5038b45a13c8 100644
--- a/sal/qa/rtl/math/test-rtl-math.cxx
+++ b/sal/qa/rtl/math/test-rtl-math.cxx
@@ -101,6 +101,54 @@ public:
         CPPUNIT_ASSERT_EQUAL(rtl_math_ConversionStatus_Ok, status);
         CPPUNIT_ASSERT_EQUAL(sal_Int32(2), end);
         CPPUNIT_ASSERT_EQUAL(5.0, res);
+
+        // Leading 0 and group separator.
+        res = rtl::math::stringToDouble(
+                OUString("0,123"),
+                '.', ',', &status, &end);
+        CPPUNIT_ASSERT_EQUAL(rtl_math_ConversionStatus_Ok, status);
+        CPPUNIT_ASSERT_EQUAL(sal_Int32(5), end);
+        CPPUNIT_ASSERT_EQUAL(123.0, res);
+
+        // Leading 0 and two consecutive group separators are none.
+        res = rtl::math::stringToDouble(
+                OUString("0,,1"),
+                '.', ',', &status, &end);
+        CPPUNIT_ASSERT_EQUAL(rtl_math_ConversionStatus_Ok, status);
+        CPPUNIT_ASSERT_EQUAL(sal_Int32(1), end);
+        CPPUNIT_ASSERT_EQUAL(0.0, res);
+
+        // Leading 0 and group separator at end is none.
+        res = rtl::math::stringToDouble(
+                OUString("0,"),
+                '.', ',', &status, &end);
+        CPPUNIT_ASSERT_EQUAL(rtl_math_ConversionStatus_Ok, status);
+        CPPUNIT_ASSERT_EQUAL(sal_Int32(1), end);
+        CPPUNIT_ASSERT_EQUAL(0.0, res);
+
+        // Leading 0 and group separator before non-digit is none.
+        res = rtl::math::stringToDouble(
+                OUString("0,x"),
+                '.', ',', &status, &end);
+        CPPUNIT_ASSERT_EQUAL(rtl_math_ConversionStatus_Ok, status);
+        CPPUNIT_ASSERT_EQUAL(sal_Int32(1), end);
+        CPPUNIT_ASSERT_EQUAL(0.0, res);
+
+        // Trailing group separator is none.
+        res = rtl::math::stringToDouble(
+                OUString("1,234,"),
+                '.', ',', &status, &end);
+        CPPUNIT_ASSERT_EQUAL(rtl_math_ConversionStatus_Ok, status);
+        CPPUNIT_ASSERT_EQUAL(sal_Int32(5), end);
+        CPPUNIT_ASSERT_EQUAL(1234.0, res);
+
+        // Group separator followed by non-digit is none.
+        res = rtl::math::stringToDouble(
+                OUString("1,234,x"),
+                '.', ',', &status, &end);
+        CPPUNIT_ASSERT_EQUAL(rtl_math_ConversionStatus_Ok, status);
+        CPPUNIT_ASSERT_EQUAL(sal_Int32(5), end);
+        CPPUNIT_ASSERT_EQUAL(1234.0, res);
     }
 
     void test_stringToDouble_bad() {
@@ -133,6 +181,14 @@ public:
         CPPUNIT_ASSERT_EQUAL(rtl_math_ConversionStatus_Ok, status);
         CPPUNIT_ASSERT_EQUAL(sal_Int32(0), end);
         CPPUNIT_ASSERT_EQUAL(0.0, res);
+
+        // Leading group separator is none.
+        res = rtl::math::stringToDouble(
+                OUString(",1234"),
+                '.', ',', &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() {


More information about the Libreoffice-commits mailing list