diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-03-24 10:41:57 +0100 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-03-24 12:51:14 +0100 |
commit | 312cf9580c4b7846d217ce241c36f327a81f6cea (patch) | |
tree | 2634e5148ecf4a921a407f32acebe16b20216be9 /sc/qa/unit/uicalc/uicalc.cxx | |
parent | 8ae60da492da5e1c1e721cf5e05f947546cc79b3 (diff) |
tdf#100847: sc_uicalc: Add unittest
Change-Id: I0bd79a0b3bc6d92ec83ecd86c4ca631e65528c35
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132057
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sc/qa/unit/uicalc/uicalc.cxx')
-rw-r--r-- | sc/qa/unit/uicalc/uicalc.cxx | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx index fe90247e16ce..b9823ff02bb5 100644 --- a/sc/qa/unit/uicalc/uicalc.cxx +++ b/sc/qa/unit/uicalc/uicalc.cxx @@ -232,6 +232,43 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf36387) CPPUNIT_ASSERT_EQUAL(OUString("TRUE"), pDoc->GetString(ScAddress(1, 0, 0))); } +CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf100847) +{ + mxComponent = loadFromDesktop("private:factory/scalc"); + ScModelObj* pModelObj = dynamic_cast<ScModelObj*>(mxComponent.get()); + CPPUNIT_ASSERT(pModelObj); + ScDocument* pDoc = pModelObj->GetDocument(); + CPPUNIT_ASSERT(pDoc); + + // 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 = "=+'" + aTempFile.GetURL() + "'#$Sheet1.A1"; + insertStringToCell(*pModelObj, "A1", aFormula.toUtf8().getStr()); + + aFormula = "=+'" + aTempFile.GetURL() + "'#$Sheet1.A1*1"; + insertStringToCell(*pModelObj, "B1", aFormula.toUtf8().getStr()); + + aFormula = "=+N('" + aTempFile.GetURL() + "'#$Sheet1.A1)*1"; + insertStringToCell(*pModelObj, "C1", aFormula.toUtf8().getStr()); + + CPPUNIT_ASSERT_EQUAL(OUString("0"), pDoc->GetString(ScAddress(0, 0, 0))); + + // Without the fix in place, this test would have failed with + // - Expected: 0 + // - Actual : #VALUE! + CPPUNIT_ASSERT_EQUAL(OUString("0"), pDoc->GetString(ScAddress(1, 0, 0))); + CPPUNIT_ASSERT_EQUAL(OUString("0"), pDoc->GetString(ScAddress(2, 0, 0))); +} + CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf103994) { mxComponent = loadFromDesktop("private:factory/scalc"); |