[Libreoffice-commits] .: sc/qa

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Jan 2 11:07:27 PST 2013


 sc/qa/unit/ucalc.cxx |   34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

New commits:
commit c1f9efa4ac8a406cf10f3b5585f45ee0114621e4
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Wed Jan 2 14:07:09 2013 -0500

    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

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 55b8b9c..4b7e4fd 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");


More information about the Libreoffice-commits mailing list