summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2021-10-02 00:09:43 +0200
committerMike Kaganski <mike.kaganski@collabora.com>2021-10-02 01:44:38 +0200
commit7b31f7428a1469fa823538fe5cf9cf36bbe2df68 (patch)
tree72ea34fac1f2c3e150f8a272d0ed1e080b1ed446 /sal
parentd830179a072072f3cc3ea5d942189647bcb7e1c7 (diff)
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@collabora.com>
Diffstat (limited to 'sal')
-rw-r--r--sal/qa/rtl/math/test-rtl-math.cxx12
1 files changed, 12 insertions, 0 deletions
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() {