Kaydet (Commit) ff1b46c6 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

loplugin:cppunitassertequals: test

Change-Id: I3357b7502fcf9a45095919157ca1530e10c14dd0
üst 73463243
......@@ -19,7 +19,7 @@ namespace apitest {
void XElementAccess::testGetElementType()
{
uno::Reference< container::XElementAccess > xElementAccess(init(), UNO_QUERY_THROW);
CPPUNIT_ASSERT(xElementAccess->getElementType()==maType);
CPPUNIT_ASSERT_EQUAL(maType, xElementAccess->getElementType());
}
void XElementAccess::testHasElements()
......
......@@ -24,13 +24,13 @@ XIndexAccess::XIndexAccess(sal_Int32 nItems):
void XIndexAccess::testGetCount()
{
uno::Reference< container::XIndexAccess > xIndexAccess(init(), UNO_QUERY_THROW);
CPPUNIT_ASSERT(mnItems == xIndexAccess->getCount());
CPPUNIT_ASSERT_EQUAL(mnItems, xIndexAccess->getCount());
}
void XIndexAccess::testGetByIndex()
{
uno::Reference< container::XIndexAccess > xIndexAccess(init(), UNO_QUERY_THROW);
CPPUNIT_ASSERT(mnItems == xIndexAccess->getCount());
CPPUNIT_ASSERT_EQUAL(mnItems, xIndexAccess->getCount());
if (mnItems > 0)
{
......
......@@ -35,7 +35,7 @@ void CellProperties::testVertJustify()
uno::Any aVertJustifyControllValue = xCellRangeBase->getPropertyValue(aVertJustify);
CPPUNIT_ASSERT(aVertJustifyControllValue >>= aValue);
std::cout << "New VertJustify value: " << aValue << std::endl;
CPPUNIT_ASSERT_MESSAGE("value has not been changed", aValue == 3);
CPPUNIT_ASSERT_EQUAL_MESSAGE("value has not been changed", sal_Int32(3), aValue);
}
void CellProperties::testRotateReference()
......@@ -53,7 +53,7 @@ void CellProperties::testRotateReference()
uno::Any aRotateReferenceControllValue = xCellRangeBase->getPropertyValue(aRotateReference);
CPPUNIT_ASSERT(aRotateReferenceControllValue >>= aValue);
std::cout << "New RotateReference value: " << aValue << std::endl;
CPPUNIT_ASSERT_MESSAGE("value has not been changed", aValue == 3);
CPPUNIT_ASSERT_EQUAL_MESSAGE("value has not been changed", sal_Int32(3), aValue);
}
}
......
......@@ -46,8 +46,9 @@ void DataPilotField::testSortInfo()
sheet::DataPilotFieldSortInfo aNewSortInfoValue;
aValue = xPropSet->getPropertyValue(aSortInfo);
CPPUNIT_ASSERT( aValue >>= aNewSortInfoValue );
CPPUNIT_ASSERT_MESSAGE("set value should be the same as got value", aNewSortInfoValue.Field == aSortInfoValue.Field
&& aNewSortInfoValue.Mode == aSortInfoValue.Mode && aNewSortInfoValue.IsAscending == aSortInfoValue.IsAscending);
CPPUNIT_ASSERT_EQUAL_MESSAGE("set value should be the same as got value", aSortInfoValue.Field, aNewSortInfoValue.Field);
CPPUNIT_ASSERT_EQUAL_MESSAGE("set value should be the same as got value", aSortInfoValue.Mode, aNewSortInfoValue.Mode);
CPPUNIT_ASSERT_EQUAL_MESSAGE("set value should be the same as got value", aSortInfoValue.IsAscending, aNewSortInfoValue.IsAscending);
//setting HasSortInfo only makes sense for false, for true the uno implementation does nothing
bool bHasSortInfo(false);
......@@ -79,8 +80,8 @@ void DataPilotField::testLayoutInfo()
sheet::DataPilotFieldLayoutInfo aNewLayoutInfoValue;
aValue = xPropSet->getPropertyValue(aLayoutInfo);
CPPUNIT_ASSERT( aValue >>= aNewLayoutInfoValue );
CPPUNIT_ASSERT_MESSAGE("set value should be the same as the got value", aNewLayoutInfoValue.LayoutMode == aLayoutInfoValue.LayoutMode &&
aNewLayoutInfoValue.AddEmptyLines == aLayoutInfoValue.AddEmptyLines);
CPPUNIT_ASSERT_EQUAL_MESSAGE("set value should be the same as the got value", aLayoutInfoValue.LayoutMode, aNewLayoutInfoValue.LayoutMode);
CPPUNIT_ASSERT_EQUAL_MESSAGE("set value should be the same as the got value", aLayoutInfoValue.AddEmptyLines, aNewLayoutInfoValue.AddEmptyLines);
//setting HasLayoutInfo only makes sense for false, tor true the uno implementation does nothing
bool bHasLayoutInfo(false);
......@@ -112,8 +113,8 @@ void DataPilotField::testAutoShowInfo()
sheet::DataPilotFieldAutoShowInfo aNewAutoShowInfoValue;
aValue = xPropSet->getPropertyValue(aAutoShowInfo);
CPPUNIT_ASSERT( aValue >>= aNewAutoShowInfoValue );
CPPUNIT_ASSERT_MESSAGE("set value should be the same as the got value", aNewAutoShowInfoValue.DataField == aAutoShowInfoValue.DataField &&
aNewAutoShowInfoValue.IsEnabled == aAutoShowInfoValue.IsEnabled);
CPPUNIT_ASSERT_EQUAL_MESSAGE("set value should be the same as the got value", aAutoShowInfoValue.DataField, aNewAutoShowInfoValue.DataField);
CPPUNIT_ASSERT_EQUAL_MESSAGE("set value should be the same as the got value", aAutoShowInfoValue.IsEnabled, aNewAutoShowInfoValue.IsEnabled);
//setting HasLayoutInfo only makes sense for false, tor true the uno implementation does nothing
bool bHasAutoShowInfo(false);
......@@ -145,8 +146,8 @@ void DataPilotField::testReference()
sheet::DataPilotFieldReference aNewReferenceValue;
aValue = xPropSet->getPropertyValue(aReference);
CPPUNIT_ASSERT( aValue >>= aNewReferenceValue );
CPPUNIT_ASSERT_MESSAGE("set value should be the same as the got value", aReferenceValue.ReferenceField == aNewReferenceValue.ReferenceField
&& aReferenceValue.ReferenceItemType == aNewReferenceValue.ReferenceItemType);
CPPUNIT_ASSERT_EQUAL_MESSAGE("set value should be the same as the got value", aReferenceValue.ReferenceField, aNewReferenceValue.ReferenceField);
CPPUNIT_ASSERT_EQUAL_MESSAGE("set value should be the same as the got value", aReferenceValue.ReferenceItemType, aNewReferenceValue.ReferenceItemType);
//setting HasReference only makes sense for false, tor true the uno implementation does nothing
bool bHasReference(false);
......
......@@ -48,11 +48,11 @@ void XDatabaseRange::testDataArea()
xDBRange->setDataArea(aCellAddress);
table::CellRangeAddress aValue;
aValue = xDBRange->getDataArea();
CPPUNIT_ASSERT( aCellAddress.Sheet == aValue.Sheet );
CPPUNIT_ASSERT( aCellAddress.StartRow == aValue.StartRow );
CPPUNIT_ASSERT( aCellAddress.EndRow == aValue.EndRow );
CPPUNIT_ASSERT( aCellAddress.StartColumn == aValue.StartColumn );
CPPUNIT_ASSERT( aCellAddress.EndColumn == aValue.EndColumn );
CPPUNIT_ASSERT_EQUAL( aCellAddress.Sheet, aValue.Sheet );
CPPUNIT_ASSERT_EQUAL( aCellAddress.StartRow, aValue.StartRow );
CPPUNIT_ASSERT_EQUAL( aCellAddress.EndRow, aValue.EndRow );
CPPUNIT_ASSERT_EQUAL( aCellAddress.StartColumn, aValue.StartColumn );
CPPUNIT_ASSERT_EQUAL( aCellAddress.EndColumn, aValue.EndColumn );
}
void XDatabaseRange::testGetSubtotalDescriptor()
......@@ -121,7 +121,7 @@ void XDatabaseRange::testGetSortDescriptor()
{
sal_Int32 nUserListIndex = 1;
aProp.Value >>= nUserListIndex;
CPPUNIT_ASSERT(nUserListIndex == 0);
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nUserListIndex);
}
}
}
......
......@@ -31,7 +31,7 @@ void XDataPilotDescriptor::testTag()
uno::Reference< sheet::XDataPilotDescriptor > xDescr(init(), UNO_QUERY_THROW);
xDescr->setTag(aTag);
OUString aNewTag = xDescr->getTag();
CPPUNIT_ASSERT( aTag == aNewTag );
CPPUNIT_ASSERT_EQUAL( aTag, aNewTag );
}
void XDataPilotDescriptor::testSourceRange()
......@@ -50,11 +50,11 @@ void XDataPilotDescriptor::testSourceRange()
table::CellRangeAddress aReturn;
aReturn = xDescr->getSourceRange();
CPPUNIT_ASSERT(aAddress.Sheet == aReturn.Sheet);
CPPUNIT_ASSERT(aAddress.StartColumn == aReturn.StartColumn);
CPPUNIT_ASSERT(aAddress.StartRow == aReturn.StartRow);
CPPUNIT_ASSERT(aAddress.EndColumn == aReturn.EndColumn);
CPPUNIT_ASSERT(aAddress.EndRow == aReturn.EndRow);
CPPUNIT_ASSERT_EQUAL(aAddress.Sheet, aReturn.Sheet);
CPPUNIT_ASSERT_EQUAL(aAddress.StartColumn, aReturn.StartColumn);
CPPUNIT_ASSERT_EQUAL(aAddress.StartRow, aReturn.StartRow);
CPPUNIT_ASSERT_EQUAL(aAddress.EndColumn, aReturn.EndColumn);
CPPUNIT_ASSERT_EQUAL(aAddress.EndRow, aReturn.EndRow);
//restore old settings
xDescr->setSourceRange(aOldAddress);
......
......@@ -31,9 +31,9 @@ void XDataPilotTable::testGetOutputRange()
uno::Reference< sheet::XDataPilotTable > xDPTable(init(),UNO_QUERY_THROW);
table::CellRangeAddress aRange = xDPTable->getOutputRange();
CPPUNIT_ASSERT( aRange.Sheet == 0 );
CPPUNIT_ASSERT( aRange.StartColumn == 7 );
CPPUNIT_ASSERT( aRange.StartRow == 8 );
CPPUNIT_ASSERT_EQUAL( sal_Int16(0), aRange.Sheet );
CPPUNIT_ASSERT_EQUAL( sal_Int32(7), aRange.StartColumn );
CPPUNIT_ASSERT_EQUAL( sal_Int32(8), aRange.StartRow );
}
void XDataPilotTable::testRefresh()
......
......@@ -127,17 +127,17 @@ void XDataPilotTable2::testGetOutputRangeByType()
CPPUNIT_ASSERT( maRangeWhole.EndRow - maRangeWhole.StartRow > 0);
//table range must be of equal width with the whole range, and the same bottom
CPPUNIT_ASSERT( maRangeTable.Sheet == maRangeWhole.Sheet );
CPPUNIT_ASSERT( maRangeTable.EndRow == maRangeWhole.EndRow );
CPPUNIT_ASSERT( maRangeTable.StartColumn == maRangeWhole.StartColumn );
CPPUNIT_ASSERT( maRangeTable.EndColumn == maRangeWhole.EndColumn );
CPPUNIT_ASSERT_EQUAL( maRangeWhole.Sheet, maRangeTable.Sheet );
CPPUNIT_ASSERT_EQUAL( maRangeWhole.EndRow, maRangeTable.EndRow );
CPPUNIT_ASSERT_EQUAL( maRangeWhole.StartColumn, maRangeTable.StartColumn );
CPPUNIT_ASSERT_EQUAL( maRangeWhole.EndColumn, maRangeTable.EndColumn );
//result range must be smaller than the table range, and must share the same lower-right corner
CPPUNIT_ASSERT( maRangeResult.Sheet == maRangeTable.Sheet );
CPPUNIT_ASSERT_EQUAL( maRangeTable.Sheet, maRangeResult.Sheet );
CPPUNIT_ASSERT( maRangeResult.StartColumn >= maRangeTable.StartColumn );
CPPUNIT_ASSERT( maRangeResult.StartRow >= maRangeTable.StartRow );
CPPUNIT_ASSERT( maRangeResult.EndRow == maRangeTable.EndRow );
CPPUNIT_ASSERT( maRangeResult.EndColumn == maRangeTable.EndColumn );
CPPUNIT_ASSERT_EQUAL( maRangeTable.EndRow, maRangeResult.EndRow );
CPPUNIT_ASSERT_EQUAL( maRangeTable.EndColumn, maRangeResult.EndColumn );
}
......@@ -269,7 +269,7 @@ bool XDataPilotTable2::checkDrillDownSheetContent(uno::Reference< sheet::XSpread
{
Any& aCell1 = aSheetData[x][y];
const Any& aCell2 = aData[x][y];
CPPUNIT_ASSERT(aCell1 == aCell2);
CPPUNIT_ASSERT_EQUAL(aCell2, aCell1);
}
}
return true;
......
......@@ -71,7 +71,7 @@ void XNamedRange::testGetType()
{
OUString aTestedNamedRangeString("initial1");
uno::Reference< sheet::XNamedRange > xNamedRange = getNamedRange(aTestedNamedRangeString);
CPPUNIT_ASSERT_MESSAGE("Wrong expected Type", xNamedRange->getType() == 0);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong expected Type", sal_Int32(0), xNamedRange->getType());
}
void XNamedRange::testSetType()
......@@ -81,23 +81,23 @@ void XNamedRange::testSetType()
sal_Int32 nType = ::sheet::NamedRangeFlag::ROW_HEADER;
xNamedRange->setType(nType);
CPPUNIT_ASSERT_MESSAGE("Wrong expected Type ROW_HEADER after setting it", xNamedRange->getType() == nType);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong expected Type ROW_HEADER after setting it", nType, xNamedRange->getType());
nType = ::sheet::NamedRangeFlag::COLUMN_HEADER;
xNamedRange->setType(nType);
CPPUNIT_ASSERT_MESSAGE("Wrong expected Type COLUMN_HEADER after setting it", xNamedRange->getType() == nType);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong expected Type COLUMN_HEADER after setting it", nType, xNamedRange->getType());
nType = ::sheet::NamedRangeFlag::FILTER_CRITERIA;
xNamedRange->setType(nType);
CPPUNIT_ASSERT_MESSAGE("Wrong expected Type FILTER_CRITERIA after setting it", xNamedRange->getType() == nType);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong expected Type FILTER_CRITERIA after setting it", nType, xNamedRange->getType());
nType = ::sheet::NamedRangeFlag::PRINT_AREA;
xNamedRange->setType(nType);
CPPUNIT_ASSERT_MESSAGE("Wrong expected Type PRINT_AREA after setting it", xNamedRange->getType() == nType);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong expected Type PRINT_AREA after setting it", nType, xNamedRange->getType());
nType = 0;
xNamedRange->setType(nType);
CPPUNIT_ASSERT_MESSAGE("Wrong expected Type 0 after setting it", xNamedRange->getType() == nType);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong expected Type 0 after setting it", nType, xNamedRange->getType());
}
void XNamedRange::testGetReferencePosition()
......@@ -107,9 +107,9 @@ void XNamedRange::testGetReferencePosition()
table::CellAddress aCellAddress = xNamedRange->getReferencePosition();
// the expected address is on B1, as it was the active cell when initial2 was created
CPPUNIT_ASSERT_MESSAGE("Wrong SHEET reference position", aCellAddress.Sheet == 0);
CPPUNIT_ASSERT_MESSAGE("Wrong COLUMN reference position", aCellAddress.Column == 1);
CPPUNIT_ASSERT_MESSAGE("Wrong ROW reference position", aCellAddress.Row == 0);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong SHEET reference position", sal_Int16(0), aCellAddress.Sheet);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong COLUMN reference position", sal_Int32(1), aCellAddress.Column);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong ROW reference position", sal_Int32(0), aCellAddress.Row);
}
void XNamedRange::testSetReferencePosition()
......@@ -122,9 +122,9 @@ void XNamedRange::testSetReferencePosition()
xNamedRange->setReferencePosition(aBaseAddress);
table::CellAddress aCellAddress = xNamedRange->getReferencePosition();
CPPUNIT_ASSERT_MESSAGE("Wrong SHEET reference position after setting it", aCellAddress.Sheet == 1);
CPPUNIT_ASSERT_MESSAGE("Wrong COLUMN reference position after setting it", aCellAddress.Column == 2);
CPPUNIT_ASSERT_MESSAGE("Wrong ROW reference position after setting it", aCellAddress.Row == 3);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong SHEET reference position after setting it", sal_Int16(1), aCellAddress.Sheet);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong COLUMN reference position after setting it", sal_Int32(2), aCellAddress.Column);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong ROW reference position after setting it", sal_Int32(3), aCellAddress.Row);
}
}
......
......@@ -120,10 +120,11 @@ void XNamedRanges::testAddNewFromTitles()
uno::Reference< sheet::XCellRangeAddressable > xCellRangeAdr(xCellRangeRef->getReferredCells(), UNO_QUERY_THROW);
table::CellRangeAddress cellRangeAddress = xCellRangeAdr->getRangeAddress();
CPPUNIT_ASSERT(cellRangeAddress.EndColumn == i && cellRangeAddress.StartColumn == i);
CPPUNIT_ASSERT(cellRangeAddress.StartRow == 1);
CPPUNIT_ASSERT(cellRangeAddress.EndRow == 3);
CPPUNIT_ASSERT(cellRangeAddress.Sheet == 1);
CPPUNIT_ASSERT_EQUAL(i, cellRangeAddress.EndColumn);
CPPUNIT_ASSERT_EQUAL(i, cellRangeAddress.StartColumn);
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), cellRangeAddress.StartRow);
CPPUNIT_ASSERT_EQUAL(sal_Int32(3), cellRangeAddress.EndRow);
CPPUNIT_ASSERT_EQUAL(sal_Int16(1), cellRangeAddress.Sheet);
}
xNamedRanges->addNewFromTitles(aCellRangeAddress, sheet::Border_LEFT);
......@@ -145,10 +146,11 @@ void XNamedRanges::testAddNewFromTitles()
uno::Reference< sheet::XCellRangeAddressable > xCellRangeAdr(xCellRangeRef->getReferredCells(), UNO_QUERY_THROW);
table::CellRangeAddress cellRangeAddress = xCellRangeAdr->getRangeAddress();
CPPUNIT_ASSERT(cellRangeAddress.EndRow == i && cellRangeAddress.StartRow == i);
CPPUNIT_ASSERT(cellRangeAddress.StartColumn == 1);
CPPUNIT_ASSERT(cellRangeAddress.EndColumn == 3);
CPPUNIT_ASSERT(cellRangeAddress.Sheet == 1);
CPPUNIT_ASSERT_EQUAL(i, cellRangeAddress.EndRow);
CPPUNIT_ASSERT_EQUAL(i, cellRangeAddress.StartRow);
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), cellRangeAddress.StartColumn);
CPPUNIT_ASSERT_EQUAL(sal_Int32(3), cellRangeAddress.EndColumn);
CPPUNIT_ASSERT_EQUAL(sal_Int16(1), cellRangeAddress.Sheet);
}
}
......
......@@ -30,9 +30,9 @@ void XSheetAnnotation::testGetPosition()
aExpectedCellAddress.Row = 1;
aExpectedCellAddress.Column = 2;
CPPUNIT_ASSERT_MESSAGE("Wrong SHEET reference position", aResultCellAddress.Sheet == aExpectedCellAddress.Sheet);
CPPUNIT_ASSERT_MESSAGE("Wrong COLUMN reference position", aResultCellAddress.Column == aExpectedCellAddress.Column);
CPPUNIT_ASSERT_MESSAGE("Wrong ROW reference position", aResultCellAddress.Row == aExpectedCellAddress.Row);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong SHEET reference position", aExpectedCellAddress.Sheet, aResultCellAddress.Sheet);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong COLUMN reference position", aExpectedCellAddress.Column, aResultCellAddress.Column);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong ROW reference position", aExpectedCellAddress.Row, aResultCellAddress.Row);
}
void XSheetAnnotation::testGetAuthor()
......@@ -40,14 +40,14 @@ void XSheetAnnotation::testGetAuthor()
uno::Reference< sheet::XSheetAnnotation > aSheetAnnotation (init(), UNO_QUERY_THROW);
OUString aAuthor = aSheetAnnotation->getAuthor();
CPPUNIT_ASSERT_MESSAGE("Wrong author", aAuthor == "LG");
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong author", OUString("LG"), aAuthor);
}
void XSheetAnnotation::testGetDate()
{
uno::Reference< sheet::XSheetAnnotation > aSheetAnnotation (init(), UNO_QUERY_THROW);
OUString aDate = aSheetAnnotation->getDate();
CPPUNIT_ASSERT_MESSAGE("Wrong date", aDate == "01/17/2013");
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong date", OUString("01/17/2013"), aDate);
}
void XSheetAnnotation::testGetIsVisible()
{
......
......@@ -25,7 +25,7 @@ void XSpreadsheetDocument::testGetSheets()
CPPUNIT_ASSERT(xSheets.is());
uno::Reference< container::XIndexAccess > xIA(xSheets, UNO_QUERY_THROW);
CPPUNIT_ASSERT( xIA->getCount() == mnSheets );
CPPUNIT_ASSERT_EQUAL( mnSheets, xIA->getCount() );
}
}
......
......@@ -275,7 +275,7 @@ void XSpreadsheets2::testImportCellStyle()
sal_Int32 aVertJustify = 0;
CPPUNIT_ASSERT(xCellStyleProp->getPropertyValue(aProperty) >>= aVertJustify);
CPPUNIT_ASSERT_MESSAGE("New style: VertJustify not set", (table::CellVertJustify)aVertJustify == table::CellVertJustify_CENTER);
CPPUNIT_ASSERT_EQUAL_MESSAGE("New style: VertJustify not set", table::CellVertJustify_CENTER, (table::CellVertJustify)aVertJustify);
}
uno::Reference< sheet::XSpreadsheetDocument> XSpreadsheets2::getDoc(const OUString& aFileBase, uno::Reference< lang::XComponent >& xComp)
......
......@@ -27,7 +27,7 @@ void XSearchable::testFindAll()
uno::Reference< container::XIndexAccess > xIndex = xSearchable->findAll(xSearchDescr);
CPPUNIT_ASSERT(xIndex.is());
CPPUNIT_ASSERT(xIndex->getCount() == mnCount);
CPPUNIT_ASSERT_EQUAL(mnCount, xIndex->getCount());
}
void XSearchable::testFindFirst()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment