sc/qa/unit/uicalc/data/tdf153669.ods |binary
 sc/qa/unit/uicalc/uicalc.cxx         |   46 +++++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+)

New commits:
commit 3fa61383b51180c17154a9d5762c22b7d436df65
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Wed Mar 1 12:19:07 2023 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Wed Mar 1 16:35:15 2023 +0000

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

diff --git a/sc/qa/unit/uicalc/data/tdf153669.ods 
b/sc/qa/unit/uicalc/data/tdf153669.ods
new file mode 100644
index 000000000000..ccd211abcb22
Binary files /dev/null and b/sc/qa/unit/uicalc/data/tdf153669.ods differ
diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx
index f3ac1dfe7115..7cc12ea150a0 100644
--- a/sc/qa/unit/uicalc/uicalc.cxx
+++ b/sc/qa/unit/uicalc/uicalc.cxx
@@ -990,6 +990,52 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf144244)
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xPage->getCount());
 }
 
+CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf153669)
+{
+    createScDoc("tdf153669.ods");
+    ScDocument* pDoc = getScDoc();
+
+    // Disable replace cell warning
+    ScModule* pMod = SC_MOD();
+    ScInputOptions aInputOption = pMod->GetInputOptions();
+    bool bOldStatus = aInputOption.GetReplaceCellsWarn();
+    aInputOption.SetReplaceCellsWarn(false);
+    pMod->SetInputOptions(aInputOption);
+
+    insertStringToCell("E2", u"100");
+
+    CPPUNIT_ASSERT_EQUAL(OUString("110.00"), pDoc->GetString(ScAddress(5, 1, 
0)));
+
+    dispatchCommand(mxComponent, ".uno:Undo", {});
+
+    CPPUNIT_ASSERT_EQUAL(OUString("15.00"), pDoc->GetString(ScAddress(5, 1, 
0)));
+
+    goToCell("E7");
+
+    dispatchCommand(mxComponent, ".uno:Copy", {});
+
+    goToCell("F7");
+
+    dispatchCommand(mxComponent, ".uno:Paste", {});
+
+    CPPUNIT_ASSERT_EQUAL(OUString("text"), pDoc->GetString(ScAddress(5, 6, 
0)));
+
+    insertStringToCell("E2", u"100");
+
+    // Without the fix in place, this test would have failed with
+    // - Expected: 110.00
+    // - Actual  : 15.00
+    CPPUNIT_ASSERT_EQUAL(OUString("110.00"), pDoc->GetString(ScAddress(5, 1, 
0)));
+
+    dispatchCommand(mxComponent, ".uno:Undo", {});
+
+    CPPUNIT_ASSERT_EQUAL(OUString("15.00"), pDoc->GetString(ScAddress(5, 1, 
0)));
+
+    // Restore previous status
+    aInputOption.SetReplaceCellsWarn(bOldStatus);
+    pMod->SetInputOptions(aInputOption);
+}
+
 CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf100582)
 {
     createScDoc("tdf100582.xls");

Reply via email to