Kaydet (Commit) 2d4a9312 authored tarafından Eike Rathke's avatar Eike Rathke

unit test for tdf#91411

Change-Id: I963674ad6c6a4ca95f1a65041f7ced64d7d86a43
üst a6c07d2c
......@@ -337,6 +337,7 @@ public:
void testSharedFormulaUpdateOnDBChange();
void testSharedFormulaAbsCellListener();
void testSharedFormulaUnshareAreaListeners();
void testSharedFormulaListenerDeleteArea();
void testFormulaPosition();
void testMixData();
......@@ -586,6 +587,7 @@ public:
CPPUNIT_TEST(testSharedFormulaUpdateOnDBChange);
CPPUNIT_TEST(testSharedFormulaAbsCellListener);
CPPUNIT_TEST(testSharedFormulaUnshareAreaListeners);
CPPUNIT_TEST(testSharedFormulaListenerDeleteArea);
CPPUNIT_TEST(testFormulaPosition);
CPPUNIT_TEST(testMixData);
CPPUNIT_TEST(testJumpToPrecedentsDependents);
......
......@@ -1733,4 +1733,48 @@ void Test::testSharedFormulaUnshareAreaListeners()
m_pDoc->DeleteTab(0);
}
void Test::testSharedFormulaListenerDeleteArea()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc.
m_pDoc->InsertTab(0, "Test0");
m_pDoc->InsertTab(1, "Test1");
const char* pData0[][3] = {
{ "", "", "=Test1.C1" },
{ "", "", "=Test1.C2" }
};
const char* pData1[][3] = {
{ "=Test0.A1", "=Test0.B1", "=SUM(A1:B1)" },
{ "=Test0.A2", "=Test0.B2", "=SUM(A2:B2)" },
};
insertRangeData(m_pDoc, ScAddress(0,0,0), pData0, SAL_N_ELEMENTS(pData0));
insertRangeData(m_pDoc, ScAddress(0,0,1), pData1, SAL_N_ELEMENTS(pData1));
// Check that Test1.A1:A2 and Test1.B1:B2 are formula groups.
const ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(0,0,1));
CPPUNIT_ASSERT(pFC);
CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(0), pFC->GetSharedTopRow());
CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(2), pFC->GetSharedLength());
pFC = m_pDoc->GetFormulaCell(ScAddress(1,0,1));
CPPUNIT_ASSERT(pFC);
CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(0), pFC->GetSharedTopRow());
CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(2), pFC->GetSharedLength());
m_pDoc->SetValue(ScAddress(0,1,0), 1.0); // change value of Test0.A2
m_pDoc->SetValue(ScAddress(1,1,0), 2.0); // change value of Test0.B2
// Test0.C2 should be recalculated.
CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(2,1,0)));
// Delete Test0.B2
clearRange(m_pDoc, ScRange(1,1,0));
// Test0.C2 should be recalculated.
CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(2,1,0)));
m_pDoc->DeleteTab(1);
m_pDoc->DeleteTab(0);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment