summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorkerem <hallackerem@gmail.com>2017-01-07 00:57:15 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2017-01-08 03:38:16 +0000
commit4d968302479531f7b9ba0f9c35b2efe0dbe39f50 (patch)
tree98e42977fc6fa15e8fc1f7c2c04ec57c3b24b3ff /sc
parentd1bad9c12d61c9f662abe6439b87a057bb54c8ca (diff)
tdf#90290 use custom asserter in ucalc_sharedformula.cxx
Change-Id: I4a27412167beaddee55cdcae2724030bbc22ec04 Reviewed-on: https://gerrit.libreoffice.org/32800 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/qa/unit/ucalc_sharedformula.cxx209
1 files changed, 69 insertions, 140 deletions
diff --git a/sc/qa/unit/ucalc_sharedformula.cxx b/sc/qa/unit/ucalc_sharedformula.cxx
index a66a09302667..f5e03c73a974 100644
--- a/sc/qa/unit/ucalc_sharedformula.cxx
+++ b/sc/qa/unit/ucalc_sharedformula.cxx
@@ -286,12 +286,9 @@ void Test::testSharedFormulasRefUpdate()
insertRangeData(m_pDoc, ScAddress(1,0,0), pData, SAL_N_ELEMENTS(pData));
}
- 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");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,0,0), "A10", "Wrong formula in B1");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,1,0), "A11", "Wrong formula in B2");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,2,0), "A12", "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());
@@ -300,12 +297,9 @@ void Test::testSharedFormulasRefUpdate()
// 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");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,0,0), "A10", "Wrong formula in B1");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,1,0), "C11", "Wrong formula in B2");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,2,0), "A12", "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());
@@ -317,12 +311,9 @@ void Test::testSharedFormulasRefUpdate()
// Delete 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");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,0,0), "A10", "Wrong formula in B1");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,1,0), "A11", "Wrong formula in B2");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,2,0), "A12", "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());
@@ -331,12 +322,9 @@ void Test::testSharedFormulasRefUpdate()
// Insert cells over A11:A12 and shift down.
m_pDoc->InsertRow(ScRange(0,10,0,0,11,0));
- if (!checkFormula(*m_pDoc, ScAddress(1,0,0), "A10"))
- CPPUNIT_FAIL("Wrong formula in B1");
- if (!checkFormula(*m_pDoc, ScAddress(1,1,0), "A13"))
- CPPUNIT_FAIL("Wrong formula in B2");
- if (!checkFormula(*m_pDoc, ScAddress(1,2,0), "A14"))
- CPPUNIT_FAIL("Wrong formula in B3");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,0,0), "A10", "Wrong formula in B1");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,1,0), "A13", "Wrong formula in B2");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,2,0), "A14", "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());
@@ -348,12 +336,9 @@ void Test::testSharedFormulasRefUpdate()
// Delete A11:A12 to bring it back to the way it was.
m_pDoc->DeleteRow(ScRange(0,10,0,0,11,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");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,0,0), "A10", "Wrong formula in B1");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,1,0), "A11", "Wrong formula in B2");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,2,0), "A12", "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());
@@ -362,12 +347,9 @@ void Test::testSharedFormulasRefUpdate()
// Insert cells over A11:B11 to shift to right again.
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");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,0,0), "A10", "Wrong formula in B1");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,1,0), "C11", "Wrong formula in B2");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,2,0), "A12", "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());
@@ -378,12 +360,9 @@ void Test::testSharedFormulasRefUpdate()
// Insert cells over A12:B12 to shift to right.
m_pDoc->InsertCol(ScRange(0,11,0,1,11,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), "C12"))
- CPPUNIT_FAIL("Wrong formula in B3");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,0,0), "A10", "Wrong formula in B1");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,1,0), "C11", "Wrong formula in B2");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,2,0), "C12", "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());
@@ -395,12 +374,9 @@ void Test::testSharedFormulasRefUpdate()
// Insert cells over A10:B10 to shift to right.
m_pDoc->InsertCol(ScRange(0,9,0,1,9,0));
- if (!checkFormula(*m_pDoc, ScAddress(1,0,0), "C10"))
- 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), "C12"))
- CPPUNIT_FAIL("Wrong formula in B3");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,0,0), "C10", "Wrong formula in B1");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,1,0), "C11", "Wrong formula in B2");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,2,0), "C12", "Wrong formula in B3");
// B1:B3 should be now grouped.
pFC = m_pDoc->GetFormulaCell(ScAddress(1,0,0));
@@ -564,12 +540,9 @@ void Test::testSharedFormulasRefUpdateRange()
insertRangeData(m_pDoc, ScAddress(1,2,0), pData, SAL_N_ELEMENTS(pData));
}
- if (!checkFormula(*m_pDoc, ScAddress(1,2,0), "SUM($A$3:$A$5)"))
- CPPUNIT_FAIL("Wrong formula");
- if (!checkFormula(*m_pDoc, ScAddress(1,3,0), "SUM($A$3:$A$5)"))
- CPPUNIT_FAIL("Wrong formula");
- if (!checkFormula(*m_pDoc, ScAddress(1,4,0), "SUM($A$3:$A$5)"))
- CPPUNIT_FAIL("Wrong formula");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,2,0), "SUM($A$3:$A$5)", "Wrong formula");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,3,0), "SUM($A$3:$A$5)", "Wrong formula");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,4,0), "SUM($A$3:$A$5)", "Wrong formula");
// B3:B5 should be shared.
const ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1,2,0));
@@ -593,12 +566,9 @@ void Test::testSharedFormulasRefUpdateRange()
CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(4), pFC->GetSharedTopRow());
CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(3), pFC->GetSharedLength());
- if (!checkFormula(*m_pDoc, ScAddress(1,4,0), "SUM($A$5:$A$7)"))
- CPPUNIT_FAIL("Wrong formula");
- if (!checkFormula(*m_pDoc, ScAddress(1,5,0), "SUM($A$5:$A$7)"))
- CPPUNIT_FAIL("Wrong formula");
- if (!checkFormula(*m_pDoc, ScAddress(1,6,0), "SUM($A$5:$A$7)"))
- CPPUNIT_FAIL("Wrong formula");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,4,0), "SUM($A$5:$A$7)", "Wrong formula");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,5,0), "SUM($A$5:$A$7)", "Wrong formula");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,6,0), "SUM($A$5:$A$7)", "Wrong formula");
m_pDoc->DeleteTab(0);
}
@@ -775,14 +745,10 @@ void Test::testSharedFormulasRefUpdateExternal()
CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(0,9,0)));
// Check the formulas too.
- if (!checkFormula(*m_pDoc, ScAddress(0,6,0), "'file:///extdata.fake'#$Data.A1"))
- CPPUNIT_FAIL("Wrong formula!");
- if (!checkFormula(*m_pDoc, ScAddress(0,7,0), "'file:///extdata.fake'#$Data.A2"))
- CPPUNIT_FAIL("Wrong formula!");
- if (!checkFormula(*m_pDoc, ScAddress(0,8,0), "'file:///extdata.fake'#$Data.A3"))
- CPPUNIT_FAIL("Wrong formula!");
- if (!checkFormula(*m_pDoc, ScAddress(0,9,0), "COUNTA('file:///extdata.fake'#$Data.A1:A3)"))
- CPPUNIT_FAIL("Wrong formula!");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,6,0), "'file:///extdata.fake'#$Data.A1", "Wrong formula!");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,7,0), "'file:///extdata.fake'#$Data.A2", "Wrong formula!");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,8,0), "'file:///extdata.fake'#$Data.A3", "Wrong formula!");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,9,0), "COUNTA('file:///extdata.fake'#$Data.A1:A3)", "Wrong formula!");
// Delete rows 1 and 2. This should not change the references in the formula cells below.
ScDocFunc& rDocFunc = getDocShell().GetDocFunc();
@@ -791,38 +757,26 @@ void Test::testSharedFormulasRefUpdateExternal()
rDocFunc.DeleteCells(ScRange(0,0,0,MAXCOL,1,0), &aMark, DEL_CELLSUP, true);
// Check the shifted formula cells now in A5:A8.
- if (!checkFormula(*m_pDoc, ScAddress(0,4,0), "'file:///extdata.fake'#$Data.A1"))
- CPPUNIT_FAIL("Wrong formula!");
- if (!checkFormula(*m_pDoc, ScAddress(0,5,0), "'file:///extdata.fake'#$Data.A2"))
- CPPUNIT_FAIL("Wrong formula!");
- if (!checkFormula(*m_pDoc, ScAddress(0,6,0), "'file:///extdata.fake'#$Data.A3"))
- CPPUNIT_FAIL("Wrong formula!");
- if (!checkFormula(*m_pDoc, ScAddress(0,7,0), "COUNTA('file:///extdata.fake'#$Data.A1:A3)"))
- CPPUNIT_FAIL("Wrong formula!");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,4,0), "'file:///extdata.fake'#$Data.A1", "Wrong formula!");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,5,0), "'file:///extdata.fake'#$Data.A2", "Wrong formula!");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,6,0), "'file:///extdata.fake'#$Data.A3", "Wrong formula!");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,7,0), "COUNTA('file:///extdata.fake'#$Data.A1:A3)", "Wrong formula!");
// Undo and check the formulas again.
SfxUndoManager* pUndoMgr = m_pDoc->GetUndoManager();
CPPUNIT_ASSERT(pUndoMgr);
pUndoMgr->Undo();
- if (!checkFormula(*m_pDoc, ScAddress(0,6,0), "'file:///extdata.fake'#$Data.A1"))
- CPPUNIT_FAIL("Wrong formula!");
- if (!checkFormula(*m_pDoc, ScAddress(0,7,0), "'file:///extdata.fake'#$Data.A2"))
- CPPUNIT_FAIL("Wrong formula!");
- if (!checkFormula(*m_pDoc, ScAddress(0,8,0), "'file:///extdata.fake'#$Data.A3"))
- CPPUNIT_FAIL("Wrong formula!");
- if (!checkFormula(*m_pDoc, ScAddress(0,9,0), "COUNTA('file:///extdata.fake'#$Data.A1:A3)"))
- CPPUNIT_FAIL("Wrong formula!");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,6,0), "'file:///extdata.fake'#$Data.A1", "Wrong formula!");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,7,0), "'file:///extdata.fake'#$Data.A2", "Wrong formula!");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,8,0), "'file:///extdata.fake'#$Data.A3", "Wrong formula!");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,9,0), "COUNTA('file:///extdata.fake'#$Data.A1:A3)", "Wrong formula!");
// Redo the row deletion and check the formulas again.
pUndoMgr->Redo();
- if (!checkFormula(*m_pDoc, ScAddress(0,4,0), "'file:///extdata.fake'#$Data.A1"))
- CPPUNIT_FAIL("Wrong formula!");
- if (!checkFormula(*m_pDoc, ScAddress(0,5,0), "'file:///extdata.fake'#$Data.A2"))
- CPPUNIT_FAIL("Wrong formula!");
- if (!checkFormula(*m_pDoc, ScAddress(0,6,0), "'file:///extdata.fake'#$Data.A3"))
- CPPUNIT_FAIL("Wrong formula!");
- if (!checkFormula(*m_pDoc, ScAddress(0,7,0), "COUNTA('file:///extdata.fake'#$Data.A1:A3)"))
- CPPUNIT_FAIL("Wrong formula!");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,4,0), "'file:///extdata.fake'#$Data.A1", "Wrong formula!");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,5,0), "'file:///extdata.fake'#$Data.A2", "Wrong formula!");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,6,0), "'file:///extdata.fake'#$Data.A3", "Wrong formula!");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,7,0), "COUNTA('file:///extdata.fake'#$Data.A1:A3)", "Wrong formula!");
xExtDocSh->DoClose();
@@ -1157,8 +1111,7 @@ void Test::testSharedFormulasRefUpdateMoveSheets()
for (SCROW i = 0; i <= 7; ++i)
{
CPPUNIT_ASSERT_EQUAL(static_cast<double>(i+1), m_pDoc->GetValue(ScAddress(0,i,1)));
- if (!checkFormula(*m_pDoc, ScAddress(0,i,1), "Sheet2!RC"))
- CPPUNIT_FAIL("Wrong formula expression.");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,i,1), "Sheet2!RC", "Wrong formula expression.");
}
// Insert a new sheet at the left end.
@@ -1176,8 +1129,7 @@ void Test::testSharedFormulasRefUpdateMoveSheets()
for (SCROW i = 0; i <= 7; ++i)
{
CPPUNIT_ASSERT_EQUAL(static_cast<double>(i+1), m_pDoc->GetValue(ScAddress(0,i,2)));
- if (!checkFormula(*m_pDoc, ScAddress(0,i,2), "Sheet2!RC"))
- CPPUNIT_FAIL("Wrong formula expression.");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,i,2), "Sheet2!RC", "Wrong formula expression.");
}
// Delete Sheet4.
@@ -1194,8 +1146,7 @@ void Test::testSharedFormulasRefUpdateMoveSheets()
for (SCROW i = 0; i <= 7; ++i)
{
CPPUNIT_ASSERT_EQUAL(static_cast<double>(i+1), m_pDoc->GetValue(ScAddress(0,i,1)));
- if (!checkFormula(*m_pDoc, ScAddress(0,i,1), "Sheet2!RC"))
- CPPUNIT_FAIL("Wrong formula expression.");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,i,1), "Sheet2!RC", "Wrong formula expression.");
}
m_pDoc->DeleteTab(2);
@@ -1223,11 +1174,8 @@ void Test::testSharedFormulasRefUpdateCopySheets()
// Copy Sheet1 and insert the copied sheet before the current Sheet1 position.
m_pDoc->CopyTab(0, 0);
- if (!checkFormula(*m_pDoc, ScAddress(0,0,0), "$Sheet2.A1"))
- CPPUNIT_FAIL("Wrong formula");
-
- if (!checkFormula(*m_pDoc, ScAddress(0,1,0), "$Sheet2.A2"))
- CPPUNIT_FAIL("Wrong formula");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,0,0), "$Sheet2.A1", "Wrong formula");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,1,0), "$Sheet2.A2", "Wrong formula");
// Check the values on the copied sheet.
CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(0,0,0)));
@@ -1264,35 +1212,26 @@ void Test::testSharedFormulasRefUpdateDeleteSheets()
CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(0,1,0)));
CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(0,2,0)));
- if (!checkFormula(*m_pDoc, ScAddress(0,0,0), "Sheet2.B2"))
- CPPUNIT_FAIL("Wrong formula");
- if (!checkFormula(*m_pDoc, ScAddress(0,1,0), "Sheet2.B3"))
- CPPUNIT_FAIL("Wrong formula");
- if (!checkFormula(*m_pDoc, ScAddress(0,2,0), "Sheet2.B4"))
- CPPUNIT_FAIL("Wrong formula");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,0,0), "Sheet2.B2", "Wrong formula");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,1,0), "Sheet2.B3", "Wrong formula");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,2,0), "Sheet2.B4", "Wrong formula");
// Delete Sheet2.
ScDocFunc& rFunc = getDocShell().GetDocFunc();
rFunc.DeleteTable(1, true, true);
- if (!checkFormula(*m_pDoc, ScAddress(0,0,0), "#REF!.B2"))
- CPPUNIT_FAIL("Wrong formula");
- if (!checkFormula(*m_pDoc, ScAddress(0,1,0), "#REF!.B3"))
- CPPUNIT_FAIL("Wrong formula");
- if (!checkFormula(*m_pDoc, ScAddress(0,2,0), "#REF!.B4"))
- CPPUNIT_FAIL("Wrong formula");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,0,0), "#REF!.B2", "Wrong formula");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,1,0), "#REF!.B3", "Wrong formula");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,2,0), "#REF!.B4", "Wrong formula");
// Undo the deletion and make sure the formulas are back to the way they were.
SfxUndoManager* pUndoMgr = m_pDoc->GetUndoManager();
CPPUNIT_ASSERT(pUndoMgr);
pUndoMgr->Undo();
- if (!checkFormula(*m_pDoc, ScAddress(0,0,0), "Sheet2.B2"))
- CPPUNIT_FAIL("Wrong formula");
- if (!checkFormula(*m_pDoc, ScAddress(0,1,0), "Sheet2.B3"))
- CPPUNIT_FAIL("Wrong formula");
- if (!checkFormula(*m_pDoc, ScAddress(0,2,0), "Sheet2.B4"))
- CPPUNIT_FAIL("Wrong formula");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,0,0), "Sheet2.B2", "Wrong formula");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,1,0), "Sheet2.B3", "Wrong formula");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,2,0), "Sheet2.B4", "Wrong formula");
// TODO: We can't test redo yet as ScUndoDeleteTab::Redo() relies on
// view shell to do its thing.
@@ -1391,11 +1330,8 @@ void Test::testSharedFormulaInsertColumn()
// Insert a single column at Column F. This used to crash before fdo#74041.
m_pDoc->InsertCol(ScRange(5,0,0,5,MAXROW,0));
- if (!checkFormula(*m_pDoc, ScAddress(8,1,0), "H3*B3"))
- CPPUNIT_FAIL("Wrong formula!");
-
- if (!checkFormula(*m_pDoc, ScAddress(8,2,0), "H4*B4"))
- CPPUNIT_FAIL("Wrong formula!");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(8,1,0), "H3*B3", "Wrong formula!");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(8,2,0), "H4*B4", "Wrong formula!");
m_pDoc->DeleteTab(0);
}
@@ -1588,20 +1524,13 @@ void Test::testSharedFormulaUpdateOnNamedRangeChange()
rFunc.ModifyAllRangeNames(aNewNames);
// Check to make sure all displayed formulas are still good.
- if (!checkFormula(*m_pDoc, ScAddress(1,0,0), "SUM(MyRange)"))
- CPPUNIT_FAIL("Wrong formula!");
- if (!checkFormula(*m_pDoc, ScAddress(1,1,0), "SUM(MyRange)"))
- CPPUNIT_FAIL("Wrong formula!");
- if (!checkFormula(*m_pDoc, ScAddress(1,2,0), "SUM(MyRange)"))
- CPPUNIT_FAIL("Wrong formula!");
- if (!checkFormula(*m_pDoc, ScAddress(1,4,0), "ROW()"))
- CPPUNIT_FAIL("Wrong formula!");
- if (!checkFormula(*m_pDoc, ScAddress(1,6,0), "ROW()"))
- CPPUNIT_FAIL("Wrong formula!");
- if (!checkFormula(*m_pDoc, ScAddress(1,7,0), "ROW()"))
- CPPUNIT_FAIL("Wrong formula!");
- if (!checkFormula(*m_pDoc, ScAddress(2,0,0), "AVERAGE(MyRange)"))
- CPPUNIT_FAIL("Wrong formula!");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,0,0), "SUM(MyRange)", "Wrong formula!");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,1,0), "SUM(MyRange)", "Wrong formula!");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,2,0), "SUM(MyRange)", "Wrong formula!");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,4,0), "ROW()", "Wrong formula!");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,6,0), "ROW()", "Wrong formula!");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,7,0), "ROW()", "Wrong formula!");
+ ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2,0,0), "AVERAGE(MyRange)", "Wrong formula!");
// Check the calculation results as well.
CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(ScAddress(1,0,0)));