diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-07-18 21:35:22 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-07-24 23:29:30 -0400 |
commit | c43c3e3c08b039bd5c572de10a673af69041758b (patch) | |
tree | 725b6fab0f0f73ff7cab02e80ab14ac7b7cb4b95 /sc/qa | |
parent | 3d7976b1ad31e682d51d3da6f3e89ca80a42a6a7 (diff) |
Add test for resizing range references. To be expanded later.
Change-Id: I886d190dd2533b89185dbc24d0b9043941618802
Diffstat (limited to 'sc/qa')
-rw-r--r-- | sc/qa/unit/ucalc.hxx | 2 | ||||
-rw-r--r-- | sc/qa/unit/ucalc_formula.cxx | 38 |
2 files changed, 40 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index 440230cad22a..09e389148aa4 100644 --- a/sc/qa/unit/ucalc.hxx +++ b/sc/qa/unit/ucalc.hxx @@ -87,6 +87,7 @@ public: void testFormulaRefData(); void testFormulaCompiler(); void testFormulaRefUpdate(); + void testFormulaRefUpdateRange(); void testFuncSUM(); void testFuncPRODUCT(); void testFuncN(); @@ -274,6 +275,7 @@ public: CPPUNIT_TEST(testFormulaRefData); CPPUNIT_TEST(testFormulaCompiler); CPPUNIT_TEST(testFormulaRefUpdate); + CPPUNIT_TEST(testFormulaRefUpdateRange); CPPUNIT_TEST(testFuncSUM); CPPUNIT_TEST(testFuncPRODUCT); CPPUNIT_TEST(testFuncN); diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx index a57c6cfaf420..a902caebea52 100644 --- a/sc/qa/unit/ucalc_formula.cxx +++ b/sc/qa/unit/ucalc_formula.cxx @@ -441,6 +441,44 @@ void Test::testFormulaRefUpdate() m_pDoc->DeleteTab(0); } +void Test::testFormulaRefUpdateRange() +{ + m_pDoc->InsertTab(0, "Formula"); + + sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on. + + // Set values to B2:C5. + m_pDoc->SetValue(ScAddress(1,1,0), 1); + m_pDoc->SetValue(ScAddress(1,2,0), 2); + m_pDoc->SetValue(ScAddress(1,3,0), 3); + m_pDoc->SetValue(ScAddress(1,4,0), 4); + m_pDoc->SetValue(ScAddress(2,1,0), 5); + m_pDoc->SetValue(ScAddress(2,2,0), 6); + m_pDoc->SetValue(ScAddress(2,3,0), 7); + m_pDoc->SetValue(ScAddress(2,4,0), 8); + + // Set formula cells to A7 and A8. + m_pDoc->SetString(ScAddress(0,6,0), "=SUM(B2:C5)"); + m_pDoc->SetString(ScAddress(0,7,0), "=SUM($B$2:$C$5)"); + + if (!checkFormula(*m_pDoc, ScAddress(0,6,0), "SUM(B2:C5)")) + CPPUNIT_FAIL("Wrong formula in A7."); + + if (!checkFormula(*m_pDoc, ScAddress(0,7,0), "SUM($B$2:$C$5)")) + CPPUNIT_FAIL("Wrong formula in A8."); + + // Delete row 3. This should shrink the range references by one row. + m_pDoc->DeleteRow(ScRange(0,2,0,MAXCOL,2,0)); + + if (!checkFormula(*m_pDoc, ScAddress(0,5,0), "SUM(B2:C4)")) + CPPUNIT_FAIL("Wrong formula in A6."); + + if (!checkFormula(*m_pDoc, ScAddress(0,6,0), "SUM($B$2:$C$4)")) + CPPUNIT_FAIL("Wrong formula in A7."); + + m_pDoc->DeleteTab(0); +} + void Test::testFuncSUM() { OUString aTabName("foo"); |