tdf#132431: sc: Add unittest
Change-Id: I4ecae9e29827a29680c9f082a9602fc181b0b56e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96024
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
diff --git a/sc/qa/unit/uicalc/data/tdf132431.ods b/sc/qa/unit/uicalc/data/tdf132431.ods
new file mode 100644
index 0000000..2022a9d
--- /dev/null
+++ b/sc/qa/unit/uicalc/data/tdf132431.ods
Binary files differ
diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx
index 694644b..46e4b24 100644
--- a/sc/qa/unit/uicalc/uicalc.cxx
+++ b/sc/qa/unit/uicalc/uicalc.cxx
@@ -149,6 +149,28 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf124815)
CPPUNIT_ASSERT_EQUAL(OUString("Rakennukset"), pDoc->GetString(ScAddress(2, 0, 0)));
}
CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf132431)
{
ScModelObj* pModelObj = createDoc("tdf132431.ods");
ScDocument* pDoc = pModelObj->GetDocument();
CPPUNIT_ASSERT(pDoc);
OUString aFormula;
pDoc->GetFormula(7, 219, 0, aFormula);
CPPUNIT_ASSERT_EQUAL(OUString("=SUMIFS($H$2:$H$198,B$2:B$198,G220)"), aFormula);
CPPUNIT_ASSERT_EQUAL(0.0, pDoc->GetValue(ScAddress(7, 219, 0)));
// Without the fix in place, it would crash here with
// uncaught exception of type std::exception (or derived).
// - vector::_M_fill_insert
pDoc->SetString(ScAddress(7, 219, 0), "=SUMIFS($H$2:$DB$198,B$2:B$198,G220)");
pDoc->GetFormula(7, 219, 0, aFormula);
CPPUNIT_ASSERT_EQUAL(OUString("=SUMIFS($H$2:$DB$198,B$2:B$198,G220)"), aFormula);
CPPUNIT_ASSERT_EQUAL(0.0, pDoc->GetValue(ScAddress(7, 219, 0)));
CPPUNIT_ASSERT_EQUAL(OUString("Err:502"), pDoc->GetString(ScAddress(7, 219, 0)));
}
CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf83901)
{
mxComponent = loadFromDesktop("private:factory/scalc");