summaryrefslogtreecommitdiff
path: root/sal/qa
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2024-05-15 00:14:40 +0200
committerEike Rathke <erack@redhat.com>2024-05-15 18:02:32 +0200
commit11bfced0a4f1d5f3ccaf8e1c87c11733ca71f29d (patch)
treefe62d9096bce566942319739a4e4633c2f3c3038 /sal/qa
parent1ea85e8f2d815e6c0834215714ed3dad1101b971 (diff)
Unit test for tdf#160985
Change-Id: I721d127b145b6524a946c42eb23f8004c700db11 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167648 Tested-by: Jenkins Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sal/qa')
-rw-r--r--sal/qa/rtl/math/test-rtl-math.cxx14
1 files changed, 14 insertions, 0 deletions
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,