sc/qa/unit/uicalc/uicalc.cxx |   18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

New commits:
commit 6fc537cdf496f3a644ec68d6103de51eb7f5c9cb
Author:     Xisco Fauli <[email protected]>
AuthorDate: Tue Jan 16 12:47:40 2024 +0100
Commit:     Xisco Fauli <[email protected]>
CommitDate: Tue Jan 16 22:01:57 2024 +0100

    CppunitTest_sc_uicalc: sc_uicalc: extend test a bit
    
    Change-Id: I3c112c1362485868d0da016428fb897e6e3df3dd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162171
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <[email protected]>

diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx
index 682160b62b2d..af9fb5511d5e 100644
--- a/sc/qa/unit/uicalc/uicalc.cxx
+++ b/sc/qa/unit/uicalc/uicalc.cxx
@@ -56,6 +56,8 @@ static void lcl_AssertConditionalFormatList(ScDocument& rDoc, 
size_t nSize,
     {
         const ScRangeList& aRange = rItem->GetRange();
         aRange.Format(sRangeStr, ScRefFlags::VALID, rDoc, 
rDoc.GetAddressConvention());
+        CPPUNIT_ASSERT_MESSAGE(OString(sRangeStr.toUtf8() + " not 
found").getStr(),
+                               rExpectedValues.count(sRangeStr));
         CPPUNIT_ASSERT_EQUAL(rExpectedValues[sRangeStr],
                              ScCondFormatHelper::GetExpression(*rItem, 
aRange.GetTopLeftCorner()));
     }
@@ -1250,8 +1252,10 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf92963)
     aInputOption.SetReplaceCellsWarn(false);
     pMod->SetInputOptions(aInputOption);
 
-    ScConditionalFormatList* pList = pDoc->GetCondFormList(0);
-    CPPUNIT_ASSERT_EQUAL(size_t(3), pList->size());
+    std::unordered_map<OUString, OUString> aExpectedValues
+        = { { "C1", "Cell value > 14" }, { "C3", "Cell value > 14" }, { "C4", 
"Cell value > 14" } };
+
+    lcl_AssertConditionalFormatList(*pDoc, 3, aExpectedValues);
 
     goToCell("A3:C4");
 
@@ -1261,7 +1265,8 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf92963)
 
     dispatchCommand(mxComponent, ".uno:Paste", {});
 
-    CPPUNIT_ASSERT_EQUAL(size_t(2), pList->size());
+    aExpectedValues = { { "C3,C1", "Cell value > 14" }, { "C4,C2", "Cell value 
> 14" } };
+    lcl_AssertConditionalFormatList(*pDoc, 2, aExpectedValues);
 
     // Restore previous status
     aInputOption.SetReplaceCellsWarn(bOldStatus);
commit e4755087cad159f8a3f628789256a4faa90a76bf
Author:     Xisco Fauli <[email protected]>
AuthorDate: Tue Jan 16 12:23:05 2024 +0100
Commit:     Xisco Fauli <[email protected]>
CommitDate: Tue Jan 16 22:01:48 2024 +0100

    tdf#140330: sc_uicalc: Add unittest
    
    Change-Id: I6cbb3f310f0876119e0d335807991e7a4f753226
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162169
    Tested-by: Xisco Fauli <[email protected]>
    Reviewed-by: Xisco Fauli <[email protected]>

diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx
index 16c751fdefce..682160b62b2d 100644
--- a/sc/qa/unit/uicalc/uicalc.cxx
+++ b/sc/qa/unit/uicalc/uicalc.cxx
@@ -1229,6 +1229,13 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf104026)
     // - Expected: Cell value != $Sheet1.$B2
     // - Actual  : Cell value != $Sheet1.$B#REF!
     lcl_AssertConditionalFormatList(*pDoc, 5, aExpectedValues);
+
+    dispatchCommand(mxComponent, ".uno:Undo", {});
+
+    // tdf#140330: Without the fix in place, this test would have failed with
+    // - Expected: 6
+    // - Actual  : 5
+    lcl_AssertConditionalFormatList(*pDoc, 6, aExpectedValues);
 }
 
 CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf92963)

Reply via email to