sal/qa/rtl/math/test-rtl-math.cxx |   33 +++++++++++++++++++++++++++++++++
 svl/source/numbers/zformat.cxx    |   25 -------------------------
 2 files changed, 33 insertions(+), 25 deletions(-)

New commits:
commit b65de20c31f470dfe8bf6dc32ecd68a36072bf50
Author: Eike Rathke <er...@redhat.com>
Date:   Wed May 17 19:15:32 2017 +0200

    Remove old cruft #if 0 debugger test cases
    
    Change-Id: I95ae76820a434ac1d295bea21f9bf77dab9a7e6e

diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index da7b8c00a909..734af6294825 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -1947,31 +1947,6 @@ void SvNumberformat::ImpGetOutputStdToPrecision(double& 
rNumber, OUString& rOutS
     // Make sure the precision doesn't go over the maximum allowable precision.
     nPrecision = ::std::min(UPPER_PRECISION, nPrecision);
 
-#if 0
-{
-    // debugger test case for ANSI standard correctness
-    OUString aTest;
-    // expect 0.00123   OK
-    aTest = ::rtl::math::doubleToUString( 0.001234567,
-                                          rtl_math_StringFormat_G, 3, '.', 
true );
-    // expect 123       OK
-    aTest = ::rtl::math::doubleToUString( 123.4567,
-                                          rtl_math_StringFormat_G, 3, '.', 
true );
-    // expect 123.5     OK
-    aTest = ::rtl::math::doubleToUString( 123.4567,
-                                          rtl_math_StringFormat_G, 4, '.', 
true );
-    // expect 1e+03 (as 999.6 rounded to 3 significant digits results in
-    // 1000 with an exponent equal to significant digits)
-    // Currently (24-Jan-2003) we do fail in this case and output 1000
-    // instead, negligible.
-    aTest = ::rtl::math::doubleToUString( 999.6,
-                                          rtl_math_StringFormat_G, 3, '.', 
true );
-    // expect what? result is 1.2e+004
-    aTest = ::rtl::math::doubleToUString( 12345.6789,
-                                          rtl_math_StringFormat_G, -3, '.', 
true );
-}
-#endif
-
     // We decided to strip trailing zeros unconditionally, since binary
     // double-precision rounding error makes it impossible to determine e.g.
     // whether 844.10000000000002273737 is what the user has typed, or the
commit 07797559153a330ca66ade146b47f2a2b0657c64
Author: Eike Rathke <er...@redhat.com>
Date:   Wed May 17 19:08:20 2017 +0200

    Add some unit tests for rtl_math_StringFormat_G
    
    Change-Id: I010c35905789d2c5f60f7f1c4d9ad4caf60146ee

diff --git a/sal/qa/rtl/math/test-rtl-math.cxx 
b/sal/qa/rtl/math/test-rtl-math.cxx
index f9f041a17f95..fa118b9f3467 100644
--- a/sal/qa/rtl/math/test-rtl-math.cxx
+++ b/sal/qa/rtl/math/test-rtl-math.cxx
@@ -203,6 +203,39 @@ public:
                     rtl_math_StringFormat_Automatic,
                     rtl_math_DecimalPlaces_Max, '.', true);
         CPPUNIT_ASSERT_EQUAL( OUString("9.00719925474099E+015"), aRes);
+
+        // Test rtl_math_StringFormat_G
+
+        fVal = 0.001234567;
+        aRes = rtl::math::doubleToUString( fVal, rtl_math_StringFormat_G, 3, 
'.', true);
+        CPPUNIT_ASSERT_EQUAL( OUString("0.00123"), aRes);
+
+        fVal = 123.4567;
+        aRes = rtl::math::doubleToUString( fVal, rtl_math_StringFormat_G, 3, 
'.', true);
+        CPPUNIT_ASSERT_EQUAL( OUString("123"), aRes);
+
+        fVal = 123.4567;
+        aRes = rtl::math::doubleToUString( fVal, rtl_math_StringFormat_G, 4, 
'.', true);
+        CPPUNIT_ASSERT_EQUAL( OUString("123.5"), aRes);
+
+        fVal = 99.6;
+        aRes = rtl::math::doubleToUString( fVal, rtl_math_StringFormat_G, 3, 
'.', true);
+        CPPUNIT_ASSERT_EQUAL( OUString("99.6"), aRes);
+
+        // Expected could be 1E+03 (as 999.6 rounded to 3 significant digits
+        // results in 1000 with an exponent equal to significant digits).
+        // Currently we don't and output 1000 instead, negligible.
+        fVal = 999.6;
+        aRes = rtl::math::doubleToUString( fVal, rtl_math_StringFormat_G, 3, 
'.', true);
+        CPPUNIT_ASSERT_EQUAL( OUString("1000"), aRes);
+
+        fVal = 9999.6;
+        aRes = rtl::math::doubleToUString( fVal, rtl_math_StringFormat_G, 3, 
'.', true);
+        CPPUNIT_ASSERT_EQUAL( OUString("1E+004"), aRes);
+
+        fVal = 12345.6789;
+        aRes = rtl::math::doubleToUString( fVal, rtl_math_StringFormat_G, -3, 
'.', true);
+        CPPUNIT_ASSERT_EQUAL( OUString("1.2E+004"), aRes);
     }
 
     void test_approx() {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to