sc/qa/unit/uicalc/uicalc.cxx | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
New commits: commit 859a7e52b20859a5c13ce83eeb7ec7fceb126fb5 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Thu Mar 24 10:57:35 2022 +0100 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Thu Mar 24 15:09:33 2022 +0100 tdf#115162: sc_uicalc: Add unittest Change-Id: I79874452b1f6909f23629cf0662f8c59faf02558 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132059 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx index b9823ff02bb5..bfb1e2ba07e5 100644 --- a/sc/qa/unit/uicalc/uicalc.cxx +++ b/sc/qa/unit/uicalc/uicalc.cxx @@ -269,6 +269,47 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf100847) CPPUNIT_ASSERT_EQUAL(OUString("0"), pDoc->GetString(ScAddress(2, 0, 0))); } +CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf115162) +{ + mxComponent = loadFromDesktop("private:factory/scalc"); + ScModelObj* pModelObj = dynamic_cast<ScModelObj*>(mxComponent.get()); + CPPUNIT_ASSERT(pModelObj); + ScDocument* pDoc = pModelObj->GetDocument(); + CPPUNIT_ASSERT(pDoc); + + insertStringToCell(*pModelObj, "A2", "2015"); + insertStringToCell(*pModelObj, "A3", "2015"); + insertStringToCell(*pModelObj, "A4", "2015"); + + insertStringToCell(*pModelObj, "B2", "1"); + insertStringToCell(*pModelObj, "B3", "1"); + insertStringToCell(*pModelObj, "B4", "2"); + + insertStringToCell(*pModelObj, "C2", "10"); + insertStringToCell(*pModelObj, "C3", "20"); + insertStringToCell(*pModelObj, "C4", "5"); + + // Save the document + utl::TempFile aTempFile = save(mxComponent, "calc8"); + + // Open a new document + mxComponent = loadFromDesktop("private:factory/scalc"); + pModelObj = dynamic_cast<ScModelObj*>(mxComponent.get()); + CPPUNIT_ASSERT(pModelObj); + pDoc = pModelObj->GetDocument(); + CPPUNIT_ASSERT(pDoc); + + // Insert the reference to the external document + OUString aFormula = "=SUMIFS('" + aTempFile.GetURL() + "'#$Sheet1.C2:C4,'" + aTempFile.GetURL() + + "'#$Sheet1.B2:B4,1,'" + aTempFile.GetURL() + "'#$Sheet1.A2:A4,2015)"; + insertStringToCell(*pModelObj, "A1", aFormula.toUtf8().getStr()); + + // Without the fix in place, this test would have failed with + // - Expected: 30 + // - Actual : Err:504 + CPPUNIT_ASSERT_EQUAL(OUString("30"), pDoc->GetString(ScAddress(0, 0, 0))); +} + CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf103994) { mxComponent = loadFromDesktop("private:factory/scalc");