summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-11-25 17:11:57 -0500
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-11-25 17:14:07 -0500
commit96a4189c568fbf7f63bec13f7a77a114aa7a3ede (patch)
tree519ea0b8d3633f2814411da3567f7bb3f14414cc
parentf46a5d6dfddf86be0d77e00cf44f26af54a97c75 (diff)
fdo#86615: Write test for this.
Change-Id: I75412790e0afc1dbe3255254ff13fd41c5e9934b
-rw-r--r--sc/qa/unit/ucalc.hxx3
-rw-r--r--sc/qa/unit/ucalc_formula.cxx29
2 files changed, 32 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index e20b069895ea..21568ed4e5aa 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -204,6 +204,8 @@ public:
*/
void testFormulaDepTracking2();
+ void testFormulaDepTracking3();
+
void testFormulaDepTrackingDeleteRow();
void testFormulaDepTrackingDeleteCol();
@@ -491,6 +493,7 @@ public:
CPPUNIT_TEST(testValueIterator);
CPPUNIT_TEST(testFormulaDepTracking);
CPPUNIT_TEST(testFormulaDepTracking2);
+ CPPUNIT_TEST(testFormulaDepTracking3);
CPPUNIT_TEST(testFormulaDepTrackingDeleteRow);
CPPUNIT_TEST(testFormulaDepTrackingDeleteCol);
CPPUNIT_TEST(testFormulaMatrixResultUpdate);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index b15342ffb1db..90e906b41109 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -4248,6 +4248,35 @@ void Test::testFormulaDepTracking2()
m_pDoc->DeleteTab(0);
}
+void Test::testFormulaDepTracking3()
+{
+ sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calculation.
+
+ m_pDoc->InsertTab(0, "Formula");
+
+ const char* pData[][4] = {
+ { "1", "2", "=SUM(A1:B1)", "=SUM(C1:C3)" },
+ { "3", "4", "=SUM(A2:B2)", 0 },
+ { "5", "6", "=SUM(A3:B3)", 0 },
+ };
+
+ insertRangeData(m_pDoc, ScAddress(0,0,0), pData, SAL_N_ELEMENTS(pData), true);
+
+ // Check the initial formula results.
+ CPPUNIT_ASSERT_EQUAL( 3.0, m_pDoc->GetValue(ScAddress(2,0,0)));
+ CPPUNIT_ASSERT_EQUAL( 7.0, m_pDoc->GetValue(ScAddress(2,1,0)));
+ CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(ScAddress(2,2,0)));
+ CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(ScAddress(3,0,0)));
+
+ // Change B3 and make sure the change gets propagated to D1.
+ ScDocFunc& rFunc = getDocShell().GetDocFunc();
+ rFunc.SetValueCell(ScAddress(1,2,0), 60.0, false);
+ CPPUNIT_ASSERT_EQUAL(65.0, m_pDoc->GetValue(ScAddress(2,2,0)));
+ CPPUNIT_ASSERT_EQUAL(75.0, m_pDoc->GetValue(ScAddress(3,0,0)));
+
+ m_pDoc->DeleteTab(0);
+}
+
void Test::testFormulaDepTrackingDeleteRow()
{
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calculation.