sc/qa/unit/functions_test.cxx |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

New commits:
commit 81b864b6100d017c3742b82b4e458b07e06519b6
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Tue Oct 8 02:10:04 2024 +0500
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Tue Oct 8 06:32:28 2024 +0200

    Use snprintf to output full double precision of expected/actual values
    
    OUString::number rounds to 15 significant digits, unfortunately; so
    where in a fix for tdf#163344 it was needed to output something like
    
      result: 0.60416666666666663, expected: 0.60416666666666674
    
    it used to print
    
      result: 0.604166666666667, expected: 0.604166666666667
    
    Change-Id: I099d91ce4ac05358a119c63a5b1e481107aa7343
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174651
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/sc/qa/unit/functions_test.cxx b/sc/qa/unit/functions_test.cxx
index 862711e16cb7..489607d4458d 100644
--- a/sc/qa/unit/functions_test.cxx
+++ b/sc/qa/unit/functions_test.cxx
@@ -49,11 +49,18 @@ bool FunctionsTest::load(const OUString& rFilter, const 
OUString& rURL,
                 {
                     if (rDoc.HasValueData(1, row, tab))
                     {
+                        // snprintf provides requested precision, unlike 
OUString::number, which
+                        // rounds to 15 decimals
+                        char buf[25];
+                        int len = snprintf(buf, 25, "%.17G", rDoc.GetValue(0, 
row, tab));
+                        OUString 
result(OUString::createFromAscii(std::string_view(buf, len)));
+                        len = snprintf(buf, 25, "%.17G", rDoc.GetValue(1, row, 
tab));
+                        OUString 
expected(OUString::createFromAscii(std::string_view(buf, len)));
                         CPPUNIT_FAIL( OUString( "Testing " + rURL + " failed, "
                                     + rDoc.GetAllTableNames()[tab] + ".A" + 
OUString::number(row+1)
                                     + " \'" + rDoc.GetString(3, row, tab) + 
"\'"
-                                    " result: " + 
OUString::number(rDoc.GetValue(0, row, tab))
-                                    + ", expected: " + 
OUString::number(rDoc.GetValue(1, row, tab)))
+                                    " result: " + result
+                                    + ", expected: " + expected)
                                 .toUtf8().getStr());
                     }
                     else

Reply via email to