sc/qa/extras/anchor.cxx | 16 +++++------ sc/qa/extras/macros-test.cxx | 8 ++--- sc/qa/unit/subsequent_filters-test.cxx | 48 ++++++++++++++++----------------- 3 files changed, 36 insertions(+), 36 deletions(-)
New commits: commit 2b04d710a27edb16bb6c47fd572a8c81d265b046 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Mon Nov 28 09:31:18 2016 +0100 sc: fix remaining loplugin:cppunitassertequals warnings Change-Id: I12191d1fd776d617d9418079b77b4c8e84d199a3 Reviewed-on: https://gerrit.libreoffice.org/31306 Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> Tested-by: Jenkins <c...@libreoffice.org> diff --git a/sc/qa/extras/anchor.cxx b/sc/qa/extras/anchor.cxx index 8233705..b5310ab 100644 --- a/sc/qa/extras/anchor.cxx +++ b/sc/qa/extras/anchor.cxx @@ -95,13 +95,13 @@ void ScAnchorTest::testUndoAnchor() ScDrawLayer::SetCellAnchoredFromPosition(*pObject, rDoc, 0); // Check state ScAnchorType oldType = ScDrawLayer::GetAnchorType(*pObject); - CPPUNIT_ASSERT(oldType == SCA_CELL ); + CPPUNIT_ASSERT_EQUAL(SCA_CELL, oldType); // Change all selected objects to page anchor pViewShell->GetViewData().GetDispatcher().Execute(SID_ANCHOR_PAGE); // Check state ScAnchorType newType = ScDrawLayer::GetAnchorType(*pObject); - CPPUNIT_ASSERT(newType == SCA_PAGE ); + CPPUNIT_ASSERT_EQUAL(SCA_PAGE, newType); // Undo and check its result. SfxUndoManager* pUndoMgr = rDoc.GetUndoManager(); @@ -109,39 +109,39 @@ void ScAnchorTest::testUndoAnchor() pUndoMgr->Undo(); // Check anchor type - CPPUNIT_ASSERT(oldType == ScDrawLayer::GetAnchorType(*pObject) ); + CPPUNIT_ASSERT_EQUAL(oldType, ScDrawLayer::GetAnchorType(*pObject)); CPPUNIT_ASSERT_EQUAL(int(GraphicType::Bitmap), int(rGraphicObj.GetGraphic().GetType())); CPPUNIT_ASSERT_EQUAL(sal_uLong(864900), rGraphicObj.GetSizeBytes()); pUndoMgr->Redo(); // Check anchor type - CPPUNIT_ASSERT(newType == ScDrawLayer::GetAnchorType(*pObject) ); + CPPUNIT_ASSERT_EQUAL(newType, ScDrawLayer::GetAnchorType(*pObject)); CPPUNIT_ASSERT_EQUAL(int(GraphicType::Bitmap), int(rGraphicObj.GetGraphic().GetType())); CPPUNIT_ASSERT_EQUAL(sal_uLong(864900), rGraphicObj.GetSizeBytes()); ScDrawLayer::SetPageAnchored(*pObject); // Check state oldType = ScDrawLayer::GetAnchorType(*pObject); - CPPUNIT_ASSERT(oldType == SCA_PAGE ); + CPPUNIT_ASSERT_EQUAL(SCA_PAGE, oldType); // Change all selected objects to cell anchor pViewShell->GetViewData().GetDispatcher().Execute(SID_ANCHOR_CELL); // Check state newType = ScDrawLayer::GetAnchorType(*pObject); - CPPUNIT_ASSERT(newType == SCA_CELL ); + CPPUNIT_ASSERT_EQUAL(SCA_CELL, newType); pUndoMgr->Undo(); // Check anchor type - CPPUNIT_ASSERT(oldType == ScDrawLayer::GetAnchorType(*pObject) ); + CPPUNIT_ASSERT_EQUAL(oldType, ScDrawLayer::GetAnchorType(*pObject)); CPPUNIT_ASSERT_EQUAL(int(GraphicType::Bitmap), int(rGraphicObj.GetGraphic().GetType())); CPPUNIT_ASSERT_EQUAL(sal_uLong(864900), rGraphicObj.GetSizeBytes()); pUndoMgr->Redo(); // Check anchor type - CPPUNIT_ASSERT(newType == ScDrawLayer::GetAnchorType(*pObject) ); + CPPUNIT_ASSERT_EQUAL(newType, ScDrawLayer::GetAnchorType(*pObject)); CPPUNIT_ASSERT_EQUAL(int(GraphicType::Bitmap), int(rGraphicObj.GetGraphic().GetType())); CPPUNIT_ASSERT_EQUAL(sal_uLong(864900), rGraphicObj.GetSizeBytes()); diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx index 064dccd..591a7f8 100644 --- a/sc/qa/extras/macros-test.cxx +++ b/sc/qa/extras/macros-test.cxx @@ -91,7 +91,7 @@ void ScMacrosTest::testMSP() aRet >>= sResult; SAL_INFO("sc.qa", "Result is " << sResult ); - CPPUNIT_ASSERT_MESSAGE("TestMSP ( for fdo#67547) failed", sResult == "OK" ); + CPPUNIT_ASSERT_EQUAL_MESSAGE("TestMSP ( for fdo#67547) failed", OUString("OK"), sResult); pDocSh->DoClose(); } @@ -124,7 +124,7 @@ void ScMacrosTest::testPasswordProtectedStarBasic() aParams, aRet, aOutParamIndex, aOutParam); OUString aValue = rDoc.GetString(0,0,0); - CPPUNIT_ASSERT_MESSAGE("User defined types script did not change the value of Sheet1.A1", aValue == "success"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("User defined types script did not change the value of Sheet1.A1", OUString("success"), aValue); // Big Module @@ -134,7 +134,7 @@ void ScMacrosTest::testPasswordProtectedStarBasic() aParams, aRet, aOutParamIndex, aOutParam); aValue = rDoc.GetString(1,0,0); - CPPUNIT_ASSERT_MESSAGE("Big module script did not change the value of Sheet1.B1", aValue == "success"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Big module script did not change the value of Sheet1.B1", OUString("success"), aValue); // far big method tdf#94617 @@ -144,7 +144,7 @@ void ScMacrosTest::testPasswordProtectedStarBasic() aParams, aRet, aOutParamIndex, aOutParam); aValue = rDoc.GetString(2,0,0); - CPPUNIT_ASSERT_MESSAGE("Far Method script did not change the value of Sheet1.C1", aValue == "success"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Far Method script did not change the value of Sheet1.C1", OUString("success"), aValue); pDocSh->DoClose(); diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index 3b5efca..30b003b 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -1560,7 +1560,7 @@ void ScFiltersTest::testRowIndex1BasedXLSX() // B2 - multi-line text. const EditTextObject* pText = rDoc.GetEditText(ScAddress(1,1,0)); CPPUNIT_ASSERT(pText); - CPPUNIT_ASSERT(pText->GetParagraphCount() == 3); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), pText->GetParagraphCount()); aStr = pText->GetText(0); CPPUNIT_ASSERT_EQUAL(OUString("This is a longer Text."), aStr); aStr = pText->GetText(1); @@ -1902,8 +1902,8 @@ void ScFiltersTest::testPivotTableNamedRangeSourceODS() sal_uInt16 nOrient; long nDim = pDP->GetHeaderDim(ScAddress(0,1,1), nOrient); CPPUNIT_ASSERT_EQUAL_MESSAGE("Failed to detect header dimension.", long(0), nDim); - CPPUNIT_ASSERT_MESSAGE("This dimension should be a page dimension.", - nOrient == sheet::DataPilotFieldOrientation_PAGE); + CPPUNIT_ASSERT_EQUAL_MESSAGE("This dimension should be a page dimension.", + static_cast<sal_uInt16>(sheet::DataPilotFieldOrientation_PAGE), nOrient); xDocSh->DoClose(); } @@ -2027,7 +2027,7 @@ void ScFiltersTest::testPivotTableSharedCacheGroupODS() for (sal_Int32 i = 1; i <= 12; ++i) aChecks.push_back(i); // January through December. aChecks.push_back(ScDPItemData::DateLast); - CPPUNIT_ASSERT_MESSAGE("Unexpected group values for the month group.", aGrpValues == aChecks); + CPPUNIT_ASSERT_MESSAGE("Unexpected group values for the month group.", bool(aGrpValues == aChecks)); } break; case sheet::DataPilotFieldGroupBy::YEARS: @@ -2058,7 +2058,7 @@ void ScFiltersTest::testPivotTableSharedCacheGroupODS() aChecks.push_back(2012); aChecks.push_back(2013); aChecks.push_back(ScDPItemData::DateLast); - CPPUNIT_ASSERT_MESSAGE("Unexpected group values for the year group.", aGrpValues == aChecks); + CPPUNIT_ASSERT_MESSAGE("Unexpected group values for the year group.", bool(aGrpValues == aChecks)); } break; default: @@ -2950,7 +2950,7 @@ void ScFiltersTest::testOrcusODSStyleInterface() CPPUNIT_ASSERT_MESSAGE("Style Name3 : Doesn't have Attribute Protection, but it should have.", pStyleSheet->GetItemSet().HasItem(ATTR_PROTECTION, &pItem)); - CPPUNIT_ASSERT_MESSAGE("Style Name 3 : Error with Protection attribute." ,ScProtectionAttr(true, false, true, true) == *pItem); + CPPUNIT_ASSERT_MESSAGE("Style Name 3 : Error with Protection attribute." ,bool(ScProtectionAttr(true, false, true, true) == *pItem)); /* Test for Style "Name4" * Hidden, protected and content is printed. @@ -2959,7 +2959,7 @@ void ScFiltersTest::testOrcusODSStyleInterface() CPPUNIT_ASSERT_MESSAGE("Style Name4 : Doesn't have Attribute Protection, but it should have.", pStyleSheet->GetItemSet().HasItem(ATTR_PROTECTION, &pItem)); - CPPUNIT_ASSERT_MESSAGE("Style Name 4 : Error with Protection attribute." ,ScProtectionAttr(true, true, false, false) == *pItem); + CPPUNIT_ASSERT_MESSAGE("Style Name 4 : Error with Protection attribute." ,bool(ScProtectionAttr(true, true, false, false) == *pItem)); /* Test for Style "Name3" * Hidden, protected and content is printed. @@ -2968,7 +2968,7 @@ void ScFiltersTest::testOrcusODSStyleInterface() CPPUNIT_ASSERT_MESSAGE("Style Name5 : Doesn't have Attribute Protection, but it should have.", pStyleSheet->GetItemSet().HasItem(ATTR_PROTECTION, &pItem)); - CPPUNIT_ASSERT_MESSAGE("Style Name 5 : Error with Protection attribute." ,ScProtectionAttr(false, false, false, true) == *pItem); + CPPUNIT_ASSERT_MESSAGE("Style Name 5 : Error with Protection attribute." ,bool(ScProtectionAttr(false, false, false, true) == *pItem)); CPPUNIT_ASSERT_MESSAGE("Style Name5 : Has Attribute Border, but it shouldn't.", !pStyleSheet->GetItemSet().HasItem(ATTR_BORDER, &pItem)); @@ -2987,38 +2987,38 @@ void ScFiltersTest::testOrcusODSStyleInterface() pStyleSheet->GetItemSet().HasItem(ATTR_FONT, &pItem)); const SvxFontItem* pFontItem= static_cast<const SvxFontItem*>(pItem); - CPPUNIT_ASSERT_MESSAGE("Style Name6 :Error with Font name", pFontItem->GetStyleName() == "Liberation Sans"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Style Name6 :Error with Font name", OUString("Liberation Sans"), pFontItem->GetStyleName()); CPPUNIT_ASSERT_MESSAGE("Style Name6 : Doesn't have Attribute Font Height, but it should have.", pStyleSheet->GetItemSet().HasItem(ATTR_FONT_HEIGHT, &pItem)); const SvxFontHeightItem* pFontHeightItem= static_cast<const SvxFontHeightItem*>(pItem); - CPPUNIT_ASSERT_MESSAGE("Style Name6 :Error with Font Height", pFontHeightItem->GetHeight() == 480); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Style Name6 :Error with Font Height", static_cast<sal_uInt32>(480), pFontHeightItem->GetHeight()); CPPUNIT_ASSERT_MESSAGE("Style Name6 : Doesn't have Attribute Font Posture, but it should have.", pStyleSheet->GetItemSet().HasItem(ATTR_FONT_POSTURE, &pItem)); const SvxPostureItem* pFontPostureItem= static_cast<const SvxPostureItem*>(pItem); - CPPUNIT_ASSERT_MESSAGE("Style Name6 :Error with Font Posture", pFontPostureItem->GetPosture() == ITALIC_NORMAL); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Style Name6 :Error with Font Posture", ITALIC_NORMAL, pFontPostureItem->GetPosture()); CPPUNIT_ASSERT_MESSAGE("Style Name6 : Doesn't have Attribute Font Weight, but it should have.", pStyleSheet->GetItemSet().HasItem(ATTR_FONT_WEIGHT, &pItem)); const SvxWeightItem* pFontWeightItem= static_cast<const SvxWeightItem*>(pItem); - CPPUNIT_ASSERT_MESSAGE("Style Name6 :Error with Font Weight", pFontWeightItem->GetWeight() == WEIGHT_BOLD); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Style Name6 :Error with Font Weight", WEIGHT_BOLD, pFontWeightItem->GetWeight()); CPPUNIT_ASSERT_MESSAGE("Style Name6 : Doesn't have Attribute Font Color, but it should have.", pStyleSheet->GetItemSet().HasItem(ATTR_FONT_COLOR, &pItem)); const SvxColorItem* pFontColorItem= static_cast<const SvxColorItem*>(pItem); - CPPUNIT_ASSERT_MESSAGE("Style Name6 :Error with Font Color", pFontColorItem->GetValue() == Color(128, 128, 128)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Style Name6 :Error with Font Color", Color(128, 128, 128), pFontColorItem->GetValue()); CPPUNIT_ASSERT_MESSAGE("Style Name6 : Doesn't have Attribute Underline, but it should have.", pStyleSheet->GetItemSet().HasItem(ATTR_FONT_UNDERLINE, &pItem)); const SvxUnderlineItem* pUnderlineItem= static_cast<const SvxUnderlineItem*>(pItem); - CPPUNIT_ASSERT_MESSAGE("Style Name6 :Error with Font Underline Style", pUnderlineItem->GetLineStyle() == LINESTYLE_SINGLE); - CPPUNIT_ASSERT_MESSAGE("Style Name6 :Error with Font Underline Color", pUnderlineItem->GetColor() == Color(128, 128, 128)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Style Name6 :Error with Font Underline Style", LINESTYLE_SINGLE, pUnderlineItem->GetLineStyle()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Style Name6 :Error with Font Underline Color", Color(128, 128, 128), pUnderlineItem->GetColor()); /* Test for Style Name "7" * Has strikethrough single @@ -3028,7 +3028,7 @@ void ScFiltersTest::testOrcusODSStyleInterface() pStyleSheet->GetItemSet().HasItem(ATTR_FONT_CROSSEDOUT, &pItem)); const SvxCrossedOutItem* pCrossedOutItem = static_cast<const SvxCrossedOutItem*>(pItem); - CPPUNIT_ASSERT_MESSAGE("Style Name7 :Error with Strikeout", pCrossedOutItem->GetStrikeout() == STRIKEOUT_SINGLE); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Style Name7 :Error with Strikeout", STRIKEOUT_SINGLE, pCrossedOutItem->GetStrikeout()); /* Test for Style Name "8" * Has strikethrough bold @@ -3038,7 +3038,7 @@ void ScFiltersTest::testOrcusODSStyleInterface() pStyleSheet->GetItemSet().HasItem(ATTR_FONT_CROSSEDOUT, &pItem)); pCrossedOutItem = static_cast<const SvxCrossedOutItem*>(pItem); - CPPUNIT_ASSERT_MESSAGE("Style Name7 :Error with Strikeout", pCrossedOutItem->GetStrikeout() == STRIKEOUT_BOLD); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Style Name7 :Error with Strikeout", STRIKEOUT_BOLD, pCrossedOutItem->GetStrikeout()); /* Test for Style Name "9" * Has strikethrough slash @@ -3048,7 +3048,7 @@ void ScFiltersTest::testOrcusODSStyleInterface() pStyleSheet->GetItemSet().HasItem(ATTR_FONT_CROSSEDOUT, &pItem)); pCrossedOutItem = static_cast<const SvxCrossedOutItem*>(pItem); - CPPUNIT_ASSERT_MESSAGE("Style Name9 :Error with Strikeout", pCrossedOutItem->GetStrikeout() == STRIKEOUT_SLASH); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Style Name9 :Error with Strikeout", STRIKEOUT_SLASH, pCrossedOutItem->GetStrikeout()); /* Test for Style Name "10" * Has ver align, and hor align @@ -3059,14 +3059,14 @@ void ScFiltersTest::testOrcusODSStyleInterface() pStyleSheet->GetItemSet().HasItem(ATTR_HOR_JUSTIFY, &pItem)); const SvxHorJustifyItem* pHorJustify = static_cast<const SvxHorJustifyItem*>(pItem); - CPPUNIT_ASSERT_MESSAGE("Style Name10 :Error with hor justify", pHorJustify->GetValue() == SVX_HOR_JUSTIFY_RIGHT); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Style Name10 :Error with hor justify", static_cast<sal_uInt16>(SVX_HOR_JUSTIFY_RIGHT), pHorJustify->GetValue()); pStyleSheet = pStyleSheetPool->FindCaseIns("Name10", SfxStyleFamily::Para); CPPUNIT_ASSERT_MESSAGE("Style Name10 : Doesn't have Attribute ver justify, but it should have.", pStyleSheet->GetItemSet().HasItem(ATTR_VER_JUSTIFY, &pItem)); const SvxVerJustifyItem* pVerJustify = static_cast<const SvxVerJustifyItem*>(pItem); - CPPUNIT_ASSERT_MESSAGE("Style Name10 :Error with ver justify", pVerJustify->GetValue() == SVX_VER_JUSTIFY_CENTER); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Style Name10 :Error with ver justify", static_cast<sal_uInt16>(SVX_VER_JUSTIFY_CENTER), pVerJustify->GetValue()); } #endif @@ -3279,7 +3279,7 @@ void ScFiltersTest::testSharedFormulaHorizontalXLS() for (SCCOL nCol = 10; nCol <= 18; ++nCol) { aPos.SetCol(nCol); - CPPUNIT_ASSERT_MESSAGE("Formula cell is expected here.", rDoc.GetCellType(aPos) == CELLTYPE_FORMULA); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Formula cell is expected here.", CELLTYPE_FORMULA, rDoc.GetCellType(aPos)); } // Likewise, B3:J9 all should be formula cells. @@ -3289,7 +3289,7 @@ void ScFiltersTest::testSharedFormulaHorizontalXLS() for (SCROW nRow = 2; nRow <= 8; ++nRow) { aPos.SetRow(nRow); - CPPUNIT_ASSERT_MESSAGE("Formula cell is expected here.", rDoc.GetCellType(aPos) == CELLTYPE_FORMULA); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Formula cell is expected here.", CELLTYPE_FORMULA, rDoc.GetCellType(aPos)); } } @@ -3298,7 +3298,7 @@ void ScFiltersTest::testSharedFormulaHorizontalXLS() for (SCCOL nCol = 1; nCol <= 8; ++nCol) { aPos.SetCol(nCol); - CPPUNIT_ASSERT_MESSAGE("Formula cell is expected here.", rDoc.GetCellType(aPos) == CELLTYPE_FORMULA); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Formula cell is expected here.", CELLTYPE_FORMULA, rDoc.GetCellType(aPos)); } // J2 has a string of "MW". @@ -3770,7 +3770,7 @@ void ScFiltersTest::testBnc762542() CPPUNIT_ASSERT_MESSAGE("draw page for sheet 1 should exist.", pPage); const size_t nCount = pPage->GetObjCount(); - CPPUNIT_ASSERT_MESSAGE("There should be 10 shapes.", nCount == 10); + CPPUNIT_ASSERT_EQUAL_MESSAGE("There should be 10 shapes.", static_cast<size_t>(10), nCount); // previously, some of the shapes were (incorrectly) rotated by 90 degrees for (size_t i : { 1, 2, 4, 5, 7, 9 }) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits