summaryrefslogtreecommitdiff
path: root/sc/qa/unit
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-07-23 18:59:34 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-07-24 23:29:40 -0400
commitcdc9c6d5780f199418cbed8045790846f0c32521 (patch)
tree451b9c5685eac41b8e1b72cde16399b1a6c2cb58 /sc/qa/unit
parentcc6e83d5ca69517f6dc44720d7c28417508b6542 (diff)
Add starter test for reference update on range move.
This currently fails. Change-Id: I83cdcb6ed9620079664ff35375a0457b0c9bcea0
Diffstat (limited to 'sc/qa/unit')
-rw-r--r--sc/qa/unit/ucalc.hxx2
-rw-r--r--sc/qa/unit/ucalc_formula.cxx50
2 files changed, 52 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index ac17bd9b4801..5a1d0aea89e9 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -89,6 +89,7 @@ public:
void testFormulaRefUpdate();
void testFormulaRefUpdateRange();
void testFormulaRefUpdateSheets();
+ void testFormulaRefUpdateMove();
void testFuncCOLUMN();
void testFuncROW();
void testFuncSUM();
@@ -280,6 +281,7 @@ public:
CPPUNIT_TEST(testFormulaRefUpdate);
CPPUNIT_TEST(testFormulaRefUpdateRange);
CPPUNIT_TEST(testFormulaRefUpdateSheets);
+ CPPUNIT_TEST(testFormulaRefUpdateMove);
CPPUNIT_TEST(testFuncCOLUMN);
CPPUNIT_TEST(testFuncROW);
CPPUNIT_TEST(testFuncSUM);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index c651b6d34cd1..69b0374aa275 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -18,6 +18,8 @@
#include "formulacell.hxx"
#include "inputopt.hxx"
#include "scmod.hxx"
+#include "docsh.hxx"
+#include "docfunc.hxx"
#include <boost/scoped_ptr.hpp>
@@ -837,6 +839,54 @@ void Test::testFormulaRefUpdateSheets()
m_pDoc->DeleteTab(0);
}
+void Test::testFormulaRefUpdateMove()
+{
+ m_pDoc->InsertTab(0, "Sheet1");
+
+ sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
+
+ // Set value to B4:B6.
+ m_pDoc->SetValue(ScAddress(1,3,0), 1);
+ m_pDoc->SetValue(ScAddress(1,4,0), 2);
+ m_pDoc->SetValue(ScAddress(1,5,0), 3);
+
+ // Set formulas to A9:A12 that references B4:B6.
+ m_pDoc->SetString(ScAddress(0,8,0), "=SUM(B4:B6)");
+ m_pDoc->SetString(ScAddress(0,9,0), "=SUM($B$4:$B$6)");
+ m_pDoc->SetString(ScAddress(0,10,0), "=B5");
+ m_pDoc->SetString(ScAddress(0,11,0), "=$B$6");
+
+ CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(0,8,0));
+ CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(0,9,0));
+ CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(0,10,0));
+ CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(0,11,0));
+
+ // Move B4:B6 to D4 (two columsn to the right).
+ ScDocFunc& rFunc = getDocShell().GetDocFunc();
+ bool bMoved = rFunc.MoveBlock(ScRange(1,3,0,1,5,0), ScAddress(3,3,0), true, false, false, false);
+ CPPUNIT_ASSERT_MESSAGE("Failed to move B4:B6.", bMoved);
+
+ // The results of the formula cells that reference the moved range should remain the same.
+ CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(0,8,0));
+ CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(0,9,0));
+ CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(0,10,0));
+ CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(0,11,0));
+
+ if (!checkFormula(*m_pDoc, ScAddress(0,8,0), "SUM(D4:D6)"))
+ CPPUNIT_FAIL("Wrong formula.");
+
+ if (!checkFormula(*m_pDoc, ScAddress(0,9,0), "SUM($D$4:$D$6)"))
+ CPPUNIT_FAIL("Wrong formula.");
+
+ if (!checkFormula(*m_pDoc, ScAddress(0,10,0), "D5"))
+ CPPUNIT_FAIL("Wrong formula.");
+
+ if (!checkFormula(*m_pDoc, ScAddress(0,11,0), "$D$6"))
+ CPPUNIT_FAIL("Wrong formula.");
+
+ m_pDoc->DeleteTab(0);
+}
+
void Test::testFuncCOLUMN()
{
m_pDoc->InsertTab(0, "Formula");