diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-11-21 16:08:12 +0100 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-11-22 15:26:35 +0100 |
commit | 41bc8bb0cd4a5b92c7e7fc0080c6e3fa5650aa01 (patch) | |
tree | 3651171eae58c93385a3f3fdc64140f1b845f3c0 /sc | |
parent | 792e41314f321f54b3b2fc4d01c8b62a3b704e9e (diff) |
sc: drop ASSERT_FORMULA_EQUAL
Unify the code and use GetFormula everywhere.
No need to define a specific assertion when
we can use OUString comparison instead
Change-Id: I7cd6f16bb32d6a659cac4e656bd4465393533cb5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143094
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/unit/bugfix-test.cxx | 3 | ||||
-rw-r--r-- | sc/qa/unit/helper/qahelper.cxx | 22 | ||||
-rw-r--r-- | sc/qa/unit/helper/qahelper.hxx | 9 | ||||
-rw-r--r-- | sc/qa/unit/helper/shared_test_impl.hxx | 2 | ||||
-rw-r--r-- | sc/qa/unit/subsequent_export_test.cxx | 70 | ||||
-rw-r--r-- | sc/qa/unit/subsequent_export_test2.cxx | 20 | ||||
-rw-r--r-- | sc/qa/unit/subsequent_filters_test.cxx | 104 | ||||
-rw-r--r-- | sc/qa/unit/subsequent_filters_test2.cxx | 53 | ||||
-rw-r--r-- | sc/qa/unit/ucalc_copypaste.cxx | 39 | ||||
-rw-r--r-- | sc/qa/unit/ucalc_formula.cxx | 583 | ||||
-rw-r--r-- | sc/qa/unit/ucalc_sharedformula.cxx | 154 | ||||
-rw-r--r-- | sc/qa/unit/ucalc_sort.cxx | 100 |
12 files changed, 581 insertions, 578 deletions
diff --git a/sc/qa/unit/bugfix-test.cxx b/sc/qa/unit/bugfix-test.cxx index 4217ce8d49ad..7a5e4e2b73b4 100644 --- a/sc/qa/unit/bugfix-test.cxx +++ b/sc/qa/unit/bugfix-test.cxx @@ -430,7 +430,8 @@ void ScFiltersTest::testRhbz1390776() createScDoc("xml/rhbz1390776.xml"); ScDocument* pDoc = getScDoc(); - ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(0, 27, 0), "SUM(A18:A23)", "Wrong range"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong range", OUString("=SUM(A18:A23)"), + pDoc->GetFormula(0, 27, 0)); } void ScFiltersTest::testTdf104310() diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx index 6fd30e2398a4..6627bd5636da 100644 --- a/sc/qa/unit/helper/qahelper.cxx +++ b/sc/qa/unit/helper/qahelper.cxx @@ -676,28 +676,6 @@ void ScModelTestBase::miscRowHeightsTest( TestParam const * aTestValues, unsigne } } -std::string to_std_string(const OUString& rStr) -{ - return std::string(rStr.toUtf8().getStr()); -} - -void checkFormula(ScDocument& rDoc, const ScAddress& rPos, const char* expected, const char* msg, CppUnit::SourceLine const & sourceLine) -{ - ScTokenArray* pCode = getTokens(rDoc, rPos); - if (!pCode) - { - CppUnit::Asserter::fail("empty token array", sourceLine); - } - - OUString aFormula = toString(rDoc, rPos, *pCode, rDoc.GetGrammar()); - OUString aExpectedFormula = OUString::createFromAscii(expected); - if (aFormula != aExpectedFormula) - { - CppUnit::Asserter::failNotEqual(to_std_string(aExpectedFormula), - to_std_string(aFormula), sourceLine, CppUnit::AdditionalMessage(msg)); - } -} - ScRange ScSimpleBootstrapFixture::insertRangeData( ScDocument* pDoc, const ScAddress& rPos, const std::vector<std::vector<const char*>>& rData ) { diff --git a/sc/qa/unit/helper/qahelper.hxx b/sc/qa/unit/helper/qahelper.hxx index 9bdd10d405d5..91e3aed2b04f 100644 --- a/sc/qa/unit/helper/qahelper.hxx +++ b/sc/qa/unit/helper/qahelper.hxx @@ -258,15 +258,6 @@ private: #define ASSERT_DOUBLES_EQUAL_MESSAGE( message, expected, result ) \ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( (message), (expected), (result), 1e-14 ) -SCQAHELPER_DLLPUBLIC void checkFormula(ScDocument& rDoc, const ScAddress& rPos, - const char* expected, const char* msg, CppUnit::SourceLine const & sourceLine); - -#define ASSERT_FORMULA_EQUAL(doc, pos, expected, msg) \ - checkFormula(doc, pos, expected, msg, CPPUNIT_SOURCELINE()) - SCQAHELPER_DLLPUBLIC ScTokenArray* getTokens(ScDocument& rDoc, const ScAddress& rPos); -SCQAHELPER_DLLPUBLIC std::string to_std_string(const OUString& rStr); - - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/qa/unit/helper/shared_test_impl.hxx b/sc/qa/unit/helper/shared_test_impl.hxx index 33b6fe06a0f5..8dcb387df38b 100644 --- a/sc/qa/unit/helper/shared_test_impl.hxx +++ b/sc/qa/unit/helper/shared_test_impl.hxx @@ -289,7 +289,7 @@ void testCeilingFloor_Impl( ScDocument& rDoc ) static constexpr OUStringLiteral pORef = u"Sheet1.K1"; ScAddress aPos; aPos.Parse(pORef, rDoc); - ASSERT_FORMULA_EQUAL(rDoc, aPos, "AND(K3:K81)", "Wrong formula."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=AND(K3:K81)"), rDoc.GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); CPPUNIT_ASSERT_MESSAGE( OUString( pORef + " result is error.").toUtf8().getStr(), isFormulaWithoutError( rDoc, aPos)); CPPUNIT_ASSERT_EQUAL(1.0, rDoc.GetValue(aPos)); diff --git a/sc/qa/unit/subsequent_export_test.cxx b/sc/qa/unit/subsequent_export_test.cxx index 94e35146b729..195e97b69e7a 100644 --- a/sc/qa/unit/subsequent_export_test.cxx +++ b/sc/qa/unit/subsequent_export_test.cxx @@ -2057,7 +2057,8 @@ void ScExportTest::testFormulaRefSheetNameODS() sc::AutoCalcSwitch aACSwitch(*pDoc, true); // turn on auto calc. pDoc->SetString(ScAddress(1, 1, 0), "='90''s Data'.B2"); CPPUNIT_ASSERT_EQUAL(1.1, pDoc->GetValue(ScAddress(1, 1, 0))); - ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(1, 1, 0), "'90''s Data'.B2", "Wrong formula"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("='90''s Data'.B2"), + pDoc->GetFormula(1, 1, 0)); } // Now, save and reload this document. saveAndReload("calc8"); @@ -2065,7 +2066,8 @@ void ScExportTest::testFormulaRefSheetNameODS() ScDocument* pDoc = getScDoc(); pDoc->CalcAll(); CPPUNIT_ASSERT_EQUAL(1.1, pDoc->GetValue(ScAddress(1, 1, 0))); - ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(1, 1, 0), "'90''s Data'.B2", "Wrong formula"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("='90''s Data'.B2"), + pDoc->GetFormula(1, 1, 0)); } void ScExportTest::testCellValuesExportODS() @@ -2113,8 +2115,10 @@ void ScExportTest::testCellValuesExportODS() CPPUNIT_ASSERT_EQUAL(3.0, pDoc->GetValue(5, 0, 0)); // check formula - ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(4, 0, 0), "10*C1/4", "Wrong formula =10*C1/4"); - ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(7, 0, 0), "SUM(C1:F1)", "Wrong formula =SUM(C1:F1)"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula =10*C1/4", OUString("=10*C1/4"), + pDoc->GetFormula(4, 0, 0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula =SUM(C1:F1)", OUString("=SUM(C1:F1)"), + pDoc->GetFormula(7, 0, 0)); CPPUNIT_ASSERT_EQUAL(16.5, pDoc->GetValue(7, 0, 0)); // check string @@ -2133,7 +2137,8 @@ void ScExportTest::testCellValuesExportODS() //check contiguous values CPPUNIT_ASSERT_EQUAL(12.0, pDoc->GetValue(0, 5, 0)); CPPUNIT_ASSERT_EQUAL(OUString("a string"), pDoc->GetString(0, 6, 0)); - ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(0, 7, 0), "$A$6", "Wrong formula =$A$6"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula =$A$6", OUString("=$A$6"), + pDoc->GetFormula(0, 7, 0)); CPPUNIT_ASSERT_EQUAL(pDoc->GetValue(0, 5, 0), pDoc->GetValue(0, 7, 0)); } @@ -2319,16 +2324,22 @@ void ScExportTest::testFormulaReferenceXLS() ScDocument* pDoc = getScDoc(); - ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(3, 1, 0), "$A$2+$B$2+$C$2", "Wrong formula in D2"); - ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(3, 2, 0), "A3+B3+C3", "Wrong formula in D3"); - ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(3, 5, 0), "SUM($A$6:$C$6)", "Wrong formula in D6"); - ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(3, 6, 0), "SUM(A7:C7)", "Wrong formula in D7"); - ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(3, 9, 0), "$Two.$A$2+$Two.$B$2+$Two.$C$2", - "Wrong formula in D10"); - ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(3, 10, 0), "$Two.A3+$Two.B3+$Two.C3", - "Wrong formula in D11"); - ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(3, 13, 0), "MIN($Two.$A$2:$C$2)", "Wrong formula in D14"); - ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(3, 14, 0), "MAX($Two.A3:C3)", "Wrong formula in D15"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in D2", OUString("=$A$2+$B$2+$C$2"), + pDoc->GetFormula(3, 1, 0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in D3", OUString("=A3+B3+C3"), + pDoc->GetFormula(3, 2, 0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in D6", OUString("=SUM($A$6:$C$6)"), + pDoc->GetFormula(3, 5, 0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in D7", OUString("=SUM(A7:C7)"), + pDoc->GetFormula(3, 6, 0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in D10", OUString("=$Two.$A$2+$Two.$B$2+$Two.$C$2"), + pDoc->GetFormula(3, 9, 0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in D11", OUString("=$Two.A3+$Two.B3+$Two.C3"), + pDoc->GetFormula(3, 10, 0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in D14", OUString("=MIN($Two.$A$2:$C$2)"), + pDoc->GetFormula(3, 13, 0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in D15", OUString("=MAX($Two.A3:C3)"), + pDoc->GetFormula(3, 14, 0)); } void ScExportTest::testSheetProtectionXLSX() @@ -3501,23 +3512,14 @@ void ScExportTest::testSupBookVirtualPathXLS() ScDocument* pDoc = getScDoc(); - ScAddress aPos(0, 0, 0); - ScTokenArray* pCode = getTokens(*pDoc, aPos); - if (!pCode) - CppUnit::Asserter::fail("empty token array", CPPUNIT_SOURCELINE()); - - OUString aFormula = toString(*pDoc, aPos, *pCode, pDoc->GetGrammar()); + OUString aFormula = pDoc->GetFormula(0, 0, 0); #ifdef _WIN32 aFormula = OUString::Concat(aFormula.subView(0, 9)) + aFormula.subView(12); // strip drive letter, e.g. 'C:/' #endif - OUString aExpectedFormula = "'file:///home/timar/Documents/external.xls'#$Sheet1.A1"; - if (aFormula != aExpectedFormula) - { - CppUnit::Asserter::failNotEqual( - to_std_string(aExpectedFormula), to_std_string(aFormula), CPPUNIT_SOURCELINE(), - CppUnit::AdditionalMessage("Wrong SupBook VirtualPath URL")); - } + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "Wrong SupBook VirtualPath URL", + OUString("='file:///home/timar/Documents/external.xls'#$Sheet1.A1"), aFormula); } void ScExportTest::testLinkedGraphicRT() @@ -3708,19 +3710,23 @@ void ScExportTest::testRelativeNamedExpressionsXLS() // Sheet1:G3 ScAddress aPos(6, 2, 0); CPPUNIT_ASSERT_EQUAL(1.0, pDoc->GetValue(aPos)); - ASSERT_FORMULA_EQUAL(*pDoc, aPos, "single_cell_A3", nullptr); + CPPUNIT_ASSERT_EQUAL(OUString("=single_cell_A3"), + pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); // Sheet2:F6 aPos = ScAddress(5, 5, 1); CPPUNIT_ASSERT_EQUAL(18.0, pDoc->GetValue(aPos)); - ASSERT_FORMULA_EQUAL(*pDoc, aPos, "SUM(test_conflict)", nullptr); + CPPUNIT_ASSERT_EQUAL(OUString("=SUM(test_conflict)"), + pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); // Sheet2:H3 aPos = ScAddress(7, 2, 1); CPPUNIT_ASSERT_EQUAL(10.0, pDoc->GetValue(aPos)); - ASSERT_FORMULA_EQUAL(*pDoc, aPos, "single_global_A3", nullptr); + CPPUNIT_ASSERT_EQUAL(OUString("=single_global_A3"), + pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); // Sheet2:H6 aPos = ScAddress(7, 5, 1); CPPUNIT_ASSERT_EQUAL(75.0, pDoc->GetValue(aPos)); - ASSERT_FORMULA_EQUAL(*pDoc, aPos, "SUM(A6:F6)", nullptr); + CPPUNIT_ASSERT_EQUAL(OUString("=SUM(A6:F6)"), + pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); } void ScExportTest::testSheetTextBoxHyperlinkXLSX() diff --git a/sc/qa/unit/subsequent_export_test2.cxx b/sc/qa/unit/subsequent_export_test2.cxx index d69e2cab9edc..03f747e82b63 100644 --- a/sc/qa/unit/subsequent_export_test2.cxx +++ b/sc/qa/unit/subsequent_export_test2.cxx @@ -1060,9 +1060,9 @@ void ScExportTest2::testTdf105272() //Expected: Table1[[#This Row],[Total]]/Table1[[#This Row],['# Athletes]] //Actual : table1[[#this row],[total]]/table1[[#this row],['# athletes]] - ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(7, 3, 0), - "Table1[[#This Row],[Total]]/Table1[[#This Row],['# Athletes]]", - "Wrong formula"); + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "Wrong formula", OUString("=Table1[[#This Row],[Total]]/Table1[[#This Row],['# Athletes]]"), + pDoc->GetFormula(7, 3, 0)); } void ScExportTest2::testTdf118990() @@ -1076,13 +1076,15 @@ void ScExportTest2::testTdf118990() // file:///share/lookupsource.xlsx - which is incorrect, since it points to local filesystem // and not to Windows network share. - ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(0, 1, 0), - "VLOOKUP(B1,'file://192.168.1.1/share/lookupsource.xlsx'#$Sheet1.A1:B5,2)", - "Wrong Windows share (using host IP) URL in A2"); + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "Wrong Windows share (using host IP) URL in A2", + OUString("=VLOOKUP(B1,'file://192.168.1.1/share/lookupsource.xlsx'#$Sheet1.A1:B5,2)"), + pDoc->GetFormula(0, 1, 0)); - ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(0, 2, 0), - "VLOOKUP(B1,'file://NETWORKHOST/share/lookupsource.xlsx'#$Sheet1.A1:B5,2)", - "Wrong Windows share (using hostname) URL in A3"); + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "Wrong Windows share (using hostname) URL in A3", + OUString("=VLOOKUP(B1,'file://NETWORKHOST/share/lookupsource.xlsx'#$Sheet1.A1:B5,2)"), + pDoc->GetFormula(0, 2, 0)); } void ScExportTest2::testTdf121612() diff --git a/sc/qa/unit/subsequent_filters_test.cxx b/sc/qa/unit/subsequent_filters_test.cxx index ddb72bc64e37..f1dc06cce920 100644 --- a/sc/qa/unit/subsequent_filters_test.cxx +++ b/sc/qa/unit/subsequent_filters_test.cxx @@ -1734,29 +1734,37 @@ void ScFiltersTest::testDataTableMortgageXLS() // One-variable table - ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(3, 1, 0), "PMT(B3/12,B4,-B5)", "Wrong formula!"); - ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(3, 2, 0), "MULTIPLE.OPERATIONS(D$2,$B$3,$C3)", - "Wrong formula!"); - ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(3, 3, 0), "MULTIPLE.OPERATIONS(D$2,$B$3,$C4)", - "Wrong formula!"); - ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(3, 4, 0), "MULTIPLE.OPERATIONS(D$2,$B$3,$C5)", - "Wrong formula!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=PMT(B3/12,B4,-B5)"), + pDoc->GetFormula(3, 1, 0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=MULTIPLE.OPERATIONS(D$2,$B$3,$C3)"), + pDoc->GetFormula(3, 2, 0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=MULTIPLE.OPERATIONS(D$2,$B$3,$C4)"), + pDoc->GetFormula(3, 3, 0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=MULTIPLE.OPERATIONS(D$2,$B$3,$C5)"), + pDoc->GetFormula(3, 4, 0)); // Two-variable table - ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(2, 7, 0), "PMT(B9/12,B10,-B11)", "Wrong formula!"); - ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(3, 8, 0), "MULTIPLE.OPERATIONS($C$8,$B$9,$C9,$B$10,D$8)", - "Wrong formula!"); - ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(3, 9, 0), "MULTIPLE.OPERATIONS($C$8,$B$9,$C10,$B$10,D$8)", - "Wrong formula!"); - ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(3, 10, 0), - "MULTIPLE.OPERATIONS($C$8,$B$9,$C11,$B$10,D$8)", "Wrong formula!"); - ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(4, 8, 0), "MULTIPLE.OPERATIONS($C$8,$B$9,$C9,$B$10,E$8)", - "Wrong formula!"); - ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(4, 9, 0), "MULTIPLE.OPERATIONS($C$8,$B$9,$C10,$B$10,E$8)", - "Wrong formula!"); - ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(4, 10, 0), - "MULTIPLE.OPERATIONS($C$8,$B$9,$C11,$B$10,E$8)", "Wrong formula!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=PMT(B9/12,B10,-B11)"), + pDoc->GetFormula(2, 7, 0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", + OUString("=MULTIPLE.OPERATIONS($C$8,$B$9,$C9,$B$10,D$8)"), + pDoc->GetFormula(3, 8, 0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", + OUString("=MULTIPLE.OPERATIONS($C$8,$B$9,$C10,$B$10,D$8)"), + pDoc->GetFormula(3, 9, 0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", + OUString("=MULTIPLE.OPERATIONS($C$8,$B$9,$C11,$B$10,D$8)"), + pDoc->GetFormula(3, 10, 0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", + OUString("=MULTIPLE.OPERATIONS($C$8,$B$9,$C9,$B$10,E$8)"), + pDoc->GetFormula(4, 8, 0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", + OUString("=MULTIPLE.OPERATIONS($C$8,$B$9,$C10,$B$10,E$8)"), + pDoc->GetFormula(4, 9, 0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", + OUString("=MULTIPLE.OPERATIONS($C$8,$B$9,$C11,$B$10,E$8)"), + pDoc->GetFormula(4, 10, 0)); } void ScFiltersTest::testDataTableOneVarXLSX() @@ -1773,26 +1781,26 @@ void ScFiltersTest::testDataTableOneVarXLSX() // B5:B11 should have multiple operations formula cells. Just check the // top and bottom cells. - ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(1, 4, 0), "MULTIPLE.OPERATIONS(B$4,$A$2,$A5)", - "Wrong formula!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=MULTIPLE.OPERATIONS(B$4,$A$2,$A5)"), + pDoc->GetFormula(1, 4, 0)); CPPUNIT_ASSERT_EQUAL(2.0, pDoc->GetValue(ScAddress(1, 4, 0))); - ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(1, 10, 0), "MULTIPLE.OPERATIONS(B$4,$A$2,$A11)", - "Wrong formula!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=MULTIPLE.OPERATIONS(B$4,$A$2,$A11)"), + pDoc->GetFormula(1, 10, 0)); CPPUNIT_ASSERT_EQUAL(14.0, pDoc->GetValue(ScAddress(1, 10, 0))); // Likewise, E5:I5 should have multiple operations formula cells. Just // check the left- and right-most cells. - ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(4, 4, 0), "MULTIPLE.OPERATIONS($D5,$B$2,E$4)", - "Wrong formula!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=MULTIPLE.OPERATIONS($D5,$B$2,E$4)"), + pDoc->GetFormula(4, 4, 0)); CPPUNIT_ASSERT_EQUAL(10.0, pDoc->GetValue(ScAddress(4, 4, 0))); - ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(8, 4, 0), "MULTIPLE.OPERATIONS($D5,$B$2,I$4)", - "Wrong formula!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=MULTIPLE.OPERATIONS($D5,$B$2,I$4)"), + pDoc->GetFormula(8, 4, 0)); CPPUNIT_ASSERT_EQUAL(50.0, pDoc->GetValue(ScAddress(8, 4, 0))); } @@ -1811,13 +1819,15 @@ void ScFiltersTest::testDataTableMultiTableXLSX() // B4:M15 should have multiple operations formula cells. We'll just check // the top-left and bottom-right ones. - ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(1, 3, 0), "MULTIPLE.OPERATIONS($A$3,$E$1,$A4,$D$1,B$3)", - "Wrong formula!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", + OUString("=MULTIPLE.OPERATIONS($A$3,$E$1,$A4,$D$1,B$3)"), + pDoc->GetFormula(1, 3, 0)); CPPUNIT_ASSERT_EQUAL(1.0, pDoc->GetValue(ScAddress(1, 3, 0))); - ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(12, 14, 0), - "MULTIPLE.OPERATIONS($A$3,$E$1,$A15,$D$1,M$3)", "Wrong formula!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", + OUString("=MULTIPLE.OPERATIONS($A$3,$E$1,$A15,$D$1,M$3)"), + pDoc->GetFormula(12, 14, 0)); CPPUNIT_ASSERT_EQUAL(144.0, pDoc->GetValue(ScAddress(12, 14, 0))); } @@ -3186,16 +3196,16 @@ void ScFiltersTest::testSharedFormulaXLS() pDoc = getScDoc(); pDoc->CalcAll(); - ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(1, 0, 0), "A1*20", "Wrong formula."); - ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(1, 1, 0), "A2*20", "Wrong formula."); - ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(1, 2, 0), "A3*20", "Wrong formula."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=A1*20"), pDoc->GetFormula(1, 0, 0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=A2*20"), pDoc->GetFormula(1, 1, 0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=A3*20"), pDoc->GetFormula(1, 2, 0)); // There is an intentional gap at row 4. - ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(1, 4, 0), "A5*20", "Wrong formula."); - ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(1, 5, 0), "A6*20", "Wrong formula."); - ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(1, 6, 0), "A7*20", "Wrong formula."); - ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(1, 7, 0), "A8*20", "Wrong formula."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=A5*20"), pDoc->GetFormula(1, 4, 0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=A6*20"), pDoc->GetFormula(1, 5, 0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=A7*20"), pDoc->GetFormula(1, 6, 0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=A8*20"), pDoc->GetFormula(1, 7, 0)); // We re-group formula cells on load. Let's check that as well. @@ -3242,22 +3252,26 @@ void ScFiltersTest::testSharedFormulaRefUpdateXLSX() struct TestCase { - ScAddress aPos; + SCCOL nCol; + SCROW nRow; + SCTAB nTab; const char* pExpectedFormula; const char* pErrorMsg; }; TestCase aCases[4] = { - { ScAddress(1, 0, 0), "B29+1", "Wrong formula in B1" }, - { ScAddress(2, 0, 0), "C29+1", "Wrong formula in C1" }, - { ScAddress(3, 0, 0), "D29+1", "Wrong formula in D1" }, - { ScAddress(4, 0, 0), "E29+1", "Wrong formula in E1" }, + { 1, 0, 0, "=B29+1", "Wrong formula in B1" }, + { 2, 0, 0, "=C29+1", "Wrong formula in C1" }, + { 3, 0, 0, "=D29+1", "Wrong formula in D1" }, + { 4, 0, 0, "=E29+1", "Wrong formula in E1" }, }; for (size_t nIdx = 0; nIdx < 4; ++nIdx) { TestCase& rCase = aCases[nIdx]; - ASSERT_FORMULA_EQUAL(*pDoc, rCase.aPos, rCase.pExpectedFormula, rCase.pErrorMsg); + CPPUNIT_ASSERT_EQUAL_MESSAGE(rCase.pErrorMsg, + OUString::createFromAscii(rCase.pExpectedFormula), + pDoc->GetFormula(rCase.nCol, rCase.nRow, rCase.nTab)); } } diff --git a/sc/qa/unit/subsequent_filters_test2.cxx b/sc/qa/unit/subsequent_filters_test2.cxx index 9cd12d5a72d6..fbaef3eb464f 100644 --- a/sc/qa/unit/subsequent_filters_test2.cxx +++ b/sc/qa/unit/subsequent_filters_test2.cxx @@ -933,8 +933,9 @@ void ScFiltersTest2::testErrorOnExternalReferences() CPPUNIT_ASSERT(pFC); CPPUNIT_ASSERT_EQUAL(int(FormulaError::NoName), static_cast<int>(pFC->GetErrCode())); - ASSERT_FORMULA_EQUAL(*pDoc, ScAddress(0, 0, 0), "'file:///Path/To/FileA.ods'#$Sheet1.A1A", - "Formula changed"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Formula changed", + OUString("='file:///Path/To/FileA.ods'#$Sheet1.A1A"), + pDoc->GetFormula(0, 0, 0)); } void ScFiltersTest2::testTdf145054() @@ -1561,23 +1562,22 @@ void ScFiltersTest2::testTdf131536() createScDoc("xlsx/tdf131536.xlsx"); ScDocument* pDoc = getScDoc(); - ScAddress aPos(3, 9, 0); - CPPUNIT_ASSERT_EQUAL(1.0, pDoc->GetValue(aPos)); - ASSERT_FORMULA_EQUAL( - *pDoc, aPos, - "IF(D$4=\"-\",\"-\",MID(TEXT(INDEX($Comparison.$I:$J,$Comparison.$A5,$Comparison.D$2),\"\")" - ",2,4)" - "=RIGHT(TEXT(INDEX($Comparison.$L:$Z,$Comparison.$A5,$Comparison.D$4),\"\"),4))", - nullptr); - - ScAddress aPos2(4, 9, 0); - CPPUNIT_ASSERT_EQUAL(1.0, pDoc->GetValue(aPos2)); - ASSERT_FORMULA_EQUAL( - *pDoc, aPos2, - "IF(D$4=\"-\",\"-\",MID(TEXT(INDEX($Comparison.$I:$J,$Comparison.$A5,$Comparison.D$2)," - "\"0\"),2,4)" - "=RIGHT(TEXT(INDEX($Comparison.$L:$Z,$Comparison.$A5,$Comparison.D$4),\"0\"),4))", - nullptr); + CPPUNIT_ASSERT_EQUAL(1.0, pDoc->GetValue(3, 9, 0)); + CPPUNIT_ASSERT_EQUAL( + OUString( + "=IF(D$4=\"-\",\"-\",MID(TEXT(INDEX($Comparison.$I:$J,$Comparison.$A5,$Comparison.D$2)," + "\"\")" + ",2,4)" + "=RIGHT(TEXT(INDEX($Comparison.$L:$Z,$Comparison.$A5,$Comparison.D$4),\"\"),4))"), + pDoc->GetFormula(3, 9, 0)); + + CPPUNIT_ASSERT_EQUAL(1.0, pDoc->GetValue(4, 9, 0)); + CPPUNIT_ASSERT_EQUAL( + OUString( + "=IF(D$4=\"-\",\"-\",MID(TEXT(INDEX($Comparison.$I:$J,$Comparison.$A5,$Comparison.D$2)," + "\"0\"),2,4)" + "=RIGHT(TEXT(INDEX($Comparison.$L:$Z,$Comparison.$A5,$Comparison.D$4),\"0\"),4))"), + pDoc->GetFormula(4, 9, 0)); } void ScFiltersTest2::testTdf130583() @@ -1647,12 +1647,14 @@ void ScFiltersTest2::testNamedExpressionsXLSXML() // A7 ScAddress aPos(0, 6, 0); CPPUNIT_ASSERT_EQUAL(15.0, pDoc->GetValue(aPos)); - ASSERT_FORMULA_EQUAL(*pDoc, aPos, "SUM(MyRange)", nullptr); + CPPUNIT_ASSERT_EQUAL(OUString("=SUM(MyRange)"), + pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); // B7 aPos.IncCol(); CPPUNIT_ASSERT_EQUAL(55.0, pDoc->GetValue(aPos)); - ASSERT_FORMULA_EQUAL(*pDoc, aPos, "SUM(MyRange2)", nullptr); + CPPUNIT_ASSERT_EQUAL(OUString("=SUM(MyRange2)"), + pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); const ScRangeData* pRD = pDoc->GetRangeName()->findByUpperName("MYRANGE"); CPPUNIT_ASSERT(pRD); @@ -1669,12 +1671,14 @@ void ScFiltersTest2::testNamedExpressionsXLSXML() // A7 on Sheet1 ScAddress aPos(0, 6, 0); CPPUNIT_ASSERT_EQUAL(27.0, pDoc->GetValue(aPos)); - ASSERT_FORMULA_EQUAL(*pDoc, aPos, "SUM(MyRange)", nullptr); + CPPUNIT_ASSERT_EQUAL(OUString("=SUM(MyRange)"), + pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); // A7 on Sheet2 aPos.IncTab(); CPPUNIT_ASSERT_EQUAL(74.0, pDoc->GetValue(aPos)); - ASSERT_FORMULA_EQUAL(*pDoc, aPos, "SUM(MyRange)", nullptr); + CPPUNIT_ASSERT_EQUAL(OUString("=SUM(MyRange)"), + pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); const ScRangeName* pRN = pDoc->GetRangeName(0); CPPUNIT_ASSERT(pRN); @@ -1714,7 +1718,8 @@ void ScFiltersTest2::testEmptyRowsXLSXML() ScAddress aPos; aPos.Parse("B9", *pDoc); - ASSERT_FORMULA_EQUAL(*pDoc, aPos, "SUM(B4:B8)", nullptr); + CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B4:B8)"), + pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); } void ScFiltersTest2::testBorderDirectionsXLSXML() diff --git a/sc/qa/unit/ucalc_copypaste.cxx b/sc/qa/unit/ucalc_copypaste.cxx index 87b9416086ff..60795656b299 100644 --- a/sc/qa/unit/ucalc_copypaste.cxx +++ b/sc/qa/unit/ucalc_copypaste.cxx @@ -9706,19 +9706,20 @@ void TestCopyPaste::testCutPasteRefUndo() &aClipDoc); CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(0, 1, 0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0, 1, 0), "C2", "A2 should be referencing C2."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("A2 should be referencing C2.", OUString("=C2"), + m_pDoc->GetFormula(0, 1, 0)); // At this point, the ref undo document should contain a formula cell at A2 that references B2. - ASSERT_FORMULA_EQUAL(*pUndoDoc, ScAddress(0, 1, 0), "B2", - "A2 in the undo document should be referencing B2."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("A2 in the undo document should be referencing B2.", + OUString("=B2"), pUndoDoc->GetFormula(0, 1, 0)); ScUndoPaste aUndo(m_xDocShell.get(), ScRange(2, 1, 0), aMark, std::move(pUndoDoc), nullptr, InsertDeleteFlags::CONTENTS, nullptr, false, nullptr); aUndo.Undo(); // Now A2 should be referencing B2 once again. - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0, 1, 0), "B2", - "A2 should be referencing B2 after undo."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("A2 should be referencing B2 after undo.", OUString("=B2"), + m_pDoc->GetFormula(0, 1, 0)); m_pDoc->DeleteTab(0); } @@ -9848,8 +9849,9 @@ void TestCopyPaste::testMoveRefBetweenSheets() CPPUNIT_ASSERT_EQUAL(30.0, m_pDoc->GetValue(ScAddress(0, 2, 0))); // These formulas should not display the sheet name. - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0, 1, 0), "A1", "Wrong formula!"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0, 2, 0), "SUM(A1:C1)", "Wrong formula!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=A1"), m_pDoc->GetFormula(0, 1, 0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=SUM(A1:C1)"), + m_pDoc->GetFormula(0, 2, 0)); // Move Test1.A2:A3 to Test2.A2:A3. ScDocFunc& rFunc = m_xDocShell->GetDocFunc(); @@ -9863,8 +9865,10 @@ void TestCopyPaste::testMoveRefBetweenSheets() ASSERT_DOUBLES_EQUAL(30.0, m_pDoc->GetValue(ScAddress(0, 2, 1))); // The reference in the pasted formula should display sheet name after the move. - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0, 1, 1), "Test1.A1", "Wrong formula!"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0, 2, 1), "SUM(Test1.A1:C1)", "Wrong formula!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=Test1.A1"), + m_pDoc->GetFormula(0, 1, 1)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=SUM(Test1.A1:C1)"), + m_pDoc->GetFormula(0, 2, 1)); m_pDoc->DeleteTab(1); m_pDoc->DeleteTab(0); @@ -10174,7 +10178,8 @@ void TestCopyPaste::testCopyPasteMixedReferenceFormula() // Insert formula to A1 with mixed relative/absolute addressing. m_pDoc->SetString(0, 0, 0, "=SUM(B:$C)"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0, 0, 0), "SUM(B:$C)", "Wrong formula."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=SUM(B:$C)"), + m_pDoc->GetFormula(0, 0, 0)); CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(0, 0, 0)); // Copy formula in A1 to clipboard. @@ -10185,15 +10190,16 @@ void TestCopyPaste::testCopyPasteMixedReferenceFormula() // Paste formula to B1. aRange = ScAddress(1, 0, 0); pasteFromClip(m_pDoc, aRange, &aClipDoc); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1, 0, 0), "SUM(C:$C)", "Wrong formula."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=SUM(C:$C)"), + m_pDoc->GetFormula(1, 0, 0)); CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(0, 0, 0)); CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(1, 0, 0)); // Paste formula to C1. All three results now must be circular reference. aRange = ScAddress(2, 0, 0); pasteFromClip(m_pDoc, aRange, &aClipDoc); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2, 0, 0), "SUM($C:D)", - "Wrong formula."); // reference put in order + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=SUM($C:D)"), + m_pDoc->GetFormula(2, 0, 0)); // reference put in order CPPUNIT_ASSERT_EQUAL(OUString("Err:522"), m_pDoc->GetString(0, 0, 0)); CPPUNIT_ASSERT_EQUAL(OUString("Err:522"), m_pDoc->GetString(1, 0, 0)); CPPUNIT_ASSERT_EQUAL(OUString("Err:522"), m_pDoc->GetString(2, 0, 0)); @@ -10358,7 +10364,8 @@ void TestCopyPaste::testTdf68976() // Without the fix in place, this would have failed with // - Expected: =$A$1 // - Actual : =$B$4 - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0, 1, nTab), "$A$1", "Wrong formula"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=$A$1"), + m_pDoc->GetFormula(0, 1, nTab)); // Without the fix in place, this would have failed with // - Expected: 1 // - Actual : 1000 @@ -10405,7 +10412,7 @@ void TestCopyPaste::testTdf71058() // Without the fix in place, this would have failed with // - Expected: =E6 // - Actual : =C4 - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2, 2, nTab), "E6", "Wrong formula"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=E6"), m_pDoc->GetFormula(2, 2, nTab)); // Without the fix in place, this would have failed with // - Expected: 1 // - Actual : 0 @@ -10414,7 +10421,7 @@ void TestCopyPaste::testTdf71058() // Without the fix in place, this would have failed with // - Expected: =E7 // - Actual : =D4 - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(3, 2, nTab), "E7", "Wrong formula"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=E7"), m_pDoc->GetFormula(3, 2, nTab)); // Without the fix in place, this would have failed with // - Expected: 2 // - Actual : 0 diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx index 0a1abe05c2f5..dc21cb16c266 100644 --- a/sc/qa/unit/ucalc_formula.cxx +++ b/sc/qa/unit/ucalc_formula.cxx @@ -636,18 +636,17 @@ void TestFormula::testFormulaParseReference() // Make sure the formula input and output match. { const char* aChecks[] = { - "'90''s Music'.B12", - "'90''s and 70''s'.$AB$100", - "'All Others'.Z$100", - "NoQuote.$C111" + "='90''s Music'.B12", + "='90''s and 70''s'.$AB$100", + "='All Others'.Z$100", + "=NoQuote.$C111" }; for (size_t i = 0; i < SAL_N_ELEMENTS(aChecks); ++i) { // Use the 'Dummy' sheet for this. - OUString aInput = "=" + OUString::createFromAscii(aChecks[i]); - m_pDoc->SetString(ScAddress(0,0,0), aInput); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,0,0), aChecks[i], "Wrong formula"); + m_pDoc->SetString(ScAddress(0,0,0), OUString::createFromAscii(aChecks[i])); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString::createFromAscii(aChecks[i]), m_pDoc->GetFormula(0,0,0)); } } @@ -819,32 +818,32 @@ void TestFormula::testFormulaParseReference() // Check for reference input conversion to and display string of entire column/row. { const char* row1048576Checks[][2] = { - { "=B:B", "B:B" }, - { "=B1:B1048576", "B:B" }, - { "=B1:B$1048576", "B1:B$1048576" }, - { "=B$1:B1048576", "B$1:B1048576" }, - { "=B$1:B$1048576", "B:B" } + { "=B:B", "=B:B" }, + { "=B1:B1048576", "=B:B" }, + { "=B1:B$1048576", "=B1:B$1048576" }, + { "=B$1:B1048576", "=B$1:B1048576" }, + { "=B$1:B$1048576", "=B:B" } }; const char* row16777216Checks[][2] = { - { "=B:B", "B:B" }, - { "=B1:B16777216", "B:B" }, - { "=B1:B$16777216", "B1:B$16777216" }, - { "=B$1:B16777216", "B$1:B16777216" }, - { "=B$1:B$16777216", "B:B" } + { "=B:B", "=B:B" }, + { "=B1:B16777216", "=B:B" }, + { "=B1:B$16777216", "=B1:B$16777216" }, + { "=B$1:B16777216", "=B$1:B16777216" }, + { "=B$1:B$16777216", "=B:B" } }; const char* col1024Checks[][2] = { - { "=2:2", "2:2" }, - { "=A2:AMJ2", "2:2" }, - { "=A2:$AMJ2", "A2:$AMJ2" }, - { "=$A2:AMJ2", "$A2:AMJ2" }, - { "=$A2:$AMJ2", "2:2" } + { "=2:2", "=2:2" }, + { "=A2:AMJ2", "=2:2" }, + { "=A2:$AMJ2", "=A2:$AMJ2" }, + { "=$A2:AMJ2", "=$A2:AMJ2" }, + { "=$A2:$AMJ2", "=2:2" } }; const char* col16384Checks[][2] = { - { "=2:2", "2:2" }, - { "=A2:XFD2", "2:2" }, - { "=A2:$XFD2", "A2:$XFD2" }, - { "=$A2:XFD2", "$A2:XFD2" }, - { "=$A2:$XFD2", "2:2" } + { "=2:2", "=2:2" }, + { "=A2:XFD2", "=2:2" }, + { "=A2:$XFD2", "=A2:$XFD2" }, + { "=$A2:XFD2", "=$A2:XFD2" }, + { "=$A2:$XFD2", "=2:2" } }; if (m_pDoc->MaxRow() == 1048575) @@ -853,7 +852,7 @@ void TestFormula::testFormulaParseReference() { // Use the 'Dummy' sheet for this. m_pDoc->SetString(ScAddress(0,0,0), OUString::createFromAscii(check[0])); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,0,0), check[1], "Wrong formula"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString::createFromAscii(check[1]), m_pDoc->GetFormula(0,0,0)); } } else @@ -862,7 +861,7 @@ void TestFormula::testFormulaParseReference() for (const auto& check : row16777216Checks) { m_pDoc->SetString(ScAddress(0,0,0), OUString::createFromAscii(check[0])); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,0,0), check[1], "Wrong formula"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString::createFromAscii(check[1]), m_pDoc->GetFormula(0,0,0)); } } if (m_pDoc->MaxCol() == 1023) @@ -870,7 +869,7 @@ void TestFormula::testFormulaParseReference() for (const auto& check : col1024Checks) { m_pDoc->SetString(ScAddress(0,0,0), OUString::createFromAscii(check[0])); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,0,0), check[1], "Wrong formula"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString::createFromAscii(check[1]), m_pDoc->GetFormula(0,0,0)); } } else @@ -879,7 +878,7 @@ void TestFormula::testFormulaParseReference() for (const auto& check : col16384Checks) { m_pDoc->SetString(ScAddress(0,0,0), OUString::createFromAscii(check[0])); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,0,0), check[1], "Wrong formula"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString::createFromAscii(check[1]), m_pDoc->GetFormula(0,0,0)); } } } @@ -1710,8 +1709,8 @@ void TestFormula::testFormulaCompilerImplicitIntersection1NoGroup() // Implicit intersection optimization in ScCompiler::HandleIIOpCode() internally changes // these to "=COS(A3)" and "=COS(A4)", but these shouldn't be merged into a formula group, // otherwise B4's formula would then be "=COS(A2:A6)". - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,2,0), "COS(A1:A5)", "Formula in B3 has changed."); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,3,0), "COS(A1:A5)", "Formula in B4 has changed."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Formula in B3 has changed.", OUString("=COS(A1:A5)"), m_pDoc->GetFormula(1,2,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Formula in B4 has changed.", OUString("=COS(A1:A5)"), m_pDoc->GetFormula(1,3,0)); m_pDoc->DeleteTab(0); } @@ -1872,82 +1871,82 @@ void TestFormula::testFormulaRefUpdate() m_pDoc->SetString(ScAddress(2,3,0), "=$A$1"); // C4 ScAddress aPos(2,2,0); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "A1", "Wrong formula in C3."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in C3.", OUString("=A1"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos = ScAddress(2,3,0); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "$A$1", "Wrong formula in C4."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in C4.", OUString("=$A$1"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); // Delete row 2 to push formula cells up (to C2:C3). m_pDoc->DeleteRow(ScRange(0,1,0,m_pDoc->MaxCol(),1,0)); aPos = ScAddress(2,1,0); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "A1", "Wrong formula in C2."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in C2.", OUString("=A1"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos = ScAddress(2,2,0); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "$A$1", "Wrong formula in C3."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in C3.", OUString("=$A$1"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); // Insert one row at row 2 to move them back. m_pDoc->InsertRow(ScRange(0,1,0,m_pDoc->MaxCol(),1,0)); aPos = ScAddress(2,2,0); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "A1", "Wrong formula in C3."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in C3.", OUString("=A1"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos = ScAddress(2,3,0); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "$A$1", "Wrong formula in C4."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in C4.", OUString("=$A$1"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); // Insert 2 rows at row 1 to shift all of A1 and C3:C4 down. m_pDoc->InsertRow(ScRange(0,0,0,m_pDoc->MaxCol(),1,0)); aPos = ScAddress(2,4,0); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "A3", "Wrong formula in C5."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in C5.", OUString("=A3"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos = ScAddress(2,5,0); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "$A$3", "Wrong formula in C6."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in C6.", OUString("=$A$3"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); // Delete 2 rows at row 1 to shift them back. m_pDoc->DeleteRow(ScRange(0,0,0,m_pDoc->MaxCol(),1,0)); aPos = ScAddress(2,2,0); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "A1", "Wrong formula in C3."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in C3.", OUString("=A1"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos = ScAddress(2,3,0); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "$A$1", "Wrong formula in C4."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in C4.", OUString("=$A$1"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); // Insert 3 columns at column B. to shift C3:C4 to F3:F4. m_pDoc->InsertCol(ScRange(1,0,0,3,m_pDoc->MaxRow(),0)); aPos = ScAddress(5,2,0); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "A1", "Wrong formula in F3."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in F3.", OUString("=A1"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos = ScAddress(5,3,0); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "$A$1", "Wrong formula in F4."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in F4.", OUString("=$A$1"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); // Delete columns B:D to shift them back. m_pDoc->DeleteCol(ScRange(1,0,0,3,m_pDoc->MaxRow(),0)); aPos = ScAddress(2,2,0); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "A1", "Wrong formula in C3."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in C3.", OUString("=A1"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos = ScAddress(2,3,0); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "$A$1", "Wrong formula in C4."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in C4.", OUString("=$A$1"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); // Insert cells over A1:A3 to only shift A1 down to A4. m_pDoc->InsertRow(ScRange(0,0,0,0,2,0)); aPos = ScAddress(2,2,0); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "A4", "Wrong formula in C3."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in C3.", OUString("=A4"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos = ScAddress(2,3,0); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "$A$4", "Wrong formula in C4."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in C4.", OUString("=$A$4"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); // .. and back. m_pDoc->DeleteRow(ScRange(0,0,0,0,2,0)); aPos = ScAddress(2,2,0); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "A1", "Wrong formula in C3."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in C3.", OUString("=A1"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos = ScAddress(2,3,0); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "$A$1", "Wrong formula in C4."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in C4.", OUString("=$A$1"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); // Delete row 1 which will delete the value cell (A1). m_pDoc->DeleteRow(ScRange(0,0,0,m_pDoc->MaxCol(),0,0)); @@ -1976,64 +1975,64 @@ void TestFormula::testFormulaRefUpdate() m_pDoc->SetString(ScAddress(0,6,0), "=SUM($B$2:$C$3)"); aPos = ScAddress(0,5,0); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM(B2:C3)", "Wrong formula in A6."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A6.", OUString("=SUM(B2:C3)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos = ScAddress(0,6,0); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM($B$2:$C$3)", "Wrong formula in A7."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A7.", OUString("=SUM($B$2:$C$3)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); // Insert a row at row 1. m_pDoc->InsertRow(ScRange(0,0,0,m_pDoc->MaxCol(),0,0)); aPos = ScAddress(0,6,0); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM(B3:C4)", "Wrong formula in A7."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A7.", OUString("=SUM(B3:C4)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos = ScAddress(0,7,0); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM($B$3:$C$4)", "Wrong formula in A8."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A8.", OUString("=SUM($B$3:$C$4)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); // ... and back. m_pDoc->DeleteRow(ScRange(0,0,0,m_pDoc->MaxCol(),0,0)); aPos = ScAddress(0,5,0); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM(B2:C3)", "Wrong formula in A6."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A6.", OUString("=SUM(B2:C3)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos = ScAddress(0,6,0); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM($B$2:$C$3)", "Wrong formula in A7."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A7.", OUString("=SUM($B$2:$C$3)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); // Insert columns B:C to shift only the value range. m_pDoc->InsertCol(ScRange(1,0,0,2,m_pDoc->MaxRow(),0)); aPos = ScAddress(0,5,0); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM(D2:E3)", "Wrong formula in A6."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A6.", OUString("=SUM(D2:E3)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos = ScAddress(0,6,0); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM($D$2:$E$3)", "Wrong formula in A7."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A7.", OUString("=SUM($D$2:$E$3)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); // ... and back. m_pDoc->DeleteCol(ScRange(1,0,0,2,m_pDoc->MaxRow(),0)); aPos = ScAddress(0,5,0); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM(B2:C3)", "Wrong formula in A6."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A6.", OUString("=SUM(B2:C3)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos = ScAddress(0,6,0); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM($B$2:$C$3)", "Wrong formula in A7."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A7.", OUString("=SUM($B$2:$C$3)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); // Insert rows 5:6 to shift the formula cells only. m_pDoc->InsertRow(ScRange(0,4,0,m_pDoc->MaxCol(),5,0)); aPos = ScAddress(0,7,0); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM(B2:C3)", "Wrong formula in A8."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A8.", OUString("=SUM(B2:C3)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos = ScAddress(0,8,0); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM($B$2:$C$3)", "Wrong formula in A9."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A9.", OUString("=SUM($B$2:$C$3)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); // ... and back. m_pDoc->DeleteRow(ScRange(0,4,0,m_pDoc->MaxCol(),5,0)); aPos = ScAddress(0,5,0); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM(B2:C3)", "Wrong formula in A6."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A6.", OUString("=SUM(B2:C3)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos = ScAddress(0,6,0); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM($B$2:$C$3)", "Wrong formula in A7."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A7.", OUString("=SUM($B$2:$C$3)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); // Check the values of the formula cells in A6:A7. CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(ScAddress(0,5,0))); @@ -2090,9 +2089,9 @@ void TestFormula::testFormulaRefUpdateRange() m_pDoc->SetString(ScAddress(0,6,0), "=SUM(B2:C5)"); m_pDoc->SetString(ScAddress(0,7,0), "=SUM($B$2:$C$5)"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,6,0), "SUM(B2:C5)", "Wrong formula in A7."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A7.", OUString("=SUM(B2:C5)"), m_pDoc->GetFormula(0,6,0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,7,0), "SUM($B$2:$C$5)", "Wrong formula in A8."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A8.", OUString("=SUM($B$2:$C$5)"), m_pDoc->GetFormula(0,7,0)); CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(ScAddress(0,6,0))); CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(ScAddress(0,7,0))); @@ -2100,9 +2099,9 @@ void TestFormula::testFormulaRefUpdateRange() // Delete row 3. This should shrink the range references by one row. m_pDoc->DeleteRow(ScRange(0,2,0,m_pDoc->MaxCol(),2,0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,5,0), "SUM(B2:C4)", "Wrong formula in A6."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A6.", OUString("=SUM(B2:C4)"), m_pDoc->GetFormula(0,5,0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,6,0), "SUM($B$2:$C$4)", "Wrong formula in A7."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A7.", OUString("=SUM($B$2:$C$4)"), m_pDoc->GetFormula(0,6,0)); CPPUNIT_ASSERT_EQUAL(28.0, m_pDoc->GetValue(ScAddress(0,5,0))); CPPUNIT_ASSERT_EQUAL(28.0, m_pDoc->GetValue(ScAddress(0,6,0))); @@ -2110,9 +2109,9 @@ void TestFormula::testFormulaRefUpdateRange() // Delete row 4 - bottom of range m_pDoc->DeleteRow(ScRange(0,3,0,m_pDoc->MaxCol(),3,0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,4,0), "SUM(B2:C3)", "Wrong formula in A5."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A5.", OUString("=SUM(B2:C3)"), m_pDoc->GetFormula(0,4,0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,5,0), "SUM($B$2:$C$3)", "Wrong formula in A6."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A6.", OUString("=SUM($B$2:$C$3)"), m_pDoc->GetFormula(0,5,0)); CPPUNIT_ASSERT_EQUAL(16.0, m_pDoc->GetValue(ScAddress(0,4,0))); CPPUNIT_ASSERT_EQUAL(16.0, m_pDoc->GetValue(ScAddress(0,5,0))); @@ -2120,9 +2119,9 @@ void TestFormula::testFormulaRefUpdateRange() // Delete row 2 - top of range m_pDoc->DeleteRow(ScRange(0,1,0,m_pDoc->MaxCol(),1,0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,3,0), "SUM(B2:C2)", "Wrong formula in A4."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A4.", OUString("=SUM(B2:C2)"), m_pDoc->GetFormula(0,3,0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,4,0), "SUM($B$2:$C$2)", "Wrong formula in A5."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A5.", OUString("=SUM($B$2:$C$2)"), m_pDoc->GetFormula(0,4,0)); CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(ScAddress(0,3,0))); CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(ScAddress(0,4,0))); @@ -2144,9 +2143,9 @@ void TestFormula::testFormulaRefUpdateRange() m_pDoc->SetString(ScAddress(0,1,0), "=SUM(C2:F3)"); m_pDoc->SetString(ScAddress(0,2,0), "=SUM($C$2:$F$3)"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,1,0), "SUM(C2:F3)", "Wrong formula in A2."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A2.", OUString("=SUM(C2:F3)"), m_pDoc->GetFormula(0,1,0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,2,0), "SUM($C$2:$F$3)", "Wrong formula in A3."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A3.", OUString("=SUM($C$2:$F$3)"), m_pDoc->GetFormula(0,2,0)); CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(ScAddress(0,1,0))); CPPUNIT_ASSERT_EQUAL(36.0, m_pDoc->GetValue(ScAddress(0,2,0))); @@ -2154,9 +2153,9 @@ void TestFormula::testFormulaRefUpdateRange() // Delete column D. m_pDoc->DeleteCol(ScRange(3,0,0,3,m_pDoc->MaxRow(),0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,1,0), "SUM(C2:E3)", "Wrong formula in A2."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A2.", OUString("=SUM(C2:E3)"), m_pDoc->GetFormula(0,1,0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,2,0), "SUM($C$2:$E$3)", "Wrong formula in A3."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A3.", OUString("=SUM($C$2:$E$3)"), m_pDoc->GetFormula(0,2,0)); CPPUNIT_ASSERT_EQUAL(28.0, m_pDoc->GetValue(ScAddress(0,1,0))); CPPUNIT_ASSERT_EQUAL(28.0, m_pDoc->GetValue(ScAddress(0,2,0))); @@ -2164,9 +2163,9 @@ void TestFormula::testFormulaRefUpdateRange() // Delete column E - the right edge of reference range. m_pDoc->DeleteCol(ScRange(4,0,0,4,m_pDoc->MaxRow(),0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,1,0), "SUM(C2:D3)", "Wrong formula in A2."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A2.", OUString("=SUM(C2:D3)"), m_pDoc->GetFormula(0,1,0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,2,0), "SUM($C$2:$D$3)", "Wrong formula in A3."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A3.", OUString("=SUM($C$2:$D$3)"), m_pDoc->GetFormula(0,2,0)); CPPUNIT_ASSERT_EQUAL(16.0, m_pDoc->GetValue(ScAddress(0,1,0))); CPPUNIT_ASSERT_EQUAL(16.0, m_pDoc->GetValue(ScAddress(0,2,0))); @@ -2174,9 +2173,9 @@ void TestFormula::testFormulaRefUpdateRange() // Delete column C - the left edge of reference range. m_pDoc->DeleteCol(ScRange(2,0,0,2,m_pDoc->MaxRow(),0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,1,0), "SUM(C2:C3)", "Wrong formula in A2."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A2.", OUString("=SUM(C2:C3)"), m_pDoc->GetFormula(0,1,0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,2,0), "SUM($C$2:$C$3)", "Wrong formula in A3."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A3.", OUString("=SUM($C$2:$C$3)"), m_pDoc->GetFormula(0,2,0)); CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(ScAddress(0,1,0))); CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(ScAddress(0,2,0))); @@ -2197,58 +2196,58 @@ void TestFormula::testFormulaRefUpdateRange() m_pDoc->SetString(ScAddress(0,4,0), "=SUM(C2:D3)"); m_pDoc->SetString(ScAddress(0,5,0), "=SUM($C$2:$D$3)"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,4,0), "SUM(C2:D3)", "Wrong formula in A5."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A5.", OUString("=SUM(C2:D3)"), m_pDoc->GetFormula(0,4,0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,5,0), "SUM($C$2:$D$3)", "Wrong formula in A6."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A6.", OUString("=SUM($C$2:$D$3)"), m_pDoc->GetFormula(0,5,0)); // Insert a column at column C. This should simply shift the reference without expansion. m_pDoc->InsertCol(ScRange(2,0,0,2,m_pDoc->MaxRow(),0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,4,0), "SUM(D2:E3)", "Wrong formula in A5."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A5.", OUString("=SUM(D2:E3)"), m_pDoc->GetFormula(0,4,0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,5,0), "SUM($D$2:$E$3)", "Wrong formula in A6."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A6.", OUString("=SUM($D$2:$E$3)"), m_pDoc->GetFormula(0,5,0)); // Shift it back. m_pDoc->DeleteCol(ScRange(2,0,0,2,m_pDoc->MaxRow(),0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,4,0), "SUM(C2:D3)", "Wrong formula in A5."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A5.", OUString("=SUM(C2:D3)"), m_pDoc->GetFormula(0,4,0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,5,0), "SUM($C$2:$D$3)", "Wrong formula in A6."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A6.", OUString("=SUM($C$2:$D$3)"), m_pDoc->GetFormula(0,5,0)); // Insert at column D. This should expand the reference by one column length. m_pDoc->InsertCol(ScRange(3,0,0,3,m_pDoc->MaxRow(),0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,4,0), "SUM(C2:E3)", "Wrong formula in A5."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A5.", OUString("=SUM(C2:E3)"), m_pDoc->GetFormula(0,4,0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,5,0), "SUM($C$2:$E$3)", "Wrong formula in A6."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A6.", OUString("=SUM($C$2:$E$3)"), m_pDoc->GetFormula(0,5,0)); // Insert at column F. No expansion should occur since the edge expansion is turned off. m_pDoc->InsertCol(ScRange(5,0,0,5,m_pDoc->MaxRow(),0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,4,0), "SUM(C2:E3)", "Wrong formula in A5."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A5.", OUString("=SUM(C2:E3)"), m_pDoc->GetFormula(0,4,0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,5,0), "SUM($C$2:$E$3)", "Wrong formula in A6."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A6.", OUString("=SUM($C$2:$E$3)"), m_pDoc->GetFormula(0,5,0)); // Insert at row 2. No expansion should occur with edge expansion turned off. m_pDoc->InsertRow(ScRange(0,1,0,m_pDoc->MaxCol(),1,0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,5,0), "SUM(C3:E4)", "Wrong formula in A6."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A6.", OUString("=SUM(C3:E4)"), m_pDoc->GetFormula(0,5,0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,6,0), "SUM($C$3:$E$4)", "Wrong formula in A7."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A7.", OUString("=SUM($C$3:$E$4)"), m_pDoc->GetFormula(0,6,0)); // Insert at row 4 to expand the reference range. m_pDoc->InsertRow(ScRange(0,3,0,m_pDoc->MaxCol(),3,0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,6,0), "SUM(C3:E5)", "Wrong formula in A7."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A7.", OUString("=SUM(C3:E5)"), m_pDoc->GetFormula(0,6,0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,7,0), "SUM($C$3:$E$5)", "Wrong formula in A8."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A8.", OUString("=SUM($C$3:$E$5)"), m_pDoc->GetFormula(0,7,0)); // Insert at row 6. No expansion with edge expansion turned off. m_pDoc->InsertRow(ScRange(0,5,0,m_pDoc->MaxCol(),5,0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,7,0), "SUM(C3:E5)", "Wrong formula in A8."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A8.", OUString("=SUM(C3:E5)"), m_pDoc->GetFormula(0,7,0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,8,0), "SUM($C$3:$E$5)", "Wrong formula in A9."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A9.", OUString("=SUM($C$3:$E$5)"), m_pDoc->GetFormula(0,8,0)); // Clear the range and start over. clearRange(m_pDoc, ScRange(0,0,0,20,20,0)); @@ -2266,37 +2265,37 @@ void TestFormula::testFormulaRefUpdateRange() m_pDoc->SetString(ScAddress(0,1,0), "=SUM(C6:D7)"); m_pDoc->SetString(ScAddress(0,2,0), "=SUM($C$6:$D$7)"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,1,0), "SUM(C6:D7)", "Wrong formula in A2."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A2.", OUString("=SUM(C6:D7)"), m_pDoc->GetFormula(0,1,0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,2,0), "SUM($C$6:$D$7)", "Wrong formula in A3."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A3.", OUString("=SUM($C$6:$D$7)"), m_pDoc->GetFormula(0,2,0)); // Insert at column E. This should expand the reference range by one column. m_pDoc->InsertCol(ScRange(4,0,0,4,m_pDoc->MaxRow(),0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,1,0), "SUM(C6:E7)", "Wrong formula in A2."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A2.", OUString("=SUM(C6:E7)"), m_pDoc->GetFormula(0,1,0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,2,0), "SUM($C$6:$E$7)", "Wrong formula in A3."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A3.", OUString("=SUM($C$6:$E$7)"), m_pDoc->GetFormula(0,2,0)); // Insert at column C to edge-expand the reference range. m_pDoc->InsertCol(ScRange(2,0,0,2,m_pDoc->MaxRow(),0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,1,0), "SUM(C6:F7)", "Wrong formula in A2."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A2.", OUString("=SUM(C6:F7)"), m_pDoc->GetFormula(0,1,0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,2,0), "SUM($C$6:$F$7)", "Wrong formula in A3."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A3.", OUString("=SUM($C$6:$F$7)"), m_pDoc->GetFormula(0,2,0)); // Insert at row 8 to edge-expand. m_pDoc->InsertRow(ScRange(0,7,0,m_pDoc->MaxCol(),7,0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,1,0), "SUM(C6:F8)", "Wrong formula in A2."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A2.", OUString("=SUM(C6:F8)"), m_pDoc->GetFormula(0,1,0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,2,0), "SUM($C$6:$F$8)", "Wrong formula in A3."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A3.", OUString("=SUM($C$6:$F$8)"), m_pDoc->GetFormula(0,2,0)); // Insert at row 6 to edge-expand. m_pDoc->InsertRow(ScRange(0,5,0,m_pDoc->MaxCol(),5,0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,1,0), "SUM(C6:F9)", "Wrong formula in A2."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A2.", OUString("=SUM(C6:F9)"), m_pDoc->GetFormula(0,1,0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,2,0), "SUM($C$6:$F$9)", "Wrong formula in A3."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A3.", OUString("=SUM($C$6:$F$9)"), m_pDoc->GetFormula(0,2,0)); m_pDoc->InsertTab(1, "StickyRange"); @@ -2345,41 +2344,41 @@ void TestFormula::testFormulaRefUpdateRange() // A3:A18 must not result in #REF! anywhere. aPos.Set(0,2,1); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "B2:B1048576", "Wrong reference in A3 after insertion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A3 after insertion.", OUString("=B2:B1048576"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "B2:B$1048576", "Wrong reference in A4 after insertion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A4 after insertion.", OUString("=B2:B$1048576"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "B2:$B1048576", "Wrong reference in A5 after insertion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A5 after insertion.", OUString("=B2:$B1048576"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "B2:$B$1048576", "Wrong reference in A6 after insertion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A6 after insertion.", OUString("=B2:$B$1048576"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "B$2:B1048576", "Wrong reference in A7 after insertion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A7 after insertion.", OUString("=B$2:B1048576"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "B$2:B$1048576", "Wrong reference in A8 after insertion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A8 after insertion.", OUString("=B$2:B$1048576"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "B$2:$B1048576", "Wrong reference in A9 after insertion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A9 after insertion.", OUString("=B$2:$B1048576"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "B$2:$B$1048576", "Wrong reference in A10 after insertion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A10 after insertion.", OUString("=B$2:$B$1048576"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "$B2:B1048576", "Wrong reference in A11 after insertion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A11 after insertion.", OUString("=$B2:B1048576"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "$B2:B$1048576", "Wrong reference in A12 after insertion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A12 after insertion.", OUString("=$B2:B$1048576"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "$B2:$B1048576", "Wrong reference in A13 after insertion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A13 after insertion.", OUString("=$B2:$B1048576"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "$B2:$B$1048576", "Wrong reference in A14 after insertion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A14 after insertion.", OUString("=$B2:$B$1048576"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "$B$2:B1048576", "Wrong reference in A15 after insertion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A15 after insertion.", OUString("=$B$2:B1048576"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "$B$2:B$1048576", "Wrong reference in A16 after insertion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A16 after insertion.", OUString("=$B$2:B$1048576"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "$B$2:$B1048576", "Wrong reference in A17 after insertion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A17 after insertion.", OUString("=$B$2:$B1048576"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "$B$2:$B$1048576", "Wrong reference in A18 after insertion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A18 after insertion.", OUString("=$B$2:$B$1048576"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); // A19 reference to one row shifted out should be #REF! - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "B#REF!:C#REF!", "Wrong reference in A19 after insertion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A19 after insertion.", OUString("=B#REF!:C#REF!"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); // A19 enter reference to last row. m_pDoc->SetString( aPos, "=B1048576:C1048576"); aPos.IncRow(); @@ -2390,41 +2389,41 @@ void TestFormula::testFormulaRefUpdateRange() // Check sticky bottom references and display of entire column references, // now in A2:A17. aPos.Set(0,1,1); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "B:B", "Wrong reference in A2 after deletion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A2 after deletion.", OUString("=B:B"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "B1:B$1048576", "Wrong reference in A3 after deletion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A3 after deletion.", OUString("=B1:B$1048576"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "B:$B", "Wrong reference in A4 after deletion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A4 after deletion.", OUString("=B:$B"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "B1:$B$1048576", "Wrong reference in A5 after deletion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A5 after deletion.", OUString("=B1:$B$1048576"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "B$1:B1048576", "Wrong reference in A6 after deletion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A6 after deletion.", OUString("=B$1:B1048576"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "B:B", "Wrong reference in A7 after deletion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A7 after deletion.", OUString("=B:B"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "B$1:$B1048576", "Wrong reference in A8 after deletion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A8 after deletion.", OUString("=B$1:$B1048576"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "B:$B", "Wrong reference in A9 after deletion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A9 after deletion.", OUString("=B:$B"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "$B:B", "Wrong reference in A10 after deletion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A10 after deletion.", OUString("=$B:B"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "$B1:B$1048576", "Wrong reference in A11 after deletion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A11 after deletion.", OUString("=$B1:B$1048576"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "$B:$B", "Wrong reference in A12 after deletion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A12 after deletion.", OUString("=$B:$B"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "$B1:$B$1048576", "Wrong reference in A13 after deletion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A13 after deletion.", OUString("=$B1:$B$1048576"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "$B$1:B1048576", "Wrong reference in A14 after deletion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A14 after deletion.", OUString("=$B$1:B1048576"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "$B:B", "Wrong reference in A15 after deletion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A15 after deletion.", OUString("=$B:B"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "$B$1:$B1048576", "Wrong reference in A16 after deletion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A16 after deletion.", OUString("=$B$1:$B1048576"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "$B:$B", "Wrong reference in A17 after deletion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A17 after deletion.", OUString("=$B:$B"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); // A18 reference to one last row should be shifted up. - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "B1048575:C1048575", "Wrong reference in A18 after deletion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A18 after deletion.", OUString("=B1048575:C1048575"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); // Insert 4 rows in the middle. @@ -2434,37 +2433,37 @@ void TestFormula::testFormulaRefUpdateRange() // References in A2:A17 must still be the same. aPos.Set(0,1,1); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "B:B", "Wrong reference in A2 after deletion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A2 after deletion.", OUString("=B:B"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "B1:B$1048576", "Wrong reference in A3 after deletion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A3 after deletion.", OUString("=B1:B$1048576"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "B:$B", "Wrong reference in A4 after deletion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A4 after deletion.", OUString("=B:$B"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "B1:$B$1048576", "Wrong reference in A5 after deletion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A5 after deletion.", OUString("=B1:$B$1048576"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "B$1:B1048576", "Wrong reference in A6 after deletion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A6 after deletion.", OUString("=B$1:B1048576"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "B:B", "Wrong reference in A7 after deletion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A7 after deletion.", OUString("=B:B"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "B$1:$B1048576", "Wrong reference in A8 after deletion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A8 after deletion.", OUString("=B$1:$B1048576"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "B:$B", "Wrong reference in A9 after deletion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A9 after deletion.", OUString("=B:$B"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "$B:B", "Wrong reference in A10 after deletion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A10 after deletion.", OUString("=$B:B"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "$B1:B$1048576", "Wrong reference in A11 after deletion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A11 after deletion.", OUString("=$B1:B$1048576"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "$B:$B", "Wrong reference in A12 after deletion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A12 after deletion.", OUString("=$B:$B"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "$B1:$B$1048576", "Wrong reference in A13 after deletion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A13 after deletion.", OUString("=$B1:$B$1048576"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "$B$1:B1048576", "Wrong reference in A14 after deletion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A14 after deletion.", OUString("=$B$1:B1048576"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "$B:B", "Wrong reference in A15 after deletion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A15 after deletion.", OUString("=$B:B"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "$B$1:$B1048576", "Wrong reference in A16 after deletion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A16 after deletion.", OUString("=$B$1:$B1048576"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "$B:$B", "Wrong reference in A17 after deletion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference in A17 after deletion.", OUString("=$B:$B"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); aPos.IncRow(); // Enter values in B1 and B1048576/B16777216 (last row). @@ -2526,9 +2525,9 @@ void TestFormula::testFormulaRefUpdateSheets() m_pDoc->SetString(ScAddress(1,1,1), "=SUM(Sheet1.B2:C3)"); m_pDoc->SetString(ScAddress(1,2,1), "=SUM($Sheet1.$B$2:$C$3)"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,1,1), "SUM(Sheet1.B2:C3)", "Wrong formula in Sheet2.B2."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in Sheet2.B2.", OUString("=SUM(Sheet1.B2:C3)"), m_pDoc->GetFormula(1,1,1)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,2,1), "SUM($Sheet1.$B$2:$C$3)", "Wrong formula in Sheet2.B3."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in Sheet2.B3.", OUString("=SUM($Sheet1.$B$2:$C$3)"), m_pDoc->GetFormula(1,2,1)); // Swap the sheets. m_pDoc->MoveTab(0, 1); @@ -2537,9 +2536,9 @@ void TestFormula::testFormulaRefUpdateSheets() m_pDoc->GetName(1, aName); CPPUNIT_ASSERT_EQUAL(OUString("Sheet1"), aName); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,1,0), "SUM(Sheet1.B2:C3)", "Wrong formula in Sheet2.B2."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in Sheet2.B2.", OUString("=SUM(Sheet1.B2:C3)"), m_pDoc->GetFormula(1,1,0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,2,0), "SUM($Sheet1.$B$2:$C$3)", "Wrong formula in Sheet2.B3."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in Sheet2.B3.", OUString("=SUM($Sheet1.$B$2:$C$3)"), m_pDoc->GetFormula(1,2,0)); // Swap back. m_pDoc->MoveTab(0, 1); @@ -2548,9 +2547,9 @@ void TestFormula::testFormulaRefUpdateSheets() m_pDoc->GetName(1, aName); CPPUNIT_ASSERT_EQUAL(OUString("Sheet2"), aName); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,1,1), "SUM(Sheet1.B2:C3)", "Wrong formula in Sheet2.B2."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in Sheet2.B2.", OUString("=SUM(Sheet1.B2:C3)"), m_pDoc->GetFormula(1,1,1)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,2,1), "SUM($Sheet1.$B$2:$C$3)", "Wrong formula in Sheet2.B3."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in Sheet2.B3.", OUString("=SUM($Sheet1.$B$2:$C$3)"), m_pDoc->GetFormula(1,2,1)); // Insert a new sheet between the two. m_pDoc->InsertTab(1, "Temp"); @@ -2560,30 +2559,30 @@ void TestFormula::testFormulaRefUpdateSheets() m_pDoc->GetName(2, aName); CPPUNIT_ASSERT_EQUAL(OUString("Sheet2"), aName); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,1,2), "SUM(Sheet1.B2:C3)", "Wrong formula in Sheet2.B2."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in Sheet2.B2.", OUString("=SUM(Sheet1.B2:C3)"), m_pDoc->GetFormula(1,1,2)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,2,2), "SUM($Sheet1.$B$2:$C$3)", "Wrong formula in Sheet2.B3."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in Sheet2.B3.", OUString("=SUM($Sheet1.$B$2:$C$3)"), m_pDoc->GetFormula(1,2,2)); // Move the last sheet (Sheet2) to the first position. m_pDoc->MoveTab(2, 0); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,1,0), "SUM(Sheet1.B2:C3)", "Wrong formula in Sheet2.B2."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in Sheet2.B2.", OUString("=SUM(Sheet1.B2:C3)"), m_pDoc->GetFormula(1,1,0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,2,0), "SUM($Sheet1.$B$2:$C$3)", "Wrong formula in Sheet2.B3."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in Sheet2.B3.", OUString("=SUM($Sheet1.$B$2:$C$3)"), m_pDoc->GetFormula(1,2,0)); // Move back. m_pDoc->MoveTab(0, 2); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,1,2), "SUM(Sheet1.B2:C3)", "Wrong formula in Sheet2.B2."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in Sheet2.B2.", OUString("=SUM(Sheet1.B2:C3)"), m_pDoc->GetFormula(1,1,2)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,2,2), "SUM($Sheet1.$B$2:$C$3)", "Wrong formula in Sheet2.B3."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in Sheet2.B3.", OUString("=SUM($Sheet1.$B$2:$C$3)"), m_pDoc->GetFormula(1,2,2)); // Move the "Temp" sheet to the last position. m_pDoc->MoveTab(1, 2); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,1,1), "SUM(Sheet1.B2:C3)", "Wrong formula in Sheet2.B2."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in Sheet2.B2.", OUString("=SUM(Sheet1.B2:C3)"), m_pDoc->GetFormula(1,1,1)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,2,1), "SUM($Sheet1.$B$2:$C$3)", "Wrong formula in Sheet2.B3."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in Sheet2.B3.", OUString("=SUM($Sheet1.$B$2:$C$3)"), m_pDoc->GetFormula(1,2,1)); // Move back. m_pDoc->MoveTab(2, 1); @@ -2594,9 +2593,9 @@ void TestFormula::testFormulaRefUpdateSheets() m_pDoc->GetName(1, aName); CPPUNIT_ASSERT_EQUAL(OUString("Sheet2"), aName); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,1,1), "SUM(Sheet1.B2:C3)", "Wrong formula in Sheet2.B2."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in Sheet2.B2.", OUString("=SUM(Sheet1.B2:C3)"), m_pDoc->GetFormula(1,1,1)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,2,1), "SUM($Sheet1.$B$2:$C$3)", "Wrong formula in Sheet2.B3."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in Sheet2.B3.", OUString("=SUM($Sheet1.$B$2:$C$3)"), m_pDoc->GetFormula(1,2,1)); // Insert a new sheet before the first one. m_pDoc->InsertTab(0, "Temp"); @@ -2606,16 +2605,16 @@ void TestFormula::testFormulaRefUpdateSheets() m_pDoc->GetName(2, aName); CPPUNIT_ASSERT_EQUAL(OUString("Sheet2"), aName); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,1,2), "SUM(Sheet1.B2:C3)", "Wrong formula in Sheet2.B2."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in Sheet2.B2.", OUString("=SUM(Sheet1.B2:C3)"), m_pDoc->GetFormula(1,1,2)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,2,2), "SUM($Sheet1.$B$2:$C$3)", "Wrong formula in Sheet2.B3."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in Sheet2.B3.", OUString("=SUM($Sheet1.$B$2:$C$3)"), m_pDoc->GetFormula(1,2,2)); // Delete the temporary sheet. m_pDoc->DeleteTab(0); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,1,1), "SUM(Sheet1.B2:C3)", "Wrong formula in Sheet2.B2."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in Sheet2.B2.", OUString("=SUM(Sheet1.B2:C3)"), m_pDoc->GetFormula(1,1,1)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,2,1), "SUM($Sheet1.$B$2:$C$3)", "Wrong formula in Sheet2.B3."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in Sheet2.B3.", OUString("=SUM($Sheet1.$B$2:$C$3)"), m_pDoc->GetFormula(1,2,1)); // Append a bunch of sheets. m_pDoc->InsertTab(2, "Temp1"); @@ -2626,9 +2625,9 @@ void TestFormula::testFormulaRefUpdateSheets() m_pDoc->MoveTab(2, 4); m_pDoc->MoveTab(3, 2); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,1,1), "SUM(Sheet1.B2:C3)", "Wrong formula in Sheet2.B2."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in Sheet2.B2.", OUString("=SUM(Sheet1.B2:C3)"), m_pDoc->GetFormula(1,1,1)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,2,1), "SUM($Sheet1.$B$2:$C$3)", "Wrong formula in Sheet2.B3."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in Sheet2.B3.", OUString("=SUM($Sheet1.$B$2:$C$3)"), m_pDoc->GetFormula(1,2,1)); // Delete the temp sheets. m_pDoc->DeleteTab(4); @@ -2640,9 +2639,9 @@ void TestFormula::testFormulaRefUpdateSheets() m_pDoc->GetName(0, aName); CPPUNIT_ASSERT_EQUAL(OUString("Sheet2"), aName); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,1,0), "SUM(#REF!.B2:C3)", "Wrong formula in Sheet2.B2."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in Sheet2.B2.", OUString("=SUM(#REF!.B2:C3)"), m_pDoc->GetFormula(1,1,0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,2,0), "SUM($#REF!.$B$2:$C$3)", "Wrong formula in Sheet2.B3."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in Sheet2.B3.", OUString("=SUM($#REF!.$B$2:$C$3)"), m_pDoc->GetFormula(1,2,0)); m_pDoc->DeleteTab(0); } @@ -2675,7 +2674,7 @@ void TestFormula::testFormulaRefUpdateInsertRows() CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(1,4,0))); CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(1,5,0))); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,6,0), "SUM(B4:B6)", "Wrong formula!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=SUM(B4:B6)"), m_pDoc->GetFormula(1,6,0)); // Clear and start over. clearSheet(m_pDoc, 0); @@ -2697,7 +2696,7 @@ void TestFormula::testFormulaRefUpdateInsertRows() CPPUNIT_ASSERT_EQUAL_MESSAGE("This formula cell should not be an error.", 0, static_cast<int>(pFC->GetErrCode())); ASSERT_DOUBLES_EQUAL(3.0, m_pDoc->GetValue(ScAddress(0,5,0))); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,5,0), "MAX(A7:A9)", "Wrong formula!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=MAX(A7:A9)"), m_pDoc->GetFormula(0,5,0)); m_pDoc->DeleteTab(0); } @@ -2713,8 +2712,8 @@ void TestFormula::testFormulaRefUpdateSheetsDelete() m_pDoc->SetString(ScAddress(4,2,0), "=SUM($Sheet2.A4:$Sheet4.A4)"); m_pDoc->DeleteTab(1); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(4,1,0), "SUM(Sheet3.A4:Sheet4.A4)", "Wrong Formula"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(4,2,0), "SUM($Sheet3.A4:$Sheet4.A4)", "Wrong Formula"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong Formula", OUString("=SUM(Sheet3.A4:Sheet4.A4)"), m_pDoc->GetFormula(4,1,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong Formula", OUString("=SUM($Sheet3.A4:$Sheet4.A4)"), m_pDoc->GetFormula(4,2,0)); m_pDoc->InsertTab(1, "Sheet2"); @@ -2722,8 +2721,8 @@ void TestFormula::testFormulaRefUpdateSheetsDelete() m_pDoc->SetString(ScAddress(5,2,3), "=SUM($Sheet1.A5:$Sheet3.A5)"); m_pDoc->DeleteTab(2); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(5,1,2), "SUM(Sheet1.A5:Sheet2.A5)", "Wrong Formula"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(5,2,2), "SUM($Sheet1.A5:$Sheet2.A5)", "Wrong Formula"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong Formula", OUString("=SUM(Sheet1.A5:Sheet2.A5)"), m_pDoc->GetFormula(5,1,2)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong Formula", OUString("=SUM($Sheet1.A5:$Sheet2.A5)"), m_pDoc->GetFormula(5,2,2)); m_pDoc->InsertTab(2, "Sheet3"); @@ -2731,8 +2730,8 @@ void TestFormula::testFormulaRefUpdateSheetsDelete() m_pDoc->SetString(ScAddress(6,2,3), "=SUM($Sheet1.A6:$Sheet3.A6)"); m_pDoc->DeleteTabs(0,3); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(6,1,0), "SUM(#REF!.A6:#REF!.A6)", "Wrong Formula"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(6,2,0), "SUM($#REF!.A6:$#REF!.A6)", "Wrong Formula"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong Formula", OUString("=SUM(#REF!.A6:#REF!.A6)"), m_pDoc->GetFormula(6,1,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong Formula", OUString("=SUM($#REF!.A6:$#REF!.A6)"), m_pDoc->GetFormula(6,2,0)); m_pDoc->InsertTab(0, "Sheet1"); m_pDoc->InsertTab(1, "Sheet2"); @@ -2748,31 +2747,31 @@ void TestFormula::testFormulaRefUpdateSheetsDelete() m_pDoc->DeleteTab(2); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,1,1), "SUM(Sheet1.A2:Sheet2.A2)", "Wrong Formula"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong Formula", OUString("=SUM(Sheet1.A2:Sheet2.A2)"), m_pDoc->GetFormula(1,1,1)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2,1,1), "SUM(Sheet1.A1:Sheet2.A1)", "Wrong Formula"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong Formula", OUString("=SUM(Sheet1.A1:Sheet2.A1)"), m_pDoc->GetFormula(2,1,1)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(3,1,1), "SUM(Sheet2.A3:Sheet4.A3)", "Wrong Formula"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong Formula", OUString("=SUM(Sheet2.A3:Sheet4.A3)"), m_pDoc->GetFormula(3,1,1)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,2,1), "SUM($Sheet1.A2:$Sheet2.A2)", "Wrong Formula"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong Formula", OUString("=SUM($Sheet1.A2:$Sheet2.A2)"), m_pDoc->GetFormula(1,2,1)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2,2,1), "SUM($Sheet1.A1:$Sheet2.A1)", "Wrong Formula"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong Formula", OUString("=SUM($Sheet1.A1:$Sheet2.A1)"), m_pDoc->GetFormula(2,2,1)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(3,2,1), "SUM($Sheet2.A3:$Sheet4.A3)", "Wrong Formula"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong Formula", OUString("=SUM($Sheet2.A3:$Sheet4.A3)"), m_pDoc->GetFormula(3,2,1)); m_pDoc->DeleteTab(0); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,1,0), "SUM(Sheet2.A2:Sheet2.A2)", "Wrong Formula"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong Formula", OUString("=SUM(Sheet2.A2:Sheet2.A2)"), m_pDoc->GetFormula(1,1,0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2,1,0), "SUM(Sheet2.A1:Sheet2.A1)", "Wrong Formula"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong Formula", OUString("=SUM(Sheet2.A1:Sheet2.A1)"), m_pDoc->GetFormula(2,1,0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(3,1,0), "SUM(Sheet2.A3:Sheet4.A3)", "Wrong Formula"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong Formula", OUString("=SUM(Sheet2.A3:Sheet4.A3)"), m_pDoc->GetFormula(3,1,0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,2,0), "SUM($Sheet2.A2:$Sheet2.A2)", "Wrong Formula"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong Formula", OUString("=SUM($Sheet2.A2:$Sheet2.A2)"), m_pDoc->GetFormula(1,2,0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2,2,0), "SUM($Sheet2.A1:$Sheet2.A1)", "Wrong Formula"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong Formula", OUString("=SUM($Sheet2.A1:$Sheet2.A1)"), m_pDoc->GetFormula(2,2,0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(3,2,0), "SUM($Sheet2.A3:$Sheet4.A3)", "Wrong Formula"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong Formula", OUString("=SUM($Sheet2.A3:$Sheet4.A3)"), m_pDoc->GetFormula(3,2,0)); m_pDoc->DeleteTab(0); m_pDoc->DeleteTab(0); @@ -2826,7 +2825,7 @@ void TestFormula::testFormulaRefUpdateInsertColumns() rFunc.InsertCells(ScRange(0,0,0,1,m_pDoc->MaxRow(),0), &aMark, INS_INSCOLS_BEFORE, false, true); // Now, the original column B has moved to column D. - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(3,3,0), "SUM(D1:D3)", "Wrong formula in D4 after column insertion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in D4 after column insertion.", OUString("=SUM(D1:D3)"), m_pDoc->GetFormula(3,3,0)); CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(3,3,0))); @@ -2837,7 +2836,7 @@ void TestFormula::testFormulaRefUpdateInsertColumns() CPPUNIT_ASSERT_EQUAL(OUString("$Formula.$D2"), aSymbol); // Check that the formula using the name, now in E2, still has the same result. - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(4,1,0), "RowRelativeRange", "Wrong formula in E2 after column insertion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in E2 after column insertion.", OUString("=RowRelativeRange"), m_pDoc->GetFormula(4,1,0)); CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(4,1,0))); @@ -2848,7 +2847,7 @@ void TestFormula::testFormulaRefUpdateInsertColumns() CPPUNIT_ASSERT_EQUAL(OUString("$D:$D"), aSymbol); // Check that the formula using the name, now in E3, still has the same result. - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(4,2,0), "SUM(EntireColumn)", "Wrong formula in E3 after column insertion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in E3 after column insertion.", OUString("=SUM(EntireColumn)"), m_pDoc->GetFormula(4,2,0)); CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(ScAddress(4,2,0))); @@ -2860,7 +2859,7 @@ void TestFormula::testFormulaRefUpdateInsertColumns() CPPUNIT_ASSERT_EQUAL(OUString("$2:$2"), aSymbol); // Check that the formula using the name, now in E4, still has the same result. - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(4,3,0), "SUM(EntireRow)", "Wrong formula in E4 after column insertion."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in E4 after column insertion.", OUString("=SUM(EntireRow)"), m_pDoc->GetFormula(4,3,0)); CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(ScAddress(4,3,0))); @@ -2900,10 +2899,10 @@ void TestFormula::testFormulaRefUpdateMove() CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(0,10,0)); CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(0,11,0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,8,0), "SUM(D4:D6)", "Wrong formula."); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,9,0), "SUM($D$4:$D$6)", "Wrong formula."); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,10,0), "D5", "Wrong formula."); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,11,0), "$D$6", "Wrong formula."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=SUM(D4:D6)"), m_pDoc->GetFormula(0,8,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=SUM($D$4:$D$6)"), m_pDoc->GetFormula(0,9,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=D5"), m_pDoc->GetFormula(0,10,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=$D$6"), m_pDoc->GetFormula(0,11,0)); // Move A9:A12 to B10:B13. bMoved = rFunc.MoveBlock(ScRange(0,8,0,0,11,0), ScAddress(1,9,0), true, false, false, false); @@ -2916,10 +2915,10 @@ void TestFormula::testFormulaRefUpdateMove() CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(1,12,0)); // Displayed formulas should stay the same since the referenced range hasn't moved. - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,9,0), "SUM(D4:D6)", "Wrong formula."); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,10,0), "SUM($D$4:$D$6)", "Wrong formula."); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,11,0), "D5", "Wrong formula."); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,12,0), "$D$6", "Wrong formula."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=SUM(D4:D6)"), m_pDoc->GetFormula(1,9,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=SUM($D$4:$D$6)"), m_pDoc->GetFormula(1,10,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=D5"), m_pDoc->GetFormula(1,11,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=$D$6"), m_pDoc->GetFormula(1,12,0)); // The value cells are in D4:D6. Move D4:D5 to the right but leave D6 // where it is. @@ -2932,10 +2931,10 @@ void TestFormula::testFormulaRefUpdateMove() CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(1,11,0)); CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(1,12,0)); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,9,0), "SUM(D4:D6)", "Wrong formula."); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,10,0), "SUM($D$4:$D$6)", "Wrong formula."); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,11,0), "E5", "Wrong formula."); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,12,0), "$D$6", "Wrong formula."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=SUM(D4:D6)"), m_pDoc->GetFormula(1,9,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=SUM($D$4:$D$6)"), m_pDoc->GetFormula(1,10,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=E5"), m_pDoc->GetFormula(1,11,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=$D$6"), m_pDoc->GetFormula(1,12,0)); m_pDoc->DeleteTab(0); } @@ -2955,28 +2954,28 @@ void TestFormula::testFormulaRefUpdateMoveUndo() // Set formulas with single cell references in A6:A8. m_pDoc->SetString(ScAddress(0,5,0), "=A1"); CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(0,5,0))); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,5,0), "A1", "Wrong formula."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=A1"), m_pDoc->GetFormula(0,5,0)); m_pDoc->SetString(ScAddress(0,6,0), "=A1+A2+A3"); CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(0,6,0))); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,6,0), "A1+A2+A3", "Wrong formula."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=A1+A2+A3"), m_pDoc->GetFormula(0,6,0)); m_pDoc->SetString(ScAddress(0,7,0), "=A1+A3+A4"); CPPUNIT_ASSERT_EQUAL(8.0, m_pDoc->GetValue(ScAddress(0,7,0))); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,7,0), "A1+A3+A4", "Wrong formula."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=A1+A3+A4"), m_pDoc->GetFormula(0,7,0)); // Set formulas with range references in A10:A12. m_pDoc->SetString(ScAddress(0,9,0), "=SUM(A1:A2)"); CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(0,9,0))); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,9,0), "SUM(A1:A2)", "Wrong formula."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=SUM(A1:A2)"), m_pDoc->GetFormula(0,9,0)); m_pDoc->SetString(ScAddress(0,10,0), "=SUM(A1:A3)"); CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(0,10,0))); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,10,0), "SUM(A1:A3)", "Wrong formula."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=SUM(A1:A3)"), m_pDoc->GetFormula(0,10,0)); m_pDoc->SetString(ScAddress(0,11,0), "=SUM(A1:A4)"); CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(ScAddress(0,11,0))); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,11,0), "SUM(A1:A4)", "Wrong formula."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=SUM(A1:A4)"), m_pDoc->GetFormula(0,11,0)); // Move A1:A3 to C1:C3. Note that A4 remains. ScDocFunc& rFunc = m_xDocShell->GetDocFunc(); @@ -2984,22 +2983,22 @@ void TestFormula::testFormulaRefUpdateMoveUndo() CPPUNIT_ASSERT(bMoved); CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(0,5,0))); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,5,0), "C1", "Wrong formula."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=C1"), m_pDoc->GetFormula(0,5,0)); CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(0,6,0))); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,6,0), "C1+C2+C3", "Wrong formula."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=C1+C2+C3"), m_pDoc->GetFormula(0,6,0)); CPPUNIT_ASSERT_EQUAL(8.0, m_pDoc->GetValue(ScAddress(0,7,0))); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,7,0), "C1+C3+A4", "Wrong formula."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=C1+C3+A4"), m_pDoc->GetFormula(0,7,0)); CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(0,9,0))); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,9,0), "SUM(C1:C2)", "Wrong formula."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=SUM(C1:C2)"), m_pDoc->GetFormula(0,9,0)); CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(0,10,0))); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,10,0), "SUM(C1:C3)", "Wrong formula."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=SUM(C1:C3)"), m_pDoc->GetFormula(0,10,0)); CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(ScAddress(0,11,0))); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,11,0), "SUM(A1:A4)", "Wrong formula."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=SUM(A1:A4)"), m_pDoc->GetFormula(0,11,0)); // Undo the move. SfxUndoManager* pUndoMgr = m_pDoc->GetUndoManager(); @@ -3007,22 +3006,22 @@ void TestFormula::testFormulaRefUpdateMoveUndo() pUndoMgr->Undo(); CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(0,5,0))); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,5,0), "A1", "Wrong formula."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=A1"), m_pDoc->GetFormula(0,5,0)); CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(0,6,0))); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,6,0), "A1+A2+A3", "Wrong formula."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=A1+A2+A3"), m_pDoc->GetFormula(0,6,0)); CPPUNIT_ASSERT_EQUAL(8.0, m_pDoc->GetValue(ScAddress(0,7,0))); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,7,0), "A1+A3+A4", "Wrong formula."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=A1+A3+A4"), m_pDoc->GetFormula(0,7,0)); CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(0,9,0))); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,9,0), "SUM(A1:A2)", "Wrong formula."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=SUM(A1:A2)"), m_pDoc->GetFormula(0,9,0)); CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(0,10,0))); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,10,0), "SUM(A1:A3)", "Wrong formula."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=SUM(A1:A3)"), m_pDoc->GetFormula(0,10,0)); CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(ScAddress(0,11,0))); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,11,0), "SUM(A1:A4)","Wrong formula." ); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=SUM(A1:A4)"), m_pDoc->GetFormula(0,11,0)); // Make sure the broadcasters are still valid by changing the value of A1. m_pDoc->SetValue(ScAddress(0,0,0), 20); @@ -3326,10 +3325,10 @@ void TestFormula::testFormulaRefUpdateMoveUndo4() bGood = checkOutput(m_pDoc, aOutRange, aCheckAfter, "A1:A2 moved to B1:B2"); CPPUNIT_ASSERT(bGood); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2,0,0), "B1", "Wrong formula"); // C1 - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2,1,0), "B2", "Wrong formula"); // C2 - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(3,0,0), "B1", "Wrong formula"); // D1 - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(3,1,0), "B2", "Wrong formula"); // D2 + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=B1"), m_pDoc->GetFormula(2,0,0)); // C1 + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=B2"), m_pDoc->GetFormula(2,1,0)); // C2 + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=B1"), m_pDoc->GetFormula(3,0,0)); // D1 + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=B2"), m_pDoc->GetFormula(3,1,0)); // D2 // Undo the move. SfxUndoManager* pUndoMgr = m_pDoc->GetUndoManager(); @@ -3339,10 +3338,10 @@ void TestFormula::testFormulaRefUpdateMoveUndo4() bGood = checkOutput(m_pDoc, aOutRange, aCheckInitial, "after undo"); CPPUNIT_ASSERT(bGood); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2,0,0), "B1", "Wrong formula"); // C1 - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2,1,0), "B2", "Wrong formula"); // C2 - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(3,0,0), "A1", "Wrong formula"); // D1 - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(3,1,0), "A2", "Wrong formula"); // D2 + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=B1"), m_pDoc->GetFormula(2,0,0)); // C1 + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=B2"), m_pDoc->GetFormula(2,1,0)); // C2 + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=A1"), m_pDoc->GetFormula(3,0,0)); // D1 + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=A2"), m_pDoc->GetFormula(3,1,0)); // D2 // Redo and check. pUndoMgr->Redo(); @@ -3350,10 +3349,10 @@ void TestFormula::testFormulaRefUpdateMoveUndo4() bGood = checkOutput(m_pDoc, aOutRange, aCheckAfter, "after redo"); CPPUNIT_ASSERT(bGood); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2,0,0), "B1", "Wrong formula"); // C1 - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2,1,0), "B2", "Wrong formula"); // C2 - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(3,0,0), "B1", "Wrong formula"); // D1 - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(3,1,0), "B2", "Wrong formula"); // D2 + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=B1"), m_pDoc->GetFormula(2,0,0)); // C1 + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=B2"), m_pDoc->GetFormula(2,1,0)); // C2 + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=B1"), m_pDoc->GetFormula(3,0,0)); // D1 + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=B2"), m_pDoc->GetFormula(3,1,0)); // D2 m_pDoc->DeleteTab(0); } @@ -3371,8 +3370,8 @@ void TestFormula::testFormulaRefUpdateMoveToSheet() m_pDoc->SetString(ScAddress(1,0,0), "=A1"); m_pDoc->SetString(ScAddress(1,1,0), "=A2"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,0,0), "A1", "Wrong formula"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,1,0), "A2", "Wrong formula"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=A1"), m_pDoc->GetFormula(1,0,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=A2"), m_pDoc->GetFormula(1,1,0)); CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(ScAddress(1,0,0))); CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(ScAddress(1,1,0))); @@ -3382,21 +3381,21 @@ void TestFormula::testFormulaRefUpdateMoveToSheet() bool bMoved = rFunc.MoveBlock(ScRange(0,0,0,0,1,0), ScAddress(1,2,1), true, true, false, true); CPPUNIT_ASSERT(bMoved); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,0,0), "Sheet2.B3", "Wrong formula"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,1,0), "Sheet2.B4", "Wrong formula"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=Sheet2.B3"), m_pDoc->GetFormula(1,0,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=Sheet2.B4"), m_pDoc->GetFormula(1,1,0)); // Undo and check again. SfxUndoManager* pUndoMgr = m_pDoc->GetUndoManager(); pUndoMgr->Undo(); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,0,0), "A1", "Wrong formula"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,1,0), "A2", "Wrong formula"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=A1"), m_pDoc->GetFormula(1,0,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=A2"), m_pDoc->GetFormula(1,1,0)); // Redo and check. pUndoMgr->Redo(); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,0,0), "Sheet2.B3", "Wrong formula"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,1,0), "Sheet2.B4", "Wrong formula"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=Sheet2.B3"), m_pDoc->GetFormula(1,0,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=Sheet2.B4"), m_pDoc->GetFormula(1,1,0)); m_pDoc->DeleteTab(1); m_pDoc->DeleteTab(0); @@ -3465,7 +3464,7 @@ void TestFormula::testFormulaRefUpdateDeleteAndShiftLeft() aPos.IncCol(-2); CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(aPos)); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM(C1:E1)", "Wrong formula!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=SUM(C1:E1)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); // Undo and check. SfxUndoManager* pUndo = m_pDoc->GetUndoManager(); @@ -3474,7 +3473,7 @@ void TestFormula::testFormulaRefUpdateDeleteAndShiftLeft() pUndo->Undo(); aPos.IncCol(2); CPPUNIT_ASSERT_EQUAL(15.0, m_pDoc->GetValue(aPos)); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM(C1:G1)", "Wrong formula!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=SUM(C1:G1)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); // Delete columns C:D (left end of the reference). bDeleted = rFunc.DeleteCells(ScRange(2,0,0,3,m_pDoc->MaxRow(),0), &aMark, DelCellCmd::CellsLeft, true); @@ -3482,13 +3481,13 @@ void TestFormula::testFormulaRefUpdateDeleteAndShiftLeft() aPos.IncCol(-2); CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(aPos)); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM(C1:E1)", "Wrong formula!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=SUM(C1:E1)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); // Undo and check again. pUndo->Undo(); aPos.IncCol(2); CPPUNIT_ASSERT_EQUAL(15.0, m_pDoc->GetValue(aPos)); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM(C1:G1)", "Wrong formula!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=SUM(C1:G1)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); // Delete columns B:E (overlaps on the left). bDeleted = rFunc.DeleteCells(ScRange(1,0,0,4,m_pDoc->MaxRow(),0), &aMark, DelCellCmd::CellsLeft, true); @@ -3496,13 +3495,13 @@ void TestFormula::testFormulaRefUpdateDeleteAndShiftLeft() aPos.IncCol(-4); CPPUNIT_ASSERT_EQUAL(9.0, m_pDoc->GetValue(aPos)); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM(B1:C1)", "Wrong formula!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=SUM(B1:C1)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); // Undo and check again. pUndo->Undo(); aPos.IncCol(4); CPPUNIT_ASSERT_EQUAL(15.0, m_pDoc->GetValue(aPos)); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM(C1:G1)", "Wrong formula!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=SUM(C1:G1)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); // Start over with a new scenario. clearSheet(m_pDoc, 0); @@ -3521,24 +3520,24 @@ void TestFormula::testFormulaRefUpdateDeleteAndShiftLeft() CPPUNIT_ASSERT(bDeleted); CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(aPos)); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM(C1:E1)", "Wrong formula!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=SUM(C1:E1)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); // Undo and check. pUndo->Undo(); CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(aPos)); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM(C1:H1)", "Wrong formula!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=SUM(C1:H1)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); // Delete columns G:I (overlaps on the right). bDeleted = rFunc.DeleteCells(ScRange(6,0,0,8,m_pDoc->MaxRow(),0), &aMark, DelCellCmd::CellsLeft, true); CPPUNIT_ASSERT(bDeleted); CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(aPos)); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM(C1:F1)", "Wrong formula!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=SUM(C1:F1)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); // Undo and check again. pUndo->Undo(); CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(aPos)); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM(C1:H1)", "Wrong formula!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=SUM(C1:H1)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); m_pDoc->DeleteTab(0); } @@ -3639,7 +3638,7 @@ void TestFormula::testFormulaRefUpdateDeleteAndShiftUp() aPos.IncRow(-2); CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(aPos)); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM(A3:A5)", "Wrong formula!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=SUM(A3:A5)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); // Undo and check. SfxUndoManager* pUndo = m_pDoc->GetUndoManager(); @@ -3648,7 +3647,7 @@ void TestFormula::testFormulaRefUpdateDeleteAndShiftUp() pUndo->Undo(); aPos.IncRow(2); CPPUNIT_ASSERT_EQUAL(15.0, m_pDoc->GetValue(aPos)); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM(A3:A7)", "Wrong formula!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=SUM(A3:A7)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); // Delete rows 3:4 (top end of the reference). bDeleted = rFunc.DeleteCells(ScRange(0,2,0,m_pDoc->MaxCol(),3,0), &aMark, DelCellCmd::CellsUp, true); @@ -3656,13 +3655,13 @@ void TestFormula::testFormulaRefUpdateDeleteAndShiftUp() aPos.IncRow(-2); CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(aPos)); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM(A3:A5)", "Wrong formula!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=SUM(A3:A5)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); // Undo and check again. pUndo->Undo(); aPos.IncRow(2); CPPUNIT_ASSERT_EQUAL(15.0, m_pDoc->GetValue(aPos)); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM(A3:A7)", "Wrong formula!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=SUM(A3:A7)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); // Delete rows 2:5 (overlaps on the top). bDeleted = rFunc.DeleteCells(ScRange(0,1,0,m_pDoc->MaxCol(),4,0), &aMark, DelCellCmd::CellsUp, true); @@ -3670,13 +3669,13 @@ void TestFormula::testFormulaRefUpdateDeleteAndShiftUp() aPos.IncRow(-4); CPPUNIT_ASSERT_EQUAL(9.0, m_pDoc->GetValue(aPos)); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM(A2:A3)", "Wrong formula!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=SUM(A2:A3)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); // Undo and check again. pUndo->Undo(); aPos.IncRow(4); CPPUNIT_ASSERT_EQUAL(15.0, m_pDoc->GetValue(aPos)); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM(A3:A7)", "Wrong formula!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=SUM(A3:A7)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); // Start over with a new scenario. clearSheet(m_pDoc, 0); @@ -3695,24 +3694,24 @@ void TestFormula::testFormulaRefUpdateDeleteAndShiftUp() CPPUNIT_ASSERT(bDeleted); CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(aPos)); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM(A3:A5)", "Wrong formula!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=SUM(A3:A5)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); // Undo and check. pUndo->Undo(); CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(aPos)); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM(A3:A8)", "Wrong formula!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=SUM(A3:A8)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); // Delete rows 7:9 (overlaps on the bottom). bDeleted = rFunc.DeleteCells(ScRange(0,6,0,m_pDoc->MaxCol(),8,0), &aMark, DelCellCmd::CellsUp, true); CPPUNIT_ASSERT(bDeleted); CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(aPos)); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM(A3:A6)", "Wrong formula!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=SUM(A3:A6)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); // Undo and check again. pUndo->Undo(); CPPUNIT_ASSERT_EQUAL(21.0, m_pDoc->GetValue(aPos)); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM(A3:A8)", "Wrong formula!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=SUM(A3:A8)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); m_pDoc->DeleteTab(0); } @@ -4946,9 +4945,9 @@ void TestFormula::testFuncROW() ScMarkData aMark(m_pDoc->GetSheetLimits()); aMark.SelectOneTable(0); rFunc.InsertCells(ScRange(0,3,0,m_pDoc->MaxCol(),3,0), &aMark, INS_INSROWS_BEFORE, false, true); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,1,0), "ROW(A6)", "Wrong formula!"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,1,0), "ROW(B6)", "Wrong formula!"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,2,0), "ROW(B7)", "Wrong formula!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=ROW(A6)"), m_pDoc->GetFormula(0,1,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=ROW(B6)"), m_pDoc->GetFormula(1,1,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=ROW(B7)"), m_pDoc->GetFormula(1,2,0)); CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(0,1,0))); CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(1,1,0))); @@ -7350,37 +7349,37 @@ void TestFormula::testFuncRangeOp() ScAddress aPos(0,0,0); m_pDoc->SetString( aPos, "=SUM(B1:B2:B3)"); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM(B1:B3)", "Wrong formula."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=SUM(B1:B3)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); CPPUNIT_ASSERT_EQUAL( 7.0, m_pDoc->GetValue(aPos)); aPos.IncRow(); m_pDoc->SetString( aPos, "=SUM(B1:B3:B2)"); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM(B1:B3)", "Wrong formula."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=SUM(B1:B3)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); CPPUNIT_ASSERT_EQUAL( 7.0, m_pDoc->GetValue(aPos)); aPos.IncRow(); m_pDoc->SetString( aPos, "=SUM(B2:B3:B1)"); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM(B1:B3)", "Wrong formula."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=SUM(B1:B3)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); CPPUNIT_ASSERT_EQUAL( 7.0, m_pDoc->GetValue(aPos)); aPos.IncRow(); m_pDoc->SetString( aPos, "=SUM(Sheet2.B1:B2:B3)"); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM(Sheet2.B1:B3)", "Wrong formula."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=SUM(Sheet2.B1:B3)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); CPPUNIT_ASSERT_EQUAL( 56.0, m_pDoc->GetValue(aPos)); aPos.IncRow(); m_pDoc->SetString( aPos, "=SUM(B2:B2:Sheet1.B2)"); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM(Sheet1.B2:B2)", "Wrong formula."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=SUM(Sheet1.B2:B2)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); CPPUNIT_ASSERT_EQUAL( 2.0, m_pDoc->GetValue(aPos)); aPos.IncRow(); m_pDoc->SetString( aPos, "=SUM(B2:B3:Sheet2.B1)"); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM(Sheet1.B1:Sheet2.B3)", "Wrong formula."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=SUM(Sheet1.B1:Sheet2.B3)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); CPPUNIT_ASSERT_EQUAL( 63.0, m_pDoc->GetValue(aPos)); aPos.IncRow(); m_pDoc->SetString( aPos, "=SUM(Sheet1.B1:Sheet2.B2:Sheet3.B3)"); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM(Sheet1.B1:Sheet3.B3)", "Wrong formula."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=SUM(Sheet1.B1:Sheet3.B3)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); CPPUNIT_ASSERT_EQUAL( 511.0, m_pDoc->GetValue(aPos)); // B1:Sheet2.B2 would be ambiguous, Sheet1.B1:Sheet2.B2 or Sheet2.B1:B2 @@ -7388,17 +7387,17 @@ void TestFormula::testFuncRangeOp() // have to be adapted. aPos.IncRow(); m_pDoc->SetString( aPos, "=SUM(B1:Sheet2.B2:Sheet3.B3)"); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM(b1:sheet2.b2:Sheet3.B3)", "Wrong formula."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=SUM(b1:sheet2.b2:Sheet3.B3)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); CPPUNIT_ASSERT_EQUAL( OUString("#NAME?"), m_pDoc->GetString(aPos)); aPos.IncRow(); m_pDoc->SetString( aPos, "=SUM(Sheet1.B1:Sheet3.B2:Sheet2.B3)"); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM(Sheet1.B1:Sheet3.B3)", "Wrong formula."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=SUM(Sheet1.B1:Sheet3.B3)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); CPPUNIT_ASSERT_EQUAL( 511.0, m_pDoc->GetValue(aPos)); aPos.IncRow(); m_pDoc->SetString( aPos, "=SUM(B$2:B$2:B2)"); - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM(B$2:B2)", "Wrong formula."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula.", OUString("=SUM(B$2:B2)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); CPPUNIT_ASSERT_EQUAL( 2.0, m_pDoc->GetValue(aPos)); m_pDoc->DeleteTab(2); @@ -7620,18 +7619,18 @@ void TestFormula::testFuncTableRef() // Set header in column B. Use ScDocFunc to have table column names refreshed. rDocFunc.SetStringCell(ScAddress(1,0,0), "NewHeader",true); // Verify that formula adapted using the updated table column names. - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,5,0), "SUM(table[[#Data];[NewHeader]])", "Wrong formula"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=SUM(table[[#Data];[NewHeader]])"), m_pDoc->GetFormula(1,5,0)); // Set header in column A to identical string. Internal table column name // for B should get a "2" appended. rDocFunc.SetStringCell(ScAddress(0,0,0), "NewHeader",true); // Verify that formula adapted using the updated table column names. - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,5,0), "SUM(table[[#Data];[NewHeader2]])", "Wrong formula"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=SUM(table[[#Data];[NewHeader2]])"), m_pDoc->GetFormula(1,5,0)); // Set header in column B to empty string, effectively clearing the cell. rDocFunc.SetStringCell(ScAddress(1,0,0), "",true); // Verify that formula is still using the previous table column name. - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,5,0), "SUM(table[[#Data];[NewHeader2]])", "Wrong formula"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=SUM(table[[#Data];[NewHeader2]])"), m_pDoc->GetFormula(1,5,0)); // === header-less === @@ -9732,7 +9731,7 @@ void TestFormula::testFormulaAfterDeleteRows() m_pDoc->DeleteRow(ScRange(0, 1, 0, m_pDoc->MaxCol(), 69997, 0)); const ScAddress aPos(0, 3, 0); // A4 - ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM(A1:A3)", "Wrong formula in A4."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A4.", OUString("=SUM(A1:A3)"), m_pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); ASSERT_DOUBLES_EQUAL_MESSAGE("Wrong value at A4", 3.0, m_pDoc->GetValue(aPos)); } diff --git a/sc/qa/unit/ucalc_sharedformula.cxx b/sc/qa/unit/ucalc_sharedformula.cxx index 0d2275c42b31..a5cb151f0f9b 100644 --- a/sc/qa/unit/ucalc_sharedformula.cxx +++ b/sc/qa/unit/ucalc_sharedformula.cxx @@ -382,9 +382,9 @@ void TestSharedFormula::testSharedFormulasRefUpdate() insertRangeData(m_pDoc, ScAddress(1,0,0), aData); } - 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"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in B1", OUString("=A10"), m_pDoc->GetFormula(1,0,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in B2", OUString("=A11"), m_pDoc->GetFormula(1,1,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in B3", OUString("=A12"), m_pDoc->GetFormula(1,2,0)); const ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1,0,0)); CPPUNIT_ASSERT_MESSAGE("This must be a shared formula cell.", pFC); @@ -394,9 +394,9 @@ void TestSharedFormula::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)); - 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"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in B1", OUString("=A10"), m_pDoc->GetFormula(1,0,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in B2", OUString("=C11"), m_pDoc->GetFormula(1,1,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in B3", OUString("=A12"), m_pDoc->GetFormula(1,2,0)); pFC = m_pDoc->GetFormulaCell(ScAddress(1,0,0)); CPPUNIT_ASSERT_MESSAGE("B1 should be a non-shared formula cell.", pFC); @@ -411,9 +411,9 @@ void TestSharedFormula::testSharedFormulasRefUpdate() // Delete cells over A11:B11 to bring it back to the previous state. m_pDoc->DeleteCol(ScRange(0,10,0,1,10,0)); - 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"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in B1", OUString("=A10"), m_pDoc->GetFormula(1,0,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in B2", OUString("=A11"), m_pDoc->GetFormula(1,1,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in B3", OUString("=A12"), m_pDoc->GetFormula(1,2,0)); pFC = m_pDoc->GetFormulaCell(ScAddress(1,0,0)); CPPUNIT_ASSERT_MESSAGE("This must be a shared formula cell.", pFC); @@ -423,9 +423,9 @@ void TestSharedFormula::testSharedFormulasRefUpdate() // Insert cells over A11:A12 and shift down. m_pDoc->InsertRow(ScRange(0,10,0,0,11,0)); - 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"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in B1", OUString("=A10"), m_pDoc->GetFormula(1,0,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in B2", OUString("=A13"), m_pDoc->GetFormula(1,1,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in B3", OUString("=A14"), m_pDoc->GetFormula(1,2,0)); pFC = m_pDoc->GetFormulaCell(ScAddress(1,0,0)); CPPUNIT_ASSERT_MESSAGE("B1 should be a non-shared formula cell.", pFC); @@ -439,9 +439,9 @@ void TestSharedFormula::testSharedFormulasRefUpdate() // Delete A11:A12 to bring it back to the way it was. m_pDoc->DeleteRow(ScRange(0,10,0,0,11,0)); - 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"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in B1", OUString("=A10"), m_pDoc->GetFormula(1,0,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in B2", OUString("=A11"), m_pDoc->GetFormula(1,1,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in B3", OUString("=A12"), m_pDoc->GetFormula(1,2,0)); pFC = m_pDoc->GetFormulaCell(ScAddress(1,0,0)); CPPUNIT_ASSERT_MESSAGE("This must be a shared formula cell.", pFC); @@ -451,9 +451,9 @@ void TestSharedFormula::testSharedFormulasRefUpdate() // Insert cells over A11:B11 to shift to right again. m_pDoc->InsertCol(ScRange(0,10,0,1,10,0)); - 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"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in B1", OUString("=A10"), m_pDoc->GetFormula(1,0,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in B2", OUString("=C11"), m_pDoc->GetFormula(1,1,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in B3", OUString("=A12"), m_pDoc->GetFormula(1,2,0)); pFC = m_pDoc->GetFormulaCell(ScAddress(1,0,0)); CPPUNIT_ASSERT_MESSAGE("B1 should be a non-shared formula cell.", pFC); @@ -467,9 +467,9 @@ void TestSharedFormula::testSharedFormulasRefUpdate() // Insert cells over A12:B12 to shift to right. m_pDoc->InsertCol(ScRange(0,11,0,1,11,0)); - 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"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in B1", OUString("=A10"), m_pDoc->GetFormula(1,0,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in B2", OUString("=C11"), m_pDoc->GetFormula(1,1,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in B3", OUString("=C12"), m_pDoc->GetFormula(1,2,0)); pFC = m_pDoc->GetFormulaCell(ScAddress(1,0,0)); CPPUNIT_ASSERT_MESSAGE("B1 should be a non-shared formula cell.", pFC); @@ -483,9 +483,9 @@ void TestSharedFormula::testSharedFormulasRefUpdate() // Insert cells over A10:B10 to shift to right. m_pDoc->InsertCol(ScRange(0,9,0,1,9,0)); - 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"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in B1", OUString("=C10"), m_pDoc->GetFormula(1,0,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in B2", OUString("=C11"), m_pDoc->GetFormula(1,1,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in B3", OUString("=C12"), m_pDoc->GetFormula(1,2,0)); // B1:B3 should be now grouped. pFC = m_pDoc->GetFormulaCell(ScAddress(1,0,0)); @@ -537,9 +537,9 @@ void TestSharedFormula::testSharedFormulasRefUpdateMove() CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(1,2,0))); // The formulas should have been adjusted for the move. - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2,1,0), "R[-1]C[-1]", "Wrong formula"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2,2,0), "R[-1]C[-1]", "Wrong formula"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2,3,0), "R[-1]C[-1]", "Wrong formula"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=R[-1]C[-1]"), m_pDoc->GetFormula(2,1,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=R[-1]C[-1]"), m_pDoc->GetFormula(2,2,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=R[-1]C[-1]"), m_pDoc->GetFormula(2,3,0)); SfxUndoManager* pUndoMgr = m_pDoc->GetUndoManager(); CPPUNIT_ASSERT(pUndoMgr); @@ -551,9 +551,9 @@ void TestSharedFormula::testSharedFormulasRefUpdateMove() CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(1,3,0))); // And the formulas should have been re-adjusted to their original references. - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2,1,0), "RC[-1]", "Wrong formula"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2,2,0), "RC[-1]", "Wrong formula"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2,3,0), "RC[-1]", "Wrong formula"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=RC[-1]"), m_pDoc->GetFormula(2,1,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=RC[-1]"), m_pDoc->GetFormula(2,2,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=RC[-1]"), m_pDoc->GetFormula(2,3,0)); m_pDoc->DeleteTab(0); } @@ -650,9 +650,9 @@ void TestSharedFormula::testSharedFormulasRefUpdateRange() insertRangeData(m_pDoc, ScAddress(1,2,0), aData); } - 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"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=SUM($A$3:$A$5)"), m_pDoc->GetFormula(1,2,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=SUM($A$3:$A$5)"), m_pDoc->GetFormula(1,3,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=SUM($A$3:$A$5)"), m_pDoc->GetFormula(1,4,0)); // B3:B5 should be shared. const ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1,2,0)); @@ -682,9 +682,9 @@ void TestSharedFormula::testSharedFormulasRefUpdateRange() CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(4), pFC->GetSharedTopRow()); CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(3), pFC->GetSharedLength()); - 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"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=SUM($A$5:$A$7)"), m_pDoc->GetFormula(1,4,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=SUM($A$5:$A$7)"), m_pDoc->GetFormula(1,5,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=SUM($A$5:$A$7)"), m_pDoc->GetFormula(1,6,0)); m_pDoc->DeleteTab(0); } @@ -874,10 +874,10 @@ void TestSharedFormula::testSharedFormulasRefUpdateExternal() CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(0,9,0))); // Check the formulas too. - 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!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("='file:///extdata.fake'#$Data.A1"), m_pDoc->GetFormula(0,6,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("='file:///extdata.fake'#$Data.A2"), m_pDoc->GetFormula(0,7,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("='file:///extdata.fake'#$Data.A3"), m_pDoc->GetFormula(0,8,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=COUNTA('file:///extdata.fake'#$Data.A1:A3)"), m_pDoc->GetFormula(0,9,0)); // Delete rows 1 and 2. This should not change the references in the formula cells below. ScDocFunc& rDocFunc = m_xDocShell->GetDocFunc(); @@ -886,26 +886,26 @@ void TestSharedFormula::testSharedFormulasRefUpdateExternal() rDocFunc.DeleteCells(ScRange(0,0,0,m_pDoc->MaxCol(),1,0), &aMark, DelCellCmd::CellsUp, true); // Check the shifted formula cells now in A5:A8. - 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!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("='file:///extdata.fake'#$Data.A1"), m_pDoc->GetFormula(0,4,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("='file:///extdata.fake'#$Data.A2"), m_pDoc->GetFormula(0,5,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("='file:///extdata.fake'#$Data.A3"), m_pDoc->GetFormula(0,6,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=COUNTA('file:///extdata.fake'#$Data.A1:A3)"), m_pDoc->GetFormula(0,7,0)); // Undo and check the formulas again. SfxUndoManager* pUndoMgr = m_pDoc->GetUndoManager(); CPPUNIT_ASSERT(pUndoMgr); pUndoMgr->Undo(); - 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!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("='file:///extdata.fake'#$Data.A1"), m_pDoc->GetFormula(0,6,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("='file:///extdata.fake'#$Data.A2"), m_pDoc->GetFormula(0,7,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("='file:///extdata.fake'#$Data.A3"), m_pDoc->GetFormula(0,8,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=COUNTA('file:///extdata.fake'#$Data.A1:A3)"), m_pDoc->GetFormula(0,9,0)); // Redo the row deletion and check the formulas again. pUndoMgr->Redo(); - 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!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("='file:///extdata.fake'#$Data.A1"), m_pDoc->GetFormula(0,4,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("='file:///extdata.fake'#$Data.A2"), m_pDoc->GetFormula(0,5,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("='file:///extdata.fake'#$Data.A3"), m_pDoc->GetFormula(0,6,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=COUNTA('file:///extdata.fake'#$Data.A1:A3)"), m_pDoc->GetFormula(0,7,0)); xExtDocSh->DoClose(); @@ -923,7 +923,7 @@ void TestSharedFormula::testSharedFormulasInsertRow() for (size_t i = 0; i < SAL_N_ELEMENTS(pRows); ++i) { ScAddress aPos(1, pRows[i], 0); - ASSERT_FORMULA_EQUAL(*pDoc, aPos, "$A$5", "Wrong formula!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=$A$5"), pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); } // B1:B2 should be grouped. @@ -950,7 +950,7 @@ void TestSharedFormula::testSharedFormulasInsertRow() for (SCROW i = 0; i <= 3; ++i) { ScAddress aPos(1,i,0); - ASSERT_FORMULA_EQUAL(*pDoc, aPos, "$A$4", "Wrong formula!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=$A$4"), pDoc->GetFormula(aPos.Col(), aPos.Row(), aPos.Tab())); } // Ensure that B5 is empty. @@ -1241,7 +1241,7 @@ void TestSharedFormula::testSharedFormulasRefUpdateMoveSheets() for (SCROW i = 0; i <= 7; ++i) { CPPUNIT_ASSERT_EQUAL(static_cast<double>(i+1), m_pDoc->GetValue(ScAddress(0,i,1))); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,i,1), "Sheet2!RC", "Wrong formula expression."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula expression.", OUString("=Sheet2!RC"), m_pDoc->GetFormula(0,i,1)); } // Insert a new sheet at the left end. @@ -1259,7 +1259,7 @@ void TestSharedFormula::testSharedFormulasRefUpdateMoveSheets() for (SCROW i = 0; i <= 7; ++i) { CPPUNIT_ASSERT_EQUAL(static_cast<double>(i+1), m_pDoc->GetValue(ScAddress(0,i,2))); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,i,2), "Sheet2!RC", "Wrong formula expression."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula expression.", OUString("=Sheet2!RC"), m_pDoc->GetFormula(0,i,2)); } // Delete Sheet4. @@ -1276,7 +1276,7 @@ void TestSharedFormula::testSharedFormulasRefUpdateMoveSheets() for (SCROW i = 0; i <= 7; ++i) { CPPUNIT_ASSERT_EQUAL(static_cast<double>(i+1), m_pDoc->GetValue(ScAddress(0,i,1))); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,i,1), "Sheet2!RC", "Wrong formula expression."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula expression.", OUString("=Sheet2!RC"), m_pDoc->GetFormula(0,i,1)); } m_pDoc->DeleteTab(2); @@ -1304,8 +1304,8 @@ void TestSharedFormula::testSharedFormulasRefUpdateCopySheets() // Copy Sheet1 and insert the copied sheet before the current Sheet1 position. m_pDoc->CopyTab(0, 0); - 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"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=$Sheet2.A1"), m_pDoc->GetFormula(0,0,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=$Sheet2.A2"), m_pDoc->GetFormula(0,1,0)); // Check the values on the copied sheet. CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(0,0,0))); @@ -1342,26 +1342,26 @@ void TestSharedFormula::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))); - 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"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=Sheet2.B2"), m_pDoc->GetFormula(0,0,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=Sheet2.B3"), m_pDoc->GetFormula(0,1,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=Sheet2.B4"), m_pDoc->GetFormula(0,2,0)); // Delete Sheet2. ScDocFunc& rFunc = m_xDocShell->GetDocFunc(); rFunc.DeleteTable(1, true); - 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"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=#REF!.B2"), m_pDoc->GetFormula(0,0,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=#REF!.B3"), m_pDoc->GetFormula(0,1,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=#REF!.B4"), m_pDoc->GetFormula(0,2,0)); // 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(); - 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"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=Sheet2.B2"), m_pDoc->GetFormula(0,0,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=Sheet2.B3"), m_pDoc->GetFormula(0,1,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula", OUString("=Sheet2.B4"), m_pDoc->GetFormula(0,2,0)); // TODO: We can't test redo yet as ScUndoDeleteTab::Redo() relies on // view shell to do its thing. @@ -1460,8 +1460,8 @@ void TestSharedFormula::testSharedFormulaInsertColumn() // Insert a single column at Column F. This used to crash before fdo#74041. m_pDoc->InsertCol(ScRange(5,0,0,5,m_pDoc->MaxRow(),0)); - 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!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=H3*B3"), m_pDoc->GetFormula(8,1,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=H4*B4"), m_pDoc->GetFormula(8,2,0)); m_pDoc->DeleteTab(0); } @@ -1651,13 +1651,13 @@ void TestSharedFormula::testSharedFormulaUpdateOnNamedRangeChange() rFunc.ModifyAllRangeNames(aNewNames); // Check to make sure all displayed formulas are still good. - 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!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=SUM(MyRange)"), m_pDoc->GetFormula(1,0,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=SUM(MyRange)"), m_pDoc->GetFormula(1,1,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=SUM(MyRange)"), m_pDoc->GetFormula(1,2,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=ROW()"), m_pDoc->GetFormula(1,4,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=ROW()"), m_pDoc->GetFormula(1,6,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=ROW()"), m_pDoc->GetFormula(1,7,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=AVERAGE(MyRange)"), m_pDoc->GetFormula(2,0,0)); // Check the calculation results as well. CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(ScAddress(1,0,0))); diff --git a/sc/qa/unit/ucalc_sort.cxx b/sc/qa/unit/ucalc_sort.cxx index f3008d85a131..26449c4302d9 100644 --- a/sc/qa/unit/ucalc_sort.cxx +++ b/sc/qa/unit/ucalc_sort.cxx @@ -234,9 +234,9 @@ void TestSort::testSortHorizontal() CPPUNIT_ASSERT_MESSAGE("Table output check failed", bSuccess); } - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,1,0), "CONCATENATE(C2;\"-\";D2)", "Wrong formula!"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,2,0), "CONCATENATE(C3;\"-\";D3)", "Wrong formula!"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,3,0), "CONCATENATE(C4;\"-\";D4)", "Wrong formula!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=CONCATENATE(C2;\"-\";D2)"), m_pDoc->GetFormula(1,1,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=CONCATENATE(C3;\"-\";D3)"), m_pDoc->GetFormula(1,2,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=CONCATENATE(C4;\"-\";D4)"), m_pDoc->GetFormula(1,3,0)); m_pDoc->DeleteTab(0); } @@ -805,7 +805,7 @@ void TestSort::testSortRefUpdate() } // C2 should now point to A4. - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2,1,0), "R[2]C[-2]", "Wrong formula in C2!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in C2!", OUString("=R[2]C[-2]"), m_pDoc->GetFormula(2,1,0)); // Undo the sort. SfxUndoManager* pUndoMgr = m_pDoc->GetUndoManager(); @@ -828,7 +828,7 @@ void TestSort::testSortRefUpdate() } // C2 should now point to A2. - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2,1,0), "RC[-2]", "Wrong formula in C2!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in C2!", OUString("=RC[-2]"), m_pDoc->GetFormula(2,1,0)); // Redo. pUndoMgr->Redo(); @@ -849,7 +849,7 @@ void TestSort::testSortRefUpdate() } // C2 should now point to A4. - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2,1,0), "R[2]C[-2]", "Wrong formula in C2!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in C2!", OUString("=R[2]C[-2]"), m_pDoc->GetFormula(2,1,0)); // Undo again. pUndoMgr->Undo(); @@ -952,7 +952,7 @@ void TestSort::testSortRefUpdate2() // Formulas in column B should still point to their respective left neighbor cell. for (SCROW i = 1; i <= 4; ++i) { - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,i,0), "RC[-1]", "Wrong formula!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=RC[-1]"), m_pDoc->GetFormula(1,i,0)); } // Undo and check the result in column B. @@ -1032,9 +1032,9 @@ void TestSort::testSortRefUpdate3() CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(ScAddress(0,5,0))); // Make sure the formula cells have been adjusted correctly. - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,3,0), "A2+A3", "Wrong formula in A4."); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,4,0), "A2+10", "Wrong formula in A5."); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,5,0), "A3+10", "Wrong formula in A6."); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A4.", OUString("=A2+A3"), m_pDoc->GetFormula(0,3,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A5.", OUString("=A2+10"), m_pDoc->GetFormula(0,4,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula in A6.", OUString("=A3+10"), m_pDoc->GetFormula(0,5,0)); // Undo and check the result. SfxUndoManager* pUndoMgr = m_pDoc->GetUndoManager(); @@ -1171,17 +1171,17 @@ void TestSort::testSortRefUpdate4_Impl() // Make sure the formula cells have been adjusted correctly. const char* aCheck[][4] = { // Name Lesson1 Lesson2 Average - { "Lesson1.A4", "Lesson1.B4", "Lesson2.B4", "AVERAGE(B2:C2)" }, - { "Lesson1.A5", "Lesson1.B5", "Lesson2.B5", "AVERAGE(B3:C3)" }, - { "Lesson1.A6", "Lesson1.B6", "Lesson2.B6", "AVERAGE(B4:C4)" }, - { "Lesson1.A3", "Lesson1.B3", "Lesson2.B3", "AVERAGE(B5:C5)" }, - { "Lesson1.A2", "Lesson1.B2", "Lesson2.B2", "AVERAGE(B6:C6)" }, + { "=Lesson1.A4", "=Lesson1.B4", "=Lesson2.B4", "=AVERAGE(B2:C2)" }, + { "=Lesson1.A5", "=Lesson1.B5", "=Lesson2.B5", "=AVERAGE(B3:C3)" }, + { "=Lesson1.A6", "=Lesson1.B6", "=Lesson2.B6", "=AVERAGE(B4:C4)" }, + { "=Lesson1.A3", "=Lesson1.B3", "=Lesson2.B3", "=AVERAGE(B5:C5)" }, + { "=Lesson1.A2", "=Lesson1.B2", "=Lesson2.B2", "=AVERAGE(B6:C6)" }, }; for (SCROW nRow=0; nRow < static_cast<SCROW>(SAL_N_ELEMENTS(aCheck)); ++nRow) { for (SCCOL nCol=0; nCol < 4; ++nCol) { - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(nCol,nRow+1,0), aCheck[nRow][nCol], OString("Wrong formula in " + OStringChar(char('A'+nCol)) + OString::number(nRow+2) + ".").getStr()); + CPPUNIT_ASSERT_EQUAL_MESSAGE(OString("Wrong formula in " + OStringChar(char('A'+nCol)) + OString::number(nRow+2) + ".").getStr(), OUString::createFromAscii(aCheck[nRow][nCol]), m_pDoc->GetFormula(nCol,nRow+1,0)); } } @@ -1242,17 +1242,17 @@ void TestSort::testSortRefUpdate4_Impl() // Make sure the formula cells have been adjusted correctly. const char* aCheck[][4] = { // Name Lesson1 Lesson2 Average - { "Lesson1.A6", "Lesson1.B6", "Lesson2.B6", "AVERAGE(B2:C2)" }, - { "Lesson1.A5", "Lesson1.B5", "Lesson2.B5", "AVERAGE(B3:C3)" }, - { "Lesson1.A4", "Lesson1.B4", "Lesson2.B4", "AVERAGE(B4:C4)" }, - { "Lesson1.A3", "Lesson1.B3", "Lesson2.B3", "AVERAGE(B5:C5)" }, - { "Lesson1.A2", "Lesson1.B2", "Lesson2.B2", "AVERAGE(B6:C6)" }, + { "=Lesson1.A6", "=Lesson1.B6", "=Lesson2.B6", "=AVERAGE(B2:C2)" }, + { "=Lesson1.A5", "=Lesson1.B5", "=Lesson2.B5", "=AVERAGE(B3:C3)" }, + { "=Lesson1.A4", "=Lesson1.B4", "=Lesson2.B4", "=AVERAGE(B4:C4)" }, + { "=Lesson1.A3", "=Lesson1.B3", "=Lesson2.B3", "=AVERAGE(B5:C5)" }, + { "=Lesson1.A2", "=Lesson1.B2", "=Lesson2.B2", "=AVERAGE(B6:C6)" }, }; for (SCROW nRow=0; nRow < static_cast<SCROW>(SAL_N_ELEMENTS(aCheck)); ++nRow) { for (SCCOL nCol=0; nCol < 4; ++nCol) { - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(nCol,nRow+1,0), aCheck[nRow][nCol], OString("Wrong formula in " + OStringChar(char('A'+nCol)) + OString::number(nRow+2) + ".").getStr()); + CPPUNIT_ASSERT_EQUAL_MESSAGE(OString("Wrong formula in " + OStringChar(char('A'+nCol)) + OString::number(nRow+2) + ".").getStr(), OUString::createFromAscii(aCheck[nRow][nCol]), m_pDoc->GetFormula(nCol,nRow+1,0)); } } } @@ -1338,14 +1338,14 @@ void TestSort::testSortRefUpdate5() // Make sure the formula cells have been adjusted correctly. const char* aFormulaCheck[] = { // Volatile - "TODAY()-$A2", - "TODAY()-$A3", - "TODAY()-$A4", - "TODAY()-$A5", + "=TODAY()-$A2", + "=TODAY()-$A3", + "=TODAY()-$A4", + "=TODAY()-$A5", }; for (SCROW nRow=0; nRow < static_cast<SCROW>(SAL_N_ELEMENTS(aFormulaCheck)); ++nRow) { - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,nRow+1,0), aFormulaCheck[nRow], OString("Wrong formula in B" + OString::number(nRow+2) + ".").getStr()); + CPPUNIT_ASSERT_EQUAL_MESSAGE(OString("Wrong formula in B" + OString::number(nRow+2) + ".").getStr(), OUString::createFromAscii(aFormulaCheck[nRow]), m_pDoc->GetFormula(1,nRow+1,0)); } // Undo and check the result. @@ -1435,9 +1435,9 @@ void TestSort::testSortRefUpdate6() } // Make sure that the formulas in C2:C4 are not adjusted. - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2,1,0), "C1+B2", "Wrong formula!"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2,2,0), "C2+B3", "Wrong formula!"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2,3,0), "C3+B4", "Wrong formula!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=C1+B2"), m_pDoc->GetFormula(2,1,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=C2+B3"), m_pDoc->GetFormula(2,2,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=C3+B4"), m_pDoc->GetFormula(2,3,0)); // Undo and check. SfxUndoManager* pUndoMgr = m_pDoc->GetUndoManager(); @@ -1569,14 +1569,14 @@ void TestSort::testSortBroadcaster() } // Make sure that the formulas in D1:G2 are not adjusted. - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(3,0,0), "B1", "Wrong formula!"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(3,1,0), "B2", "Wrong formula!"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(4,0,0), "$B$1", "Wrong formula!"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(4,1,0), "$B$2", "Wrong formula!"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(5,0,0), "SUM(A1:B1)", "Wrong formula!"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(5,1,0), "SUM(A2:B2)", "Wrong formula!"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(6,0,0), "SUM($A$1:$B$1)", "Wrong formula!"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(6,1,0), "SUM($A$2:$B$2)", "Wrong formula!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=B1"), m_pDoc->GetFormula(3,0,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=B2"), m_pDoc->GetFormula(3,1,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=$B$1"), m_pDoc->GetFormula(4,0,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=$B$2"), m_pDoc->GetFormula(4,1,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=SUM(A1:B1)"), m_pDoc->GetFormula(5,0,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=SUM(A2:B2)"), m_pDoc->GetFormula(5,1,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=SUM($A$1:$B$1)"), m_pDoc->GetFormula(6,0,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=SUM($A$2:$B$2)"), m_pDoc->GetFormula(6,1,0)); // Enter new value and check that it is broadcasted. First in empty cell. m_pDoc->SetString(1,1,0, "16"); @@ -1671,14 +1671,14 @@ void TestSort::testSortBroadcaster() } // Make sure that the formulas in A8:B11 are not adjusted. - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,7,0), "A6", "Wrong formula!"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,7,0), "B6", "Wrong formula!"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,8,0), "$A$6", "Wrong formula!"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,8,0), "$B$6", "Wrong formula!"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,9,0), "SUM(A5:A6)", "Wrong formula!"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,9,0), "SUM(B5:B6)", "Wrong formula!"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(0,10,0), "SUM($A$5:$A$6)", "Wrong formula!"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,10,0), "SUM($B$5:$B$6)", "Wrong formula!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=A6"), m_pDoc->GetFormula(0,7,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=B6"), m_pDoc->GetFormula(1,7,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=$A$6"), m_pDoc->GetFormula(0,8,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=$B$6"), m_pDoc->GetFormula(1,8,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=SUM(A5:A6)"), m_pDoc->GetFormula(0,9,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=SUM(B5:B6)"), m_pDoc->GetFormula(1,9,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=SUM($A$5:$A$6)"), m_pDoc->GetFormula(0,10,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=SUM($B$5:$B$6)"), m_pDoc->GetFormula(1,10,0)); // Enter new value and check that it is broadcasted. First in empty cell. m_pDoc->SetString(1,5,0, "16"); @@ -1769,10 +1769,10 @@ void TestSort::testSortBroadcastBroadcaster() } // Make sure that the formulas in B1:C2 are not adjusted. - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,0,0), "A1", "Wrong formula!"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(1,1,0), "A2", "Wrong formula!"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2,0,0), "B1", "Wrong formula!"); - ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2,1,0), "B2", "Wrong formula!"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=A1"), m_pDoc->GetFormula(1,0,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=A2"), m_pDoc->GetFormula(1,1,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=B1"), m_pDoc->GetFormula(2,0,0)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula!", OUString("=B2"), m_pDoc->GetFormula(2,1,0)); } m_pDoc->DeleteTab(0); |