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

Mike Kaganski (via logerrit) logerrit at kemper.freedesktop.org
Fri Oct 1 23:45:12 UTC 2021


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

New commits:
commit 7b31f7428a1469fa823538fe5cf9cf36bbe2df68
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Sat Oct 2 00:09:43 2021 +0200
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Sat Oct 2 01:44:38 2021 +0200

    Some corner case unit tests
    
    Change-Id: I43474265a9b3e1d07394c5f7e429e081d67f2eda
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122935
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/sal/qa/rtl/math/test-rtl-math.cxx b/sal/qa/rtl/math/test-rtl-math.cxx
index 3067e11ac167..aaadccc8e97c 100644
--- a/sal/qa/rtl/math/test-rtl-math.cxx
+++ b/sal/qa/rtl/math/test-rtl-math.cxx
@@ -469,6 +469,18 @@ public:
         fVal = 123456.789;
         aRes = rtl::math::doubleToUString(fVal, rtl_math_StringFormat_E, 2, '.', false);
         CPPUNIT_ASSERT_EQUAL(OUString("1.23E+005"), aRes);
+
+        // Testing "after-treatment of up-rounding to the next decade" branch
+        // See void doubleToString in sal/rtl/math.cxx
+        // 1. Yet empty buffer
+        fVal = 9.9999999999999929;
+        aRes = rtl::math::doubleToUString(fVal, rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, '.', true);
+        CPPUNIT_ASSERT_EQUAL(OUString("10"), aRes);
+
+        // 2. Buffer with some content
+        fVal = 0.99999999999999933;
+        aRes = rtl::math::doubleToUString(fVal, rtl_math_StringFormat_F, rtl_math_DecimalPlaces_Max, '.', true);
+        CPPUNIT_ASSERT_EQUAL(OUString("1"), aRes);
     }
 
     void test_approx() {


More information about the Libreoffice-commits mailing list