diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2024-10-08 02:10:04 +0500 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2024-10-08 06:32:28 +0200 |
commit | 81b864b6100d017c3742b82b4e458b07e06519b6 (patch) | |
tree | 271bfd01b145df5bb1cda5048dea271f282e914b /sc/qa | |
parent | 0a004f1a1528b8a85245de4672852b574bdc2cb2 (diff) |
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.kaganski@collabora.com>
Diffstat (limited to 'sc/qa')
-rw-r--r-- | sc/qa/unit/functions_test.cxx | 11 |
1 files changed, 9 insertions, 2 deletions
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 |