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

New commits:
commit 11bfced0a4f1d5f3ccaf8e1c87c11733ca71f29d
Author:     Eike Rathke <er...@redhat.com>
AuthorDate: Wed May 15 00:14:40 2024 +0200
Commit:     Eike Rathke <er...@redhat.com>
CommitDate: Wed May 15 18:02:32 2024 +0200

    Unit test for tdf#160985
    
    Change-Id: I721d127b145b6524a946c42eb23f8004c700db11
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167648
    Tested-by: Jenkins
    Reviewed-by: Eike Rathke <er...@redhat.com>

diff --git a/sal/qa/rtl/math/test-rtl-math.cxx 
b/sal/qa/rtl/math/test-rtl-math.cxx
index ce73edb4799e..7e28356f625a 100644
--- a/sal/qa/rtl/math/test-rtl-math.cxx
+++ b/sal/qa/rtl/math/test-rtl-math.cxx
@@ -407,6 +407,20 @@ public:
         aRes = rtl::math::doubleToUString( fVal, rtl_math_StringFormat_G, -3, 
'.', true);
         CPPUNIT_ASSERT_EQUAL( u"1.2E+004"_ustr, aRes);
 
+        fVal = 2000000528764739.0;
+        aRes = rtl::math::doubleToUString( fVal, rtl_math_StringFormat_G, 15, 
'.', true);
+        CPPUNIT_ASSERT_EQUAL( u"2.00000052876474E+015"_ustr, aRes);
+
+        // The original problem of tdf#160985 was nDecPlaces = 16 with
+        // RTL_STR_MAX_VALUEOFDOUBLE - std::size("-x.E-xxx")
+        fVal = 2000000528764739.0;
+        aRes = rtl::math::doubleToUString( fVal, rtl_math_StringFormat_G, 16, 
'.', true);
+        CPPUNIT_ASSERT_EQUAL( u"2000000528764739"_ustr, aRes);
+
+        fVal = 2000000528764739.0;
+        aRes = rtl::math::doubleToUString( fVal, rtl_math_StringFormat_G, 18, 
'.', false);
+        CPPUNIT_ASSERT_EQUAL( u"2000000528764739.00"_ustr, aRes);
+
         // DBL_MAX and 4 nextafters
         fVal = DBL_MAX;
         aRes = rtl::math::doubleToUString( fVal, 
rtl_math_StringFormat_Automatic,

Reply via email to