diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-04-28 20:52:29 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-04-28 23:00:50 -0400 |
commit | e4a886f657723040ba10a0ce0101f14763f5605a (patch) | |
tree | 188ebb5659a8b1340d96568b2d5c18e98adc54fb | |
parent | b6086aa6b6107421e1267ad7a50a74aa05770041 (diff) |
fdo#77647: Write test for this.
Change-Id: I25b04c4790fcdae1e85b5d7b9cb85792226af757
-rw-r--r-- | sc/qa/unit/ucalc.hxx | 2 | ||||
-rw-r--r-- | sc/qa/unit/ucalc_formula.cxx | 43 |
2 files changed, 44 insertions, 1 deletions
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index 9a81c5e40e20..06bab38c01a1 100644 --- a/sc/qa/unit/ucalc.hxx +++ b/sc/qa/unit/ucalc.hxx @@ -118,6 +118,7 @@ public: void testFormulaRefUpdate(); void testFormulaRefUpdateRange(); void testFormulaRefUpdateSheets(); + void testFormulaRefUpdateInsertRows(); void testFormulaRefUpdateMove(); void testFormulaRefUpdateMoveUndo(); void testFormulaRefUpdateNamedExpression(); @@ -370,6 +371,7 @@ public: CPPUNIT_TEST(testFormulaRefUpdate); CPPUNIT_TEST(testFormulaRefUpdateRange); CPPUNIT_TEST(testFormulaRefUpdateSheets); + CPPUNIT_TEST(testFormulaRefUpdateInsertRows); CPPUNIT_TEST(testFormulaRefUpdateMove); CPPUNIT_TEST(testFormulaRefUpdateMoveUndo); CPPUNIT_TEST(testFormulaRefUpdateNamedExpression); diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx index 1ecc5d2665bc..937c96e71021 100644 --- a/sc/qa/unit/ucalc_formula.cxx +++ b/sc/qa/unit/ucalc_formula.cxx @@ -1477,6 +1477,43 @@ void Test::testFormulaRefUpdateSheets() m_pDoc->DeleteTab(0); } +void Test::testFormulaRefUpdateInsertRows() +{ + ScModule* pMod = SC_MOD(); + ScInputOptions aOpt = pMod->GetInputOptions(); + aOpt.SetExpandRefs(false); + pMod->SetInputOptions(aOpt); + + sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on. + m_pDoc->InsertTab(0, "Formula"); + + // Insert raw values in B2:B4. + m_pDoc->SetValue(ScAddress(1,1,0), 1.0); + m_pDoc->SetValue(ScAddress(1,2,0), 2.0); + m_pDoc->SetValue(ScAddress(1,3,0), 3.0); + + // Insert a formula in B5 to sum up B2:B4. + m_pDoc->SetString(ScAddress(1,4,0), "=SUM(B2:B4)"); + + CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(1,4,0))); + + // Insert rows over rows 1:2. + ScMarkData aMark; + aMark.SelectOneTable(0); + ScDocFunc& rFunc = getDocShell().GetDocFunc(); + rFunc.InsertCells(ScRange(0,0,0,MAXCOL,1,0), &aMark, INS_INSROWS, false, true, false); + + // The raw data should have shifted to B4:B6. + CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(1,3,0))); + CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(1,4,0))); + CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(1,5,0))); + + if (!checkFormula(*m_pDoc, ScAddress(1,6,0), "SUM(B4:B6)")) + CPPUNIT_FAIL("Wrong formula!"); + + m_pDoc->DeleteTab(0); +} + void Test::testFormulaRefUpdateMove() { m_pDoc->InsertTab(0, "Sheet1"); @@ -1900,10 +1937,14 @@ void Test::testFormulaRefUpdateNamedExpressionMove() void Test::testFormulaRefUpdateNamedExpressionExpandRef() { + ScModule* pMod = SC_MOD(); + ScInputOptions aOpt = pMod->GetInputOptions(); + aOpt.SetExpandRefs(true); // turn on automatic range expansion. + pMod->SetInputOptions(aOpt); + sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on. m_pDoc->InsertTab(0, "Test"); - m_pDoc->SetExpandRefs(true); // turn on automatic range expansion. bool bInserted = m_pDoc->InsertNewRangeName("MyRange", ScAddress(0,0,0), "$A$1:$A$3"); CPPUNIT_ASSERT(bInserted); |