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 14:08:49 -0500
commitc1f9efa4ac8a406cf10f3b5585f45ee0114621e4 (patch)
tree8fc519e131f85dc432fcbf382364d7d43c6a6d38
parent8275c8fc33b63aa40a0a8a8c215f32b9986edab6 (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");