summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-01-02 14:07:09 -0500
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-01-02 20:54:31 -0500
commite2b91f39f7162e031c07235a60bfe04f26fee53a (patch)
tree44b30d6a752caa3b0b01251afc8514eb14263847
parentfbbbcdde585636aea0db1741a0a0ddcc7e0358f3 (diff)
fdo#56278: Write a unit test for this.
The reported bug description was very concise and unit-testable. We should turn it into a real test. Change-Id: I7383316e8fcf799a59b1c32a1722fd4b6b224d1c
-rw-r--r--sc/qa/unit/ucalc.cxx34
1 files changed, 34 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 55b8b9c94405..4b7e4fd5c1eb 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -121,7 +121,16 @@ public:
*/
void testSheetsFunc();
void testVolatileFunc();
+
+ /**
+ * Basic test for formula dependency tracking.
+ */
void testFormulaDepTracking();
+
+ /**
+ * Another test for formula dependency tracking, inspired by fdo#56278.
+ */
+ void testFormulaDepTracking2();
void testFuncParam();
void testNamedRange();
void testCSV();
@@ -248,6 +257,7 @@ public:
CPPUNIT_TEST(testSheetsFunc);
CPPUNIT_TEST(testVolatileFunc);
CPPUNIT_TEST(testFormulaDepTracking);
+ CPPUNIT_TEST(testFormulaDepTracking2);
CPPUNIT_TEST(testFuncParam);
CPPUNIT_TEST(testNamedRange);
CPPUNIT_TEST(testCSV);
@@ -1223,6 +1233,30 @@ void Test::testFormulaDepTracking()
m_pDoc->DeleteTab(0);
}
+void Test::testFormulaDepTracking2()
+{
+ CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet", m_pDoc->InsertTab (0, "foo"));
+
+ AutoCalcSwitch aACSwitch(m_pDoc, true); // turn on auto calculation.
+
+ double val = 2.0;
+ m_pDoc->SetValue(0, 0, 0, val);
+ val = 4.0;
+ m_pDoc->SetValue(1, 0, 0, val);
+ val = 5.0;
+ m_pDoc->SetValue(0, 1, 0, val);
+ m_pDoc->SetString(2, 0, 0, "=A1/B1");
+ m_pDoc->SetString(1, 1, 0, "=B1*C1");
+
+ CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(1, 1, 0)); // B2 should equal 2.
+
+ clearRange(m_pDoc, ScAddress(2, 0, 0)); // Delete C1.
+
+ CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(1, 1, 0)); // B2 should now equal 0.
+
+ m_pDoc->DeleteTab(0);
+}
+
void Test::testFuncParam()
{
rtl::OUString aTabName("foo");