sc/qa/unit/uicalc/data/tdf142010.xls |binary
 sc/qa/unit/uicalc/uicalc.cxx         |   30 ++++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+)

New commits:
commit eb664612aba4d7d8d5cf8d5a448f12be55da59ba
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Tue Oct 26 10:49:40 2021 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue Oct 26 22:28:33 2021 +0200

    tdf#142010: sc_uicalc: Add unittest
    
    Change-Id: I99676a273c7ad1dad61ba82bc538c1ee4bd35d03
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124175
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sc/qa/unit/uicalc/data/tdf142010.xls 
b/sc/qa/unit/uicalc/data/tdf142010.xls
new file mode 100644
index 000000000000..c58bc0169fe7
Binary files /dev/null and b/sc/qa/unit/uicalc/data/tdf142010.xls differ
diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx
index 46c430c7e087..1abbf6342ed8 100644
--- a/sc/qa/unit/uicalc/uicalc.cxx
+++ b/sc/qa/unit/uicalc/uicalc.cxx
@@ -1103,6 +1103,36 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf124815)
     CPPUNIT_ASSERT_EQUAL(OUString("Rakennukset"), pDoc->GetString(ScAddress(2, 
0, 0)));
 }
 
+CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf142010)
+{
+    ScModelObj* pModelObj = createDoc("tdf142010.xls");
+    ScDocument* pDoc = pModelObj->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+
+    goToCell("A1");
+
+    OUString aFormula;
+    pDoc->GetFormula(5, 71, 0, aFormula);
+    CPPUNIT_ASSERT_EQUAL(OUString("=MOD(F$71+$C72,9)"), aFormula);
+    CPPUNIT_ASSERT_EQUAL(5.0, pDoc->GetValue(ScAddress(5, 71, 0)));
+
+    dispatchCommand(mxComponent, ".uno:InsertColumnsBefore", {});
+
+    pDoc->GetFormula(6, 71, 0, aFormula);
+
+    // Without the fix in place, this test would have failed with
+    // - Expected: =MOD(G$71+$D72,9)
+    // - Actual  : =MOD(G$71+$K72,9)
+    CPPUNIT_ASSERT_EQUAL(OUString("=MOD(G$71+$D72,9)"), aFormula);
+    CPPUNIT_ASSERT_EQUAL(5.0, pDoc->GetValue(ScAddress(6, 71, 0)));
+
+    dispatchCommand(mxComponent, ".uno:Undo", {});
+
+    pDoc->GetFormula(5, 71, 0, aFormula);
+    CPPUNIT_ASSERT_EQUAL(OUString("=MOD(F$71+$C72,9)"), aFormula);
+    CPPUNIT_ASSERT_EQUAL(5.0, pDoc->GetValue(ScAddress(5, 71, 0)));
+}
+
 CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf132431)
 {
     ScModelObj* pModelObj = createDoc("tdf132431.ods");

Reply via email to