diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-08-13 18:28:11 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-08-13 23:01:21 -0400 |
commit | 77e8422947a83d6db3c528fd5d773aeb14178f37 (patch) | |
tree | 86719e54bd52c4788dad243bf28760dc28336b40 /sc/qa | |
parent | ecb842e71e6cd17cc9f19e7dbc975de90d8603ae (diff) |
Add test for reference update on shared formulas.
This currently (rightfully) fails.
Change-Id: I254dc7042e93b257765c8ed8cdb9904966afd77e
Diffstat (limited to 'sc/qa')
-rw-r--r-- | sc/qa/unit/ucalc.hxx | 2 | ||||
-rw-r--r-- | sc/qa/unit/ucalc_sharedformula.cxx | 63 |
2 files changed, 65 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index ebc3221868d2..5e8933c90b2c 100644 --- a/sc/qa/unit/ucalc.hxx +++ b/sc/qa/unit/ucalc.hxx @@ -219,6 +219,7 @@ public: void testUpdateReference(); void testSearchCells(); void testSharedFormulas(); + void testSharedFormulasRefUpdate(); void testSharedFormulasCopyPaste(); void testFormulaPosition(); @@ -345,6 +346,7 @@ public: CPPUNIT_TEST(testUpdateReference); CPPUNIT_TEST(testSearchCells); CPPUNIT_TEST(testSharedFormulas); + CPPUNIT_TEST(testSharedFormulasRefUpdate); CPPUNIT_TEST(testSharedFormulasCopyPaste); CPPUNIT_TEST(testFormulaPosition); CPPUNIT_TEST(testJumpToPrecedentsDependents); diff --git a/sc/qa/unit/ucalc_sharedformula.cxx b/sc/qa/unit/ucalc_sharedformula.cxx index 1eba457902f0..094db8f1acd1 100644 --- a/sc/qa/unit/ucalc_sharedformula.cxx +++ b/sc/qa/unit/ucalc_sharedformula.cxx @@ -14,6 +14,7 @@ #include "docsh.hxx" #include "clipparam.hxx" #include "undoblk.hxx" +#include "scopetools.hxx" #include "formula/grammar.hxx" @@ -249,6 +250,68 @@ void Test::testSharedFormulas() m_pDoc->DeleteTab(0); } +void Test::testSharedFormulasRefUpdate() +{ + m_pDoc->InsertTab(0, "Test"); + + sc::AutoCalcSwitch aACSwitch(*m_pDoc, false); // turn off auto calculation. + + // Set values to A10:A12. + m_pDoc->SetValue(ScAddress(0,9,0), 1); + m_pDoc->SetValue(ScAddress(0,10,0), 2); + m_pDoc->SetValue(ScAddress(0,11,0), 3); + + // Insert formulas that reference A10:A12 in B1:B3. + m_pDoc->SetString(ScAddress(1,0,0), "=A10"); + m_pDoc->SetString(ScAddress(1,1,0), "=A11"); + m_pDoc->SetString(ScAddress(1,2,0), "=A12"); + + if (!checkFormula(*m_pDoc, ScAddress(1,0,0), "A10")) + CPPUNIT_FAIL("Wrong formula in B1"); + if (!checkFormula(*m_pDoc, ScAddress(1,1,0), "A11")) + CPPUNIT_FAIL("Wrong formula in B2"); + if (!checkFormula(*m_pDoc, ScAddress(1,2,0), "A12")) + CPPUNIT_FAIL("Wrong formula in B3"); + + const ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1,0,0)); + CPPUNIT_ASSERT_MESSAGE("This must be a shared formula cell.", pFC && pFC->IsShared()); + CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(0), pFC->GetSharedTopRow()); + CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(3), pFC->GetSharedLength()); + + // Insert cells over A11:B11 to shift to right. This should split the B1:B3 grouping into 3. + m_pDoc->InsertCol(ScRange(0,10,0,1,10,0)); + if (!checkFormula(*m_pDoc, ScAddress(1,0,0), "A10")) + CPPUNIT_FAIL("Wrong formula in B1"); + if (!checkFormula(*m_pDoc, ScAddress(1,1,0), "C11")) + CPPUNIT_FAIL("Wrong formula in B2"); + if (!checkFormula(*m_pDoc, ScAddress(1,2,0), "A12")) + CPPUNIT_FAIL("Wrong formula in B3"); + + pFC = m_pDoc->GetFormulaCell(ScAddress(1,0,0)); + CPPUNIT_ASSERT_MESSAGE("B1 should be a non-shared formula cell.", pFC && !pFC->IsShared()); + pFC = m_pDoc->GetFormulaCell(ScAddress(1,1,0)); + CPPUNIT_ASSERT_MESSAGE("B2 should be a non-shared formula cell.", pFC && !pFC->IsShared()); + pFC = m_pDoc->GetFormulaCell(ScAddress(1,2,0)); + CPPUNIT_ASSERT_MESSAGE("B3 should be a non-shared formula cell.", pFC && !pFC->IsShared()); + + // Delelte cells over A11:B11 to bring it back to the previous state. + m_pDoc->DeleteCol(ScRange(0,10,0,1,10,0)); + + if (!checkFormula(*m_pDoc, ScAddress(1,0,0), "A10")) + CPPUNIT_FAIL("Wrong formula in B1"); + if (!checkFormula(*m_pDoc, ScAddress(1,1,0), "A11")) + CPPUNIT_FAIL("Wrong formula in B2"); + if (!checkFormula(*m_pDoc, ScAddress(1,2,0), "A12")) + CPPUNIT_FAIL("Wrong formula in B3"); + + pFC = m_pDoc->GetFormulaCell(ScAddress(1,0,0)); + CPPUNIT_ASSERT_MESSAGE("This must be a shared formula cell.", pFC && pFC->IsShared()); + CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(0), pFC->GetSharedTopRow()); + CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(3), pFC->GetSharedLength()); + + m_pDoc->DeleteTab(0); +} + void Test::testSharedFormulasCopyPaste() { m_pDoc->InsertTab(0, "Test"); |