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>
This commit is contained in:
Eike Rathke 2024-05-15 00:14:40 +02:00
parent 1ea85e8f2d
commit 11bfced0a4

View file

@ -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,