include/test/unoapi_test.hxx |   16 +++++++
 sc/qa/unit/bugfix-test.cxx   |   44 ++-------------------
 sc/qa/unit/scshapetest.cxx   |   89 +++++++++++--------------------------------
 svx/qa/unit/customshapes.cxx |   46 +++-------------------
 4 files changed, 54 insertions(+), 141 deletions(-)

New commits:
commit 15df8e5422010e0806eb9e93bd8822519c1ab989
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Wed Dec 14 18:46:19 2022 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Thu Dec 15 07:43:49 2022 +0000

    UnoApiTest: introduce CPPUNIT_ASSERT_RECTANGLE_EQUAL
    
    and get rid of duplicated code
    
    Change-Id: Iccbd3147fab71b43b1725af308df8ed37c807b7e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144173
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/include/test/unoapi_test.hxx b/include/test/unoapi_test.hxx
index f228f70e21ca..e008b11ca2f0 100644
--- a/include/test/unoapi_test.hxx
+++ b/include/test/unoapi_test.hxx
@@ -84,6 +84,22 @@ private:
     OUString maImportFilterName;
 };
 
+inline void assertRectangleEqual(const tools::Rectangle& rExpected, const 
tools::Rectangle& rActual,
+                                 const sal_Int32 nTolerance, const 
CppUnit::SourceLine& rSourceLine)
+{
+    CPPUNIT_NS::assertDoubleEquals(rExpected.Top(), rActual.Top(), nTolerance, 
rSourceLine,
+                                   "different Top");
+    CPPUNIT_NS::assertDoubleEquals(rExpected.Left(), rActual.Left(), 
nTolerance, rSourceLine,
+                                   "different Left");
+    CPPUNIT_NS::assertDoubleEquals(rExpected.GetWidth(), rActual.GetWidth(), 
nTolerance,
+                                   rSourceLine, "different Width");
+    CPPUNIT_NS::assertDoubleEquals(rExpected.GetHeight(), rActual.GetHeight(), 
nTolerance,
+                                   rSourceLine, "different Height");
+}
+
+#define CPPUNIT_ASSERT_RECTANGLE_EQUAL(aExpected, aActual, aTolerance)         
                    \
+    assertRectangleEqual(aExpected, aActual, aTolerance, CPPUNIT_SOURCELINE())
+
 #endif // INCLUDED_TEST_UNOAPI_TEST_HXX
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/qa/unit/bugfix-test.cxx b/sc/qa/unit/bugfix-test.cxx
index cc7673c72b8a..4c7137d39ab2 100644
--- a/sc/qa/unit/bugfix-test.cxx
+++ b/sc/qa/unit/bugfix-test.cxx
@@ -87,38 +87,6 @@ public:
     CPPUNIT_TEST_SUITE_END();
 };
 
-static void lcl_AssertRectEqualWithTolerance(std::string_view sInfo,
-                                             const tools::Rectangle& rExpected,
-                                             const tools::Rectangle& rActual,
-                                             const sal_Int32 nTolerance)
-{
-    // Left
-    OString sMsg = OString::Concat(sInfo) + " Left expected " + 
OString::number(rExpected.Left())
-                   + " actual " + OString::number(rActual.Left()) + " 
Tolerance "
-                   + OString::number(nTolerance);
-    CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(),
-                           std::abs(rExpected.Left() - rActual.Left()) <= 
nTolerance);
-
-    // Top
-    sMsg = OString::Concat(sInfo) + " Top expected " + 
OString::number(rExpected.Top()) + " actual "
-           + OString::number(rActual.Top()) + " Tolerance " + 
OString::number(nTolerance);
-    CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(), std::abs(rExpected.Top() - 
rActual.Top()) <= nTolerance);
-
-    // Width
-    sMsg = OString::Concat(sInfo) + " Width expected " + 
OString::number(rExpected.GetWidth())
-           + " actual " + OString::number(rActual.GetWidth()) + " Tolerance "
-           + OString::number(nTolerance);
-    CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(),
-                           std::abs(rExpected.GetWidth() - rActual.GetWidth()) 
<= nTolerance);
-
-    // Height
-    sMsg = OString::Concat(sInfo) + " Height expected " + 
OString::number(rExpected.GetHeight())
-           + " actual " + OString::number(rActual.GetHeight()) + " Tolerance "
-           + OString::number(nTolerance);
-    CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(),
-                           std::abs(rExpected.GetHeight() - 
rActual.GetHeight()) <= nTolerance);
-}
-
 void ScFiltersTest::testTdf137576_Measureline()
 {
     // The document contains a vertical measure line, anchored "To Cell 
(resize with cell)" with
@@ -205,8 +173,8 @@ void ScFiltersTest::testTdf137044_CoverHiddenRows()
     // Get original object values
     tools::Rectangle aSnapRectOrig = pObj->GetSnapRect();
     Point aOriginalEndOffset = ScDrawLayer::GetObjData(pObj)->maEndOffset;
-    lcl_AssertRectEqualWithTolerance("Load:", tools::Rectangle(Point(500, 
3500), Size(1501, 11001)),
-                                     aSnapRectOrig, 1);
+    CPPUNIT_ASSERT_RECTANGLE_EQUAL(tools::Rectangle(Point(500, 3500), 
Size(1501, 11001)),
+                                   aSnapRectOrig, 1);
     CPPUNIT_ASSERT_POINT_EQUAL(Point(2000, 2499), aOriginalEndOffset, 1);
 
     // Hide rows 5 and 6 in UI = row index 4 to 5.
@@ -227,8 +195,8 @@ void ScFiltersTest::testTdf137044_CoverHiddenRows()
     // Get new values and compare. End offset should be the same, height 
should be 6000 smaller.
     tools::Rectangle aSnapRectReload = pObj->GetSnapRect();
     Point aReloadEndOffset = ScDrawLayer::GetObjData(pObj)->maEndOffset;
-    lcl_AssertRectEqualWithTolerance(
-        "Reload:", tools::Rectangle(Point(500, 3500), Size(1501, 5001)), 
aSnapRectReload, 1);
+    CPPUNIT_ASSERT_RECTANGLE_EQUAL(tools::Rectangle(Point(500, 3500), 
Size(1501, 5001)),
+                                   aSnapRectReload, 1);
     CPPUNIT_ASSERT_POINT_EQUAL(Point(2000, 2499), aReloadEndOffset, 1);
 }
 
@@ -251,7 +219,7 @@ void ScFiltersTest::testTdf137020_FlipVertical()
     // Vertical mirror on center should not change the snap rect.
     pObj->Mirror(aSnapRectOrig.LeftCenter(), aSnapRectOrig.RightCenter());
     const tools::Rectangle aSnapRectFlip = pObj->GetSnapRect();
-    lcl_AssertRectEqualWithTolerance("Mirror:", aSnapRectOrig, aSnapRectFlip, 
1);
+    CPPUNIT_ASSERT_RECTANGLE_EQUAL(aSnapRectOrig, aSnapRectFlip, 1);
 
     // Save and reload
     saveAndReload("calc8");
@@ -267,7 +235,7 @@ void ScFiltersTest::testTdf137020_FlipVertical()
 
     // Check pos and size of shape again, should be unchanged
     const tools::Rectangle aSnapRectReload = pObj->GetSnapRect();
-    lcl_AssertRectEqualWithTolerance("Reload:", aSnapRectOrig, 
aSnapRectReload, 1);
+    CPPUNIT_ASSERT_RECTANGLE_EQUAL(aSnapRectOrig, aSnapRectReload, 1);
 }
 
 void ScFiltersTest::testTdf64229()
diff --git a/sc/qa/unit/scshapetest.cxx b/sc/qa/unit/scshapetest.cxx
index 1b2610bf645e..d7f80607ac96 100644
--- a/sc/qa/unit/scshapetest.cxx
+++ b/sc/qa/unit/scshapetest.cxx
@@ -104,38 +104,6 @@ ScShapeTest::ScShapeTest()
 {
 }
 
-static void lcl_AssertRectEqualWithTolerance(std::string_view sInfo,
-                                             const tools::Rectangle& rExpected,
-                                             const tools::Rectangle& rActual,
-                                             const sal_Int32 nTolerance)
-{
-    // Left
-    OString sMsg = OString::Concat(sInfo) + " Left expected " + 
OString::number(rExpected.Left())
-                   + " actual " + OString::number(rActual.Left()) + " 
Tolerance "
-                   + OString::number(nTolerance);
-    CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(),
-                           std::abs(rExpected.Left() - rActual.Left()) <= 
nTolerance);
-
-    // Top
-    sMsg = OString::Concat(sInfo) + " Top expected " + 
OString::number(rExpected.Top()) + " actual "
-           + OString::number(rActual.Top()) + " Tolerance " + 
OString::number(nTolerance);
-    CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(), std::abs(rExpected.Top() - 
rActual.Top()) <= nTolerance);
-
-    // Width
-    sMsg = OString::Concat(sInfo) + " Width expected " + 
OString::number(rExpected.GetWidth())
-           + " actual " + OString::number(rActual.GetWidth()) + " Tolerance "
-           + OString::number(nTolerance);
-    CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(),
-                           std::abs(rExpected.GetWidth() - rActual.GetWidth()) 
<= nTolerance);
-
-    // Height
-    sMsg = OString::Concat(sInfo) + " Height expected " + 
OString::number(rExpected.GetHeight())
-           + " actual " + OString::number(rActual.GetHeight()) + " Tolerance "
-           + OString::number(nTolerance);
-    CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(),
-                           std::abs(rExpected.GetHeight() - 
rActual.GetHeight()) <= nTolerance);
-}
-
 static SdrPage* lcl_getSdrPageWithAssert(ScDocument& rDoc)
 {
     ScDrawLayer* pDrawLayer = rDoc.GetDrawLayer();
@@ -187,7 +155,7 @@ void ScShapeTest::testTdf144242_OpenBezier_noSwapWH()
     pObj = lcl_getSdrObjectWithAssert(*pDoc, 0);
     tools::Rectangle aSnapRect(pObj->GetSnapRect());
     // Without fix in place width and height were swapped
-    lcl_AssertRectEqualWithTolerance("Reload: wrong pos and size", 
aExpectRect, aSnapRect, 40);
+    CPPUNIT_ASSERT_RECTANGLE_EQUAL(aExpectRect, aSnapRect, 40);
 }
 
 void ScShapeTest::testTdf144242_Line_noSwapWH()
@@ -220,7 +188,7 @@ void ScShapeTest::testTdf144242_Line_noSwapWH()
     pObj = lcl_getSdrObjectWithAssert(*pDoc, 0);
     tools::Rectangle aSnapRect(pObj->GetSnapRect());
     // Without fix in place width and height were swapped
-    lcl_AssertRectEqualWithTolerance("Reload: wrong pos and size", 
aExpectRect, aSnapRect, 40);
+    CPPUNIT_ASSERT_RECTANGLE_EQUAL(aExpectRect, aSnapRect, 40);
 }
 
 void ScShapeTest::testTdf143619_validation_circle_pos()
@@ -411,9 +379,9 @@ void ScShapeTest::testTdf137082_RTL_cell_anchored()
 
     // Test reading was correct
     SdrObject* pObj = lcl_getSdrObjectWithAssert(*pDoc, 0);
-    lcl_AssertRectEqualWithTolerance("load shape A: ", aSnapRectA, 
pObj->GetSnapRect(), 1);
+    CPPUNIT_ASSERT_RECTANGLE_EQUAL(aSnapRectA, pObj->GetSnapRect(), 1);
     pObj = lcl_getSdrObjectWithAssert(*pDoc, 1);
-    lcl_AssertRectEqualWithTolerance("load shape B: ", aSnapRectB, 
pObj->GetSnapRect(), 1);
+    CPPUNIT_ASSERT_RECTANGLE_EQUAL(aSnapRectB, pObj->GetSnapRect(), 1);
 
     // Save and reload.
     saveAndReload("calc8");
@@ -423,9 +391,9 @@ void ScShapeTest::testTdf137082_RTL_cell_anchored()
 
     // And test again
     pObj = lcl_getSdrObjectWithAssert(*pDoc, 0);
-    lcl_AssertRectEqualWithTolerance("reload shape A: ", aSnapRectA, 
pObj->GetSnapRect(), 1);
+    CPPUNIT_ASSERT_RECTANGLE_EQUAL(aSnapRectA, pObj->GetSnapRect(), 1);
     pObj = lcl_getSdrObjectWithAssert(*pDoc, 1);
-    lcl_AssertRectEqualWithTolerance("reload shape B: ", aSnapRectB, 
pObj->GetSnapRect(), 1);
+    CPPUNIT_ASSERT_RECTANGLE_EQUAL(aSnapRectB, pObj->GetSnapRect(), 1);
 }
 
 void ScShapeTest::testTdf137081_RTL_page_anchored()
@@ -517,8 +485,7 @@ void ScShapeTest::testTdf139583_Rotate180deg()
     pObj = static_cast<SdrRectObj*>(lcl_getSdrObjectWithAssert(*pDoc, 0));
 
     //  Without the fix in place, the shape would have nearly zero size.
-    lcl_AssertRectEqualWithTolerance("Show: Object geometry should not 
change", aRect,
-                                     pObj->GetSnapRect(), 1);
+    CPPUNIT_ASSERT_RECTANGLE_EQUAL(aRect, pObj->GetSnapRect(), 1);
 }
 
 void ScShapeTest::testTdf137033_FlipHori_Resize()
@@ -534,7 +501,7 @@ void ScShapeTest::testTdf137033_FlipHori_Resize()
     // Verify shape is correctly loaded. Then set shape to "resize with cell".
     tools::Rectangle aSnapRect(pObj->GetSnapRect());
     const tools::Rectangle aExpectRect(Point(4998, 7000), Size(9644, 6723));
-    lcl_AssertRectEqualWithTolerance("Load, wrong pos or size: ", aExpectRect, 
aSnapRect, 1);
+    CPPUNIT_ASSERT_RECTANGLE_EQUAL(aExpectRect, aSnapRect, 1);
     ScDrawLayer::SetCellAnchoredFromPosition(*pObj, *pDoc, 0 /*SCTAB*/, true 
/*bResizeWithCell*/);
 
     // Save and reload.
@@ -546,7 +513,7 @@ void ScShapeTest::testTdf137033_FlipHori_Resize()
 
     // Check shape has the original geometry, besides rounding and unit 
conversion errors
     aSnapRect = pObj->GetSnapRect();
-    lcl_AssertRectEqualWithTolerance("Reload, wrong pos or size: ", 
aExpectRect, aSnapRect, 1);
+    CPPUNIT_ASSERT_RECTANGLE_EQUAL(aExpectRect, aSnapRect, 1);
 }
 
 void ScShapeTest::testTdf137033_RotShear_ResizeHide()
@@ -581,7 +548,7 @@ void ScShapeTest::testTdf137033_RotShear_ResizeHide()
                            abs(aShearAngle - aExpectShearAngle) <= 1_deg100);
     CPPUNIT_ASSERT_MESSAGE("Hide rows, rotate angle: ",
                            abs(aRotateAngle - aExpectRotateAngle) <= 1_deg100);
-    lcl_AssertRectEqualWithTolerance("Load: wrong pos or size", aExpectRect, 
aSnapRect, 1);
+    CPPUNIT_ASSERT_RECTANGLE_EQUAL(aExpectRect, aSnapRect, 1);
 
     // Save and reload.
     saveAndReload("calc8");
@@ -598,7 +565,7 @@ void ScShapeTest::testTdf137033_RotShear_ResizeHide()
                            abs(aShearAngle - aExpectShearAngle) <= 3_deg100);
     CPPUNIT_ASSERT_MESSAGE("Reload, rotate angle: ",
                            abs(aRotateAngle - aExpectRotateAngle) <= 3_deg100);
-    lcl_AssertRectEqualWithTolerance("Reload: wrong pos or size", aExpectRect, 
aSnapRect, 7);
+    CPPUNIT_ASSERT_RECTANGLE_EQUAL(aExpectRect, aSnapRect, 7);
 }
 
 void ScShapeTest::testTdf137033_RotShear_Hide()
@@ -631,7 +598,7 @@ void ScShapeTest::testTdf137033_RotShear_Hide()
     // Values are manually taken from shape before hiding column C.
     const tools::Rectangle aExpectRect(Point(4500, 3500), Size(15143, 5187));
     const tools::Rectangle aSnapRect = pObj->GetSnapRect();
-    lcl_AssertRectEqualWithTolerance("Reload: wrong pos and size", 
aExpectRect, aSnapRect, 1);
+    CPPUNIT_ASSERT_RECTANGLE_EQUAL(aExpectRect, aSnapRect, 1);
 }
 
 void ScShapeTest::testTdf137576_LogicRectInDefaultMeasureline()
@@ -789,8 +756,7 @@ void ScShapeTest::testHideColsShow()
     // Check object is visible and has old size
     CPPUNIT_ASSERT_MESSAGE("Show: Object should be visible", 
pObj->IsVisible());
     tools::Rectangle aSnapRectShow(pObj->GetSnapRect());
-    lcl_AssertRectEqualWithTolerance("Show: Object geometry should not 
change", aSnapRectOrig,
-                                     aSnapRectShow, 1);
+    CPPUNIT_ASSERT_RECTANGLE_EQUAL(aSnapRectOrig, aSnapRectShow, 1);
 }
 
 void ScShapeTest::testTdf138138_MoveCellWithRotatedShape()
@@ -806,7 +772,7 @@ void ScShapeTest::testTdf138138_MoveCellWithRotatedShape()
     // Check anchor and position of shape. The expected values are taken from 
UI.
     tools::Rectangle aSnapRect = pObj->GetSnapRect();
     tools::Rectangle aExpectedRect(Point(10000, 3000), Size(1000, 7500));
-    lcl_AssertRectEqualWithTolerance("Load original: ", aExpectedRect, 
aSnapRect, 1);
+    CPPUNIT_ASSERT_RECTANGLE_EQUAL(aExpectedRect, aSnapRect, 1);
 
     // Insert two columns after column B
     uno::Sequence<beans::PropertyValue> aPropertyValues = {
@@ -818,8 +784,7 @@ void ScShapeTest::testTdf138138_MoveCellWithRotatedShape()
     pViewShell->GetViewData().GetDispatcher().Execute(FID_INS_COLUMNS_AFTER);
     aExpectedRect = tools::Rectangle(Point(16000, 3000), Size(1000, 7500)); // 
col width 3000
     aSnapRect = pObj->GetSnapRect();
-    lcl_AssertRectEqualWithTolerance("Shift: Wrong after insert of columns ", 
aExpectedRect,
-                                     aSnapRect, 1);
+    CPPUNIT_ASSERT_RECTANGLE_EQUAL(aExpectedRect, aSnapRect, 1);
 
     // Save and reload
     saveAndReload("calc8");
@@ -830,8 +795,7 @@ void ScShapeTest::testTdf138138_MoveCellWithRotatedShape()
 
     // Assert objects size is unchanged, position is shifted.
     aSnapRect = pObj->GetSnapRect();
-    lcl_AssertRectEqualWithTolerance("Reload: Shape geometry has changed.", 
aExpectedRect,
-                                     aSnapRect, 1);
+    CPPUNIT_ASSERT_RECTANGLE_EQUAL(aExpectedRect, aSnapRect, 1);
 }
 
 void ScShapeTest::testLoadVerticalFlip()
@@ -869,11 +833,10 @@ void ScShapeTest::testTdf117948_CollapseBeforeShape()
     // Check anchor and position of shape. The expected values are taken from 
UI before saving.
     tools::Rectangle aSnapRect0Collapse = pObj0->GetSnapRect();
     tools::Rectangle aExpectedRect0(Point(4672, 1334), Size(1787, 1723));
-    lcl_AssertRectEqualWithTolerance("Collapse: Custom shape", aExpectedRect0, 
aSnapRect0Collapse,
-                                     1);
+    CPPUNIT_ASSERT_RECTANGLE_EQUAL(aExpectedRect0, aSnapRect0Collapse, 1);
     tools::Rectangle aSnapRect1Collapse = pObj1->GetSnapRect();
     tools::Rectangle aExpectedRect1(Point(5647, 4172), Size(21, 3441));
-    lcl_AssertRectEqualWithTolerance("Collapse: Line", aExpectedRect1, 
aSnapRect1Collapse, 1);
+    CPPUNIT_ASSERT_RECTANGLE_EQUAL(aExpectedRect1, aSnapRect1Collapse, 1);
 
     // Save and reload
     saveAndReload("calc8");
@@ -886,12 +849,10 @@ void ScShapeTest::testTdf117948_CollapseBeforeShape()
     // Assert objects size and position are not changed. Actual values differ 
a little bit
     // because of cumulated Twips-Hmm conversion errors.
     tools::Rectangle aSnapRect0Reload = pObj0->GetSnapRect();
-    lcl_AssertRectEqualWithTolerance("Reload: Custom shape geometry has 
changed.", aExpectedRect0,
-                                     aSnapRect0Reload, 2);
+    CPPUNIT_ASSERT_RECTANGLE_EQUAL(aExpectedRect0, aSnapRect0Reload, 2);
 
     tools::Rectangle aSnapRect1Reload = pObj1->GetSnapRect();
-    lcl_AssertRectEqualWithTolerance("Reload: Line geometry has changed.", 
aExpectedRect1,
-                                     aSnapRect1Reload, 2);
+    CPPUNIT_ASSERT_RECTANGLE_EQUAL(aExpectedRect1, aSnapRect1Reload, 2);
 }
 
 void ScShapeTest::testTdf137355_UndoHideRows()
@@ -927,8 +888,7 @@ void ScShapeTest::testTdf137355_UndoHideRows()
     CPPUNIT_ASSERT_MESSAGE("Undo: Object should exist", pObj);
     CPPUNIT_ASSERT_MESSAGE("Undo: Object should be visible", 
pObj->IsVisible());
     tools::Rectangle aSnapRectUndo(pObj->GetSnapRect());
-    lcl_AssertRectEqualWithTolerance("Undo: Object geometry should not 
change", aSnapRectOrig,
-                                     aSnapRectUndo, 1);
+    CPPUNIT_ASSERT_RECTANGLE_EQUAL(aSnapRectOrig, aSnapRectUndo, 1);
 }
 
 void ScShapeTest::testTdf152081_UndoHideColsWithNotes()
@@ -1002,8 +962,7 @@ void ScShapeTest::testTdf115655_HideDetail()
 
     // Assert image size is not changed
     tools::Rectangle aSnapRectReload = pObj->GetSnapRect();
-    lcl_AssertRectEqualWithTolerance("Reload: Object geometry has changed.", 
aSnapRectOrig,
-                                     aSnapRectReload, 1);
+    CPPUNIT_ASSERT_RECTANGLE_EQUAL(aSnapRectOrig, aSnapRectReload, 1);
 }
 
 void ScShapeTest::testFitToCellSize()
@@ -1032,7 +991,7 @@ void ScShapeTest::testFitToCellSize()
 
     const tools::Rectangle& rShapeRect(pObj->GetSnapRect());
     const tools::Rectangle aCellRect = pDoc->GetMMRect(1, 1, 1, 1, 0);
-    lcl_AssertRectEqualWithTolerance("Cell and SnapRect should be equal", 
aCellRect, rShapeRect, 2);
+    CPPUNIT_ASSERT_RECTANGLE_EQUAL(aCellRect, rShapeRect, 2);
 }
 
 void ScShapeTest::testCustomShapeCellAnchoredRotatedShape()
@@ -1051,7 +1010,7 @@ void 
ScShapeTest::testCustomShapeCellAnchoredRotatedShape()
     pDoc->SetDrawPageSize(0); // trigger recalcpos
     tools::Rectangle aRect(2400, 751, 5772, 3694); // expected snap rect from 
values in file
     const tools::Rectangle& rShapeRect(pObj->GetSnapRect());
-    lcl_AssertRectEqualWithTolerance("Load: wrong pos and size", aRect, 
rShapeRect, 1);
+    CPPUNIT_ASSERT_RECTANGLE_EQUAL(aRect, rShapeRect, 1);
 
     // Check anchor
     ScDrawObjData* pData = ScDrawLayer::GetObjData(pObj);
diff --git a/svx/qa/unit/customshapes.cxx b/svx/qa/unit/customshapes.cxx
index efe322d54e76..5840d636eb61 100644
--- a/svx/qa/unit/customshapes.cxx
+++ b/svx/qa/unit/customshapes.cxx
@@ -89,36 +89,6 @@ sal_uInt8 CustomshapesTest::countShapes()
     return xDrawPage->getCount();
 }
 
-void lcl_AssertRectEqualWithTolerance(std::string_view sInfo, const 
tools::Rectangle& rExpected,
-                                      const tools::Rectangle& rActual, const 
sal_Int32 nTolerance)
-{
-    // Left
-    OString sMsg = OString::Concat(sInfo) + " Left expected " + 
OString::number(rExpected.Left())
-                   + " actual " + OString::number(rActual.Left()) + " 
Tolerance "
-                   + OString::number(nTolerance);
-    CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(),
-                           std::abs(rExpected.Left() - rActual.Left()) <= 
nTolerance);
-
-    // Top
-    sMsg = OString::Concat(sInfo) + " Top expected " + 
OString::number(rExpected.Top()) + " actual "
-           + OString::number(rActual.Top()) + " Tolerance " + 
OString::number(nTolerance);
-    CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(), std::abs(rExpected.Top() - 
rActual.Top()) <= nTolerance);
-
-    // Width
-    sMsg = OString::Concat(sInfo) + " Width expected " + 
OString::number(rExpected.GetWidth())
-           + " actual " + OString::number(rActual.GetWidth()) + " Tolerance "
-           + OString::number(nTolerance);
-    CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(),
-                           std::abs(rExpected.GetWidth() - rActual.GetWidth()) 
<= nTolerance);
-
-    // Height
-    sMsg = OString::Concat(sInfo) + " Height expected " + 
OString::number(rExpected.GetHeight())
-           + " actual " + OString::number(rActual.GetHeight()) + " Tolerance "
-           + OString::number(nTolerance);
-    CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(),
-                           std::abs(rExpected.GetHeight() - 
rActual.GetHeight()) <= nTolerance);
-}
-
 CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf147409_GeomItemHash)
 {
     loadFromURL(u"tdf147409_GeomItemHash.odg");
@@ -357,7 +327,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, 
testTdf145245_ExtrusionPosition)
             
static_cast<SdrObjCustomShape&>(*SdrObject::getSdrObjectFromXShape(xShape0)));
         tools::Rectangle aBoundRect(rSdrCustomShape.GetCurrentBoundRect());
         tools::Rectangle aExpected(Point(1000, 1000), Size(6002, 5001));
-        lcl_AssertRectEqualWithTolerance("Pos 0.0 extrusion", aExpected, 
aBoundRect, 40);
+        CPPUNIT_ASSERT_RECTANGLE_EQUAL(aExpected, aBoundRect, 40);
     }
     {
         // Second shape has half of extrusion behind the shape.
@@ -367,7 +337,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, 
testTdf145245_ExtrusionPosition)
         // Without the fix the height was 1 instead of 5001.
         tools::Rectangle aBoundRect(rSdrCustomShape.GetCurrentBoundRect());
         tools::Rectangle aExpected(Point(9000, 3500), Size(6002, 5001));
-        lcl_AssertRectEqualWithTolerance("Pos 0.5 extrusion", aExpected, 
aBoundRect, 40);
+        CPPUNIT_ASSERT_RECTANGLE_EQUAL(aExpected, aBoundRect, 40);
     }
     {
         // Third shape has extrusion before the shape.
@@ -377,7 +347,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, 
testTdf145245_ExtrusionPosition)
         // Without the fix the y-coordinate was 1000 instead of 6000.
         tools::Rectangle aBoundRect(rSdrCustomShape.GetCurrentBoundRect());
         tools::Rectangle aExpected(Point(18000, 6000), Size(6002, 5001));
-        lcl_AssertRectEqualWithTolerance("Pos 1.0 extrusion", aExpected, 
aBoundRect, 40);
+        CPPUNIT_ASSERT_RECTANGLE_EQUAL(aExpected, aBoundRect, 40);
     }
 }
 
@@ -401,7 +371,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, 
testTdf145111_Fontwork_rendering_font_siz
     // The expected values 1501|1777, 3941 x 1446 are only valid for 96dpi.
     tools::Rectangle aBoundRect(rSdrCustomShape.GetCurrentBoundRect());
     tools::Rectangle aExpected(Point(1501, 1777), Size(3941, 1446));
-    lcl_AssertRectEqualWithTolerance("Wrong text rendering", aExpected, 
aBoundRect, 5);
+    CPPUNIT_ASSERT_RECTANGLE_EQUAL(aExpected, aBoundRect, 5);
 }
 
 CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf145111_anchor_in_Fontwork)
@@ -508,7 +478,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, 
testResizeRotatedShape)
         rSdrShape.NbcResize(rSdrShape.GetRelativePos(), Fraction(1.0), 
Fraction(-0.5));
         tools::Rectangle aSnapRect(rSdrShape.GetSnapRect());
         tools::Rectangle aBoundRect(rSdrShape.GetCurrentBoundRect());
-        lcl_AssertRectEqualWithTolerance("height changed, mirror vert", 
aSnapRect, aBoundRect, 3);
+        CPPUNIT_ASSERT_RECTANGLE_EQUAL(aSnapRect, aBoundRect, 3);
     }
 
     // Change height
@@ -518,7 +488,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, 
testResizeRotatedShape)
         rSdrShape.NbcResize(rSdrShape.GetRelativePos(), Fraction(1.0), 
Fraction(2.0));
         tools::Rectangle aSnapRect(rSdrShape.GetSnapRect());
         tools::Rectangle aBoundRect(rSdrShape.GetCurrentBoundRect());
-        lcl_AssertRectEqualWithTolerance("height changed", aSnapRect, 
aBoundRect, 3);
+        CPPUNIT_ASSERT_RECTANGLE_EQUAL(aSnapRect, aBoundRect, 3);
     }
 
     // Change width
@@ -528,7 +498,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, 
testResizeRotatedShape)
         rSdrShape.NbcResize(rSdrShape.GetRelativePos(), Fraction(2.0), 
Fraction(1.0));
         tools::Rectangle aSnapRect(rSdrShape.GetSnapRect());
         tools::Rectangle aBoundRect(rSdrShape.GetCurrentBoundRect());
-        lcl_AssertRectEqualWithTolerance("width changed", aSnapRect, 
aBoundRect, 3);
+        CPPUNIT_ASSERT_RECTANGLE_EQUAL(aSnapRect, aBoundRect, 3);
     }
 
     // Change width and mirror horizontal
@@ -538,7 +508,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, 
testResizeRotatedShape)
         rSdrShape.NbcResize(rSdrShape.GetRelativePos(), Fraction(-0.5), 
Fraction(1.0));
         tools::Rectangle aSnapRect(rSdrShape.GetSnapRect());
         tools::Rectangle aBoundRect(rSdrShape.GetCurrentBoundRect());
-        lcl_AssertRectEqualWithTolerance("width changed, mirror hori", 
aSnapRect, aBoundRect, 3);
+        CPPUNIT_ASSERT_RECTANGLE_EQUAL(aSnapRect, aBoundRect, 3);
     }
 }
 

Reply via email to