summaryrefslogtreecommitdiff
path: root/sc/qa
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2020-11-16 16:07:30 +0100
committerStephan Bergmann <sbergman@redhat.com>2020-11-16 21:43:09 +0100
commit50d3ad9127aaf63afcfa299adcea060c9b09faa4 (patch)
treeaf3bf48ae8e31e180003c9f998831dd7777d1f5b /sc/qa
parentcd4a239063a77d49fe178255c20f0558e337a82f (diff)
Instead of labs, use overloaded abs
...more likely to pick an appropriate version for the involved integer types, esp. after the recent long -> tools::Long changes Change-Id: Ia91259ca35aaf74b0e907de6831fc926f30057f4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105949 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sc/qa')
-rw-r--r--sc/qa/unit/bugfix-test.cxx17
-rw-r--r--sc/qa/unit/helper/qahelper.cxx3
-rw-r--r--sc/qa/unit/scshapetest.cxx13
3 files changed, 22 insertions, 11 deletions
diff --git a/sc/qa/unit/bugfix-test.cxx b/sc/qa/unit/bugfix-test.cxx
index 2d815bb10c93..be2a00a94e76 100644
--- a/sc/qa/unit/bugfix-test.cxx
+++ b/sc/qa/unit/bugfix-test.cxx
@@ -7,6 +7,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#include <sal/config.h>
+
+#include <cstdlib>
+
#include <postit.hxx>
#include <validat.hxx>
#include <tabvwsh.hxx>
@@ -90,24 +94,25 @@ static void lcl_AssertRectEqualWithTolerance(const OString& sInfo,
// Left
OString sMsg = sInfo + " Left expected " + OString::number(rExpected.Left()) + " actual "
+ OString::number(rActual.Left()) + " Tolerance " + OString::number(nTolerance);
- CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(), labs(rExpected.Left() - rActual.Left()) <= nTolerance);
+ CPPUNIT_ASSERT_MESSAGE(
+ sMsg.getStr(), std::abs(rExpected.Left() - rActual.Left()) <= nTolerance);
// Top
sMsg = sInfo + " Top expected " + OString::number(rExpected.Top()) + " actual "
+ OString::number(rActual.Top()) + " Tolerance " + OString::number(nTolerance);
- CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(), labs(rExpected.Top() - rActual.Top()) <= nTolerance);
+ CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(), std::abs(rExpected.Top() - rActual.Top()) <= nTolerance);
// Width
sMsg = sInfo + " Width expected " + OString::number(rExpected.GetWidth()) + " actual "
+ OString::number(rActual.GetWidth()) + " Tolerance " + OString::number(nTolerance);
CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(),
- labs(rExpected.GetWidth() - rActual.GetWidth()) <= nTolerance);
+ std::abs(rExpected.GetWidth() - rActual.GetWidth()) <= nTolerance);
// Height
sMsg = sInfo + " Height expected " + OString::number(rExpected.GetHeight()) + " actual "
+ OString::number(rActual.GetHeight()) + " Tolerance " + OString::number(nTolerance);
CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(),
- labs(rExpected.GetHeight() - rActual.GetHeight()) <= nTolerance);
+ std::abs(rExpected.GetHeight() - rActual.GetHeight()) <= nTolerance);
}
static void lcl_AssertPointEqualWithTolerance(const OString& sInfo, const Point rExpected,
@@ -116,11 +121,11 @@ static void lcl_AssertPointEqualWithTolerance(const OString& sInfo, const Point
// X
OString sMsg = sInfo + " X expected " + OString::number(rExpected.X()) + " actual "
+ OString::number(rActual.X()) + " Tolerance " + OString::number(nTolerance);
- CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(), labs(rExpected.X() - rActual.X()) <= nTolerance);
+ CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(), std::abs(rExpected.X() - rActual.X()) <= nTolerance);
// Y
sMsg = sInfo + " Y expected " + OString::number(rExpected.Y()) + " actual "
+ OString::number(rActual.Y()) + " Tolerance " + OString::number(nTolerance);
- CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(), labs(rExpected.Y() - rActual.Y()) <= nTolerance);
+ CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(), std::abs(rExpected.Y() - rActual.Y()) <= nTolerance);
}
void ScFiltersTest::testTdf137576_Measureline()
diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx
index 2ba82ae91944..c481260378c7 100644
--- a/sc/qa/unit/helper/qahelper.cxx
+++ b/sc/qa/unit/helper/qahelper.cxx
@@ -39,6 +39,7 @@
#include <orcus/csv_parser.hpp>
+#include <cstdlib>
#include <fstream>
#include <com/sun/star/chart2/XChartDocument.hpp>
@@ -99,7 +100,7 @@ const FileFormat ScBootstrapFixture::aFileFormats[] = {
bool testEqualsWithTolerance( tools::Long nVal1, tools::Long nVal2, tools::Long nTol )
{
- return ( labs( nVal1 - nVal2 ) <= nTol );
+ return ( std::abs( nVal1 - nVal2 ) <= nTol );
}
void loadFile(const OUString& aFileName, std::string& aContent)
diff --git a/sc/qa/unit/scshapetest.cxx b/sc/qa/unit/scshapetest.cxx
index 6eac2bc2b859..c8753cb99aa9 100644
--- a/sc/qa/unit/scshapetest.cxx
+++ b/sc/qa/unit/scshapetest.cxx
@@ -7,6 +7,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#include <sal/config.h>
+
+#include <cstdlib>
+
#include <test/calc_unoapi_test.hxx>
#include <comphelper/dispatchcommand.hxx>
@@ -83,24 +87,25 @@ static void lcl_AssertRectEqualWithTolerance(const OString& sInfo,
// Left
OString sMsg = sInfo + " Left expected " + OString::number(rExpected.Left()) + " actual "
+ OString::number(rActual.Left()) + " Tolerance " + OString::number(nTolerance);
- CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(), labs(rExpected.Left() - rActual.Left()) <= nTolerance);
+ CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(),
+ std::abs(rExpected.Left() - rActual.Left()) <= nTolerance);
// Top
sMsg = sInfo + " Top expected " + OString::number(rExpected.Top()) + " actual "
+ OString::number(rActual.Top()) + " Tolerance " + OString::number(nTolerance);
- CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(), labs(rExpected.Top() - rActual.Top()) <= nTolerance);
+ CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(), std::abs(rExpected.Top() - rActual.Top()) <= nTolerance);
// Width
sMsg = sInfo + " Width expected " + OString::number(rExpected.GetWidth()) + " actual "
+ OString::number(rActual.GetWidth()) + " Tolerance " + OString::number(nTolerance);
CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(),
- labs(rExpected.GetWidth() - rActual.GetWidth()) <= nTolerance);
+ std::abs(rExpected.GetWidth() - rActual.GetWidth()) <= nTolerance);
// Height
sMsg = sInfo + " Height expected " + OString::number(rExpected.GetHeight()) + " actual "
+ OString::number(rActual.GetHeight()) + " Tolerance " + OString::number(nTolerance);
CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(),
- labs(rExpected.GetHeight() - rActual.GetHeight()) <= nTolerance);
+ std::abs(rExpected.GetHeight() - rActual.GetHeight()) <= nTolerance);
}
void ScShapeTest::testHideColsShow()