[Libreoffice-commits] core.git: 15 commits - basegfx/test basic/qa comphelper/qa configmgr/qa cppu/qa extensions/qa sal/qa sc/qa sdext/source starmath/qa sw/qa test/source tools/qa unotest/source vcl/qa
Stephan Bergmann
sbergman at redhat.com
Fri Apr 28 12:23:28 UTC 2017
basegfx/test/basegfx2d.cxx | 373 +++++++++++++--------------
basegfx/test/basegfxtools.cxx | 18 -
basegfx/test/boxclipper.cxx | 8
basegfx/test/clipstate.cxx | 4
basegfx/test/genericclipper.cxx | 9
basic/qa/cppunit/test_vba.cxx | 2
comphelper/qa/container/testifcontainer.cxx | 3
configmgr/qa/unit/test.cxx | 12
cppu/qa/test_any.cxx | 130 ++++++---
extensions/qa/update/test_update.cxx | 12
sal/qa/OStringBuffer/rtl_OStringBuffer.cxx | 110 ++++++-
sal/qa/osl/condition/osl_Condition.cxx | 44 ++-
sal/qa/osl/file/osl_File.cxx | 298 +++++++++++++--------
sal/qa/osl/file/test_cpy_wrt_file.cxx | 4
sal/qa/osl/module/osl_Module.cxx | 22 +
sal/qa/osl/mutex/osl_Mutex.cxx | 42 ++-
sal/qa/osl/pipe/osl_Pipe.cxx | 43 ++-
sal/qa/osl/process/osl_Thread.cxx | 170 +++++++++---
sal/qa/osl/security/osl_Security.cxx | 15 -
sal/qa/rtl/uri/rtl_testuri.cxx | 268 +++++++++----------
sc/qa/unit/subsequent_filters-test.cxx | 2
sc/qa/unit/tiledrendering/tiledrendering.cxx | 20 -
sc/qa/unit/ucalc.cxx | 2
sdext/source/pdfimport/test/tests.cxx | 92 +++---
starmath/qa/cppunit/test_starmath.cxx | 52 +--
sw/qa/core/Test-BigPtrArray.cxx | 20 -
test/source/container/xelementaccess.cxx | 2
test/source/container/xindexaccess.cxx | 4
test/source/sheet/cellproperties.cxx | 4
test/source/sheet/datapilotfield.cxx | 17 -
test/source/sheet/xdatabaserange.cxx | 12
test/source/sheet/xdatapilotdescriptor.cxx | 12
test/source/sheet/xdatapilottable.cxx | 6
test/source/sheet/xdatapilottable2.cxx | 16 -
test/source/sheet/xnamedrange.cxx | 24 -
test/source/sheet/xnamedranges.cxx | 18 -
test/source/sheet/xsheetannotation.cxx | 10
test/source/sheet/xspreadsheetdocument.cxx | 2
test/source/sheet/xspreadsheets2.cxx | 2
test/source/util/xsearchable.cxx | 2
tools/qa/cppunit/test_urlobj.cxx | 36 +-
unotest/source/cpp/directories.cxx | 6
vcl/qa/cppunit/errorhandler.cxx | 4
vcl/qa/cppunit/fontmetric.cxx | 24 -
44 files changed, 1190 insertions(+), 786 deletions(-)
New commits:
commit 29c09916760419ebfb87a954927bcd02b186a46b
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Fri Apr 28 14:22:53 2017 +0200
loplugin:cppunitassertequals: vcl
Change-Id: I0b1b279b9bbb82b5e7aff0b0fb6a5be0ee0b3f62
diff --git a/vcl/qa/cppunit/errorhandler.cxx b/vcl/qa/cppunit/errorhandler.cxx
index e86cc793d2bd..defc218fac5f 100644
--- a/vcl/qa/cppunit/errorhandler.cxx
+++ b/vcl/qa/cppunit/errorhandler.cxx
@@ -51,12 +51,12 @@ void ErrorHandlerTest::testGetErrorString()
!ErrorHandler::GetErrorString(ERRCODE_ABORT, aErrStr));
// normally protected, but MockErrorHandler is a friend of this class
aErrHdlr.CreateString(ErrorInfo::GetErrorInfo(ERRCODE_ABORT), aErrStr);
- CPPUNIT_ASSERT_MESSAGE("error message should be non-dynamic", aErrStr == "Non-dynamic error");
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("error message should be non-dynamic", OUString("Non-dynamic error"), aErrStr);
CPPUNIT_ASSERT_MESSAGE("GetErrorString(ERRCODE_NONE, aErrStr) should return false",
!ErrorHandler::GetErrorString(ERRCODE_NONE, aErrStr));
aErrHdlr.CreateString(ErrorInfo::GetErrorInfo(ERRCODE_NONE), aErrStr);
- CPPUNIT_ASSERT_MESSAGE("error message should be non-dynamic", aErrStr == "Non-dynamic error");
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("error message should be non-dynamic", OUString("Non-dynamic error"), aErrStr);
}
CPPUNIT_TEST_SUITE_REGISTRATION(ErrorHandlerTest);
diff --git a/vcl/qa/cppunit/fontmetric.cxx b/vcl/qa/cppunit/fontmetric.cxx
index 7fdd531c52b3..93378c6e581c 100644
--- a/vcl/qa/cppunit/fontmetric.cxx
+++ b/vcl/qa/cppunit/fontmetric.cxx
@@ -107,33 +107,33 @@ void VclFontMetricTest::testEqualityOperator()
aLhs.SetFullstopCenteredFlag(true);
aRhs.SetFullstopCenteredFlag(true);
- CPPUNIT_ASSERT_EQUAL_MESSAGE( "Fullstop centered flag set same, aLhs == aRhs failed", aRhs, aLhs );
- CPPUNIT_ASSERT_MESSAGE( "Fullstop centered flag set same, aLhs != aRhs succeeded", !(aLhs != aRhs) );
+ CPPUNIT_ASSERT_MESSAGE( "Fullstop centered flag set same, aLhs == aRhs failed", aLhs.operator ==(aRhs) );
+ CPPUNIT_ASSERT_MESSAGE( "Fullstop centered flag set same, aLhs != aRhs succeeded", !aLhs.operator !=(aRhs) );
aLhs.SetExternalLeading(10);
aRhs.SetExternalLeading(10);
- CPPUNIT_ASSERT_EQUAL_MESSAGE( "External leading set same, aLHS == aRhs failed", aRhs, aLhs );
- CPPUNIT_ASSERT_MESSAGE( "External leading set same, aLHS != aRhs succeeded", !(aLhs != aRhs) );
+ CPPUNIT_ASSERT_MESSAGE( "External leading set same, aLHS == aRhs failed", aLhs.operator ==(aRhs) );
+ CPPUNIT_ASSERT_MESSAGE( "External leading set same, aLHS != aRhs succeeded", !aLhs.operator !=(aRhs) );
aLhs.SetInternalLeading(10);
aRhs.SetInternalLeading(10);
- CPPUNIT_ASSERT_EQUAL_MESSAGE( "Internal leading set same, aLHS == aRhs failed", aRhs, aLhs );
- CPPUNIT_ASSERT_MESSAGE( "Internal leading set same, aLHS != aRhs succeeded", !(aLhs != aRhs) );
+ CPPUNIT_ASSERT_MESSAGE( "Internal leading set same, aLHS == aRhs failed", aLhs.operator ==(aRhs) );
+ CPPUNIT_ASSERT_MESSAGE( "Internal leading set same, aLHS != aRhs succeeded", !aLhs.operator !=(aRhs) );
aLhs.SetAscent( 100 );
aRhs.SetAscent( 100 );
- CPPUNIT_ASSERT_EQUAL_MESSAGE( "Ascent set same, aLHS == aRhs failed", aRhs, aLhs );
- CPPUNIT_ASSERT_MESSAGE( "Ascent set same, aLHS != aRhs succeeded", !(aLhs != aRhs) );
+ CPPUNIT_ASSERT_MESSAGE( "Ascent set same, aLHS == aRhs failed", aLhs.operator ==(aRhs) );
+ CPPUNIT_ASSERT_MESSAGE( "Ascent set same, aLHS != aRhs succeeded", !aLhs.operator !=(aRhs) );
aLhs.SetDescent( 100 );
aRhs.SetDescent( 100 );
- CPPUNIT_ASSERT_EQUAL_MESSAGE( "Descent set same, aLHS == aRhs failed", aRhs, aLhs);
- CPPUNIT_ASSERT_MESSAGE( "Descent set same, aLHS != aRhs succeeded", !(aLhs != aRhs) );
+ CPPUNIT_ASSERT_MESSAGE( "Descent set same, aLHS == aRhs failed", aLhs.operator ==(aRhs));
+ CPPUNIT_ASSERT_MESSAGE( "Descent set same, aLHS != aRhs succeeded", !aLhs.operator !=(aRhs) );
aLhs.SetSlant( 100 );
aRhs.SetSlant( 100 );
- CPPUNIT_ASSERT_EQUAL_MESSAGE( "Slant set same, aLHS == aRhs failed", aRhs, aLhs);
- CPPUNIT_ASSERT_MESSAGE( "Slant set same, aLHS != aRhs succeeded", !(aLhs != aRhs) );
+ CPPUNIT_ASSERT_MESSAGE( "Slant set same, aLHS == aRhs failed", aLhs.operator ==(aRhs));
+ CPPUNIT_ASSERT_MESSAGE( "Slant set same, aLHS != aRhs succeeded", !aLhs.operator !=(aRhs) );
}
commit 36638dac7d9a9f14ebaedb6a76371beef9d14bde
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Fri Apr 28 14:22:47 2017 +0200
loplugin:cppunitassertequals: unotest
Change-Id: If2ebd9ffcab036ecb7b07038346c8a8f8e059cbe
diff --git a/unotest/source/cpp/directories.cxx b/unotest/source/cpp/directories.cxx
index 71c1f32fa193..d559dffc2e90 100644
--- a/unotest/source/cpp/directories.cxx
+++ b/unotest/source/cpp/directories.cxx
@@ -29,9 +29,11 @@ OUString getFileURLFromSystemPath(OUString const & path) {
test::Directories::Directories() {
const char* pSrcRoot = getenv( "SRC_ROOT" );
- CPPUNIT_ASSERT_MESSAGE("SRC_ROOT env variable not set", pSrcRoot != nullptr && pSrcRoot[0] != 0);
+ CPPUNIT_ASSERT_MESSAGE("SRC_ROOT env variable not set", pSrcRoot != nullptr);
+ CPPUNIT_ASSERT_MESSAGE("SRC_ROOT env variable not set", pSrcRoot[0] != 0);
const char* pWorkdirRoot = getenv( "WORKDIR_FOR_BUILD" );
- CPPUNIT_ASSERT_MESSAGE("$WORKDIR_FOR_BUILD env variable not set", pWorkdirRoot != nullptr && pWorkdirRoot[0] != 0);
+ CPPUNIT_ASSERT_MESSAGE("$WORKDIR_FOR_BUILD env variable not set", pWorkdirRoot != nullptr);
+ CPPUNIT_ASSERT_MESSAGE("$WORKDIR_FOR_BUILD env variable not set", pWorkdirRoot[0] != 0);
m_aSrcRootPath = OUString::createFromAscii( pSrcRoot );
m_aSrcRootURL = getFileURLFromSystemPath(m_aSrcRootPath);
commit 50413b07d2ab1fb0dd706565bfcac0a5946f6cf2
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Fri Apr 28 14:22:41 2017 +0200
loplugin:cppunitassertequals: tools
Change-Id: I8dc45fbbe3ea8c3fb898250e55cee582d1d8199d
diff --git a/tools/qa/cppunit/test_urlobj.cxx b/tools/qa/cppunit/test_urlobj.cxx
index 2c14f2210dab..68ff8197076f 100644
--- a/tools/qa/cppunit/test_urlobj.cxx
+++ b/tools/qa/cppunit/test_urlobj.cxx
@@ -55,9 +55,9 @@ namespace tools_urlobj
CPPUNIT_ASSERT_EQUAL(INetProtocol::Smb, aUrl.GetProtocol());
#endif
#ifdef _WIN32
- CPPUNIT_ASSERT( aUrl.GetMainURL( INetURLObject::DecodeMechanism::NONE )
- == "file://10.10.1.1/sampledir/sample.file" );
- CPPUNIT_ASSERT( aUrl.GetProtocol( ) == INetProtocol::File );
+ CPPUNIT_ASSERT_EQUAL( OUString("file://10.10.1.1/sampledir/sample.file"),
+ aUrl.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
+ CPPUNIT_ASSERT_EQUAL( INetProtocol::File, aUrl.GetProtocol( ) );
#endif
CPPUNIT_ASSERT_EQUAL(OUString("10.10.1.1"),
aUrl.GetHost(INetURLObject::DecodeMechanism::NONE));
@@ -81,9 +81,9 @@ namespace tools_urlobj
CPPUNIT_ASSERT_EQUAL(INetProtocol::Smb, aUrl.GetProtocol());
#endif
#ifdef _WIN32
- CPPUNIT_ASSERT( aUrl.GetMainURL( INetURLObject::DecodeMechanism::NONE )
- == "file://137.65.170.24/c$/Img0001.jpg" );
- CPPUNIT_ASSERT( aUrl.GetProtocol( ) == INetProtocol::File );
+ CPPUNIT_ASSERT_EQUAL( OUString("file://137.65.170.24/c$/Img0001.jpg"),
+ aUrl.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
+ CPPUNIT_ASSERT_EQUAL( INetProtocol::File, aUrl.GetProtocol( ) );
#endif
CPPUNIT_ASSERT_EQUAL(OUString("137.65.170.24"),
aUrl.GetHost(INetURLObject::DecodeMechanism::NONE));
@@ -107,9 +107,9 @@ namespace tools_urlobj
CPPUNIT_ASSERT_EQUAL(INetProtocol::Smb, aUrl.GetProtocol());
#endif
#ifdef _WIN32
- CPPUNIT_ASSERT( aUrl.GetMainURL( INetURLObject::DecodeMechanism::NONE )
- == "file://hive-winxp-x86/pmladek/test2.odt" );
- CPPUNIT_ASSERT( aUrl.GetProtocol( ) == INetProtocol::File );
+ CPPUNIT_ASSERT_EQUAL( OUString("file://hive-winxp-x86/pmladek/test2.odt"),
+ aUrl.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
+ CPPUNIT_ASSERT_EQUAL( INetProtocol::File, aUrl.GetProtocol( ) );
#endif
CPPUNIT_ASSERT_EQUAL(OUString("hive-winxp-x86"),
aUrl.GetHost(INetURLObject::DecodeMechanism::NONE));
@@ -126,9 +126,9 @@ namespace tools_urlobj
CPPUNIT_ASSERT_EQUAL( INetProtocol::Smb, aUrl.GetProtocol( ) );
#endif
#ifdef _WIN32
- CPPUNIT_ASSERT( aUrl.GetMainURL( INetURLObject::DecodeMechanism::NONE )
- == "file://10.10.1.1/sampledir/sample.file" );
- CPPUNIT_ASSERT( aUrl.GetProtocol( ) == INetProtocol::File );
+ CPPUNIT_ASSERT_EQUAL( OUString("file://10.10.1.1/sampledir/sample.file"),
+ aUrl.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
+ CPPUNIT_ASSERT_EQUAL( INetProtocol::File, aUrl.GetProtocol( ) );
#endif
CPPUNIT_ASSERT_EQUAL(OUString("10.10.1.1"),
aUrl.GetHost(INetURLObject::DecodeMechanism::NONE));
@@ -150,9 +150,9 @@ namespace tools_urlobj
CPPUNIT_ASSERT_EQUAL(INetProtocol::Smb, aUrl.GetProtocol());
#endif
#ifdef _WIN32
- CPPUNIT_ASSERT( aUrl.GetMainURL( INetURLObject::DecodeMechanism::NONE )
- == "file://137.65.170.24/c$/Img0001.jpg" );
- CPPUNIT_ASSERT( aUrl.GetProtocol( ) == INetProtocol::File );
+ CPPUNIT_ASSERT_EQUAL( OUString("file://137.65.170.24/c$/Img0001.jpg"),
+ aUrl.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
+ CPPUNIT_ASSERT_EQUAL( INetProtocol::File, aUrl.GetProtocol( ) );
#endif
CPPUNIT_ASSERT_EQUAL(OUString("137.65.170.24"),
aUrl.GetHost(INetURLObject::DecodeMechanism::NONE));
@@ -175,9 +175,9 @@ namespace tools_urlobj
CPPUNIT_ASSERT_EQUAL(INetProtocol::Smb, aUrl.GetProtocol());
#endif
#ifdef _WIN32
- CPPUNIT_ASSERT( aUrl.GetMainURL( INetURLObject::DecodeMechanism::NONE )
- == "file://hive-winxp-x86/pmladek/test2.odt" );
- CPPUNIT_ASSERT( aUrl.GetProtocol( ) == INetProtocol::File );
+ CPPUNIT_ASSERT_EQUAL( OUString("file://hive-winxp-x86/pmladek/test2.odt"),
+ aUrl.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
+ CPPUNIT_ASSERT_EQUAL( INetProtocol::File, aUrl.GetProtocol( ) );
#endif
CPPUNIT_ASSERT_EQUAL(OUString("hive-winxp-x86"),
aUrl.GetHost(INetURLObject::DecodeMechanism::NONE));
commit ff1b46c6fee5f6d1259eb29254782688b4dccb32
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Fri Apr 28 14:22:36 2017 +0200
loplugin:cppunitassertequals: test
Change-Id: I3357b7502fcf9a45095919157ca1530e10c14dd0
diff --git a/test/source/container/xelementaccess.cxx b/test/source/container/xelementaccess.cxx
index c1281feaa796..16e9c2ff4c3c 100644
--- a/test/source/container/xelementaccess.cxx
+++ b/test/source/container/xelementaccess.cxx
@@ -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()
diff --git a/test/source/container/xindexaccess.cxx b/test/source/container/xindexaccess.cxx
index 773366ab5ee2..e359d88277a4 100644
--- a/test/source/container/xindexaccess.cxx
+++ b/test/source/container/xindexaccess.cxx
@@ -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)
{
diff --git a/test/source/sheet/cellproperties.cxx b/test/source/sheet/cellproperties.cxx
index c5a52367f34b..746ee190e1e4 100644
--- a/test/source/sheet/cellproperties.cxx
+++ b/test/source/sheet/cellproperties.cxx
@@ -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);
}
}
diff --git a/test/source/sheet/datapilotfield.cxx b/test/source/sheet/datapilotfield.cxx
index 2772328eef17..66c3b45ab1d4 100644
--- a/test/source/sheet/datapilotfield.cxx
+++ b/test/source/sheet/datapilotfield.cxx
@@ -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);
diff --git a/test/source/sheet/xdatabaserange.cxx b/test/source/sheet/xdatabaserange.cxx
index 45f59fc9109c..e85d0741a2f5 100644
--- a/test/source/sheet/xdatabaserange.cxx
+++ b/test/source/sheet/xdatabaserange.cxx
@@ -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);
}
}
}
diff --git a/test/source/sheet/xdatapilotdescriptor.cxx b/test/source/sheet/xdatapilotdescriptor.cxx
index 7fd5b4f772ae..58f48a8bbcd5 100644
--- a/test/source/sheet/xdatapilotdescriptor.cxx
+++ b/test/source/sheet/xdatapilotdescriptor.cxx
@@ -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);
diff --git a/test/source/sheet/xdatapilottable.cxx b/test/source/sheet/xdatapilottable.cxx
index cef1550dc9d1..50d6cb80d7fb 100644
--- a/test/source/sheet/xdatapilottable.cxx
+++ b/test/source/sheet/xdatapilottable.cxx
@@ -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()
diff --git a/test/source/sheet/xdatapilottable2.cxx b/test/source/sheet/xdatapilottable2.cxx
index 235fa5090878..a300704d1a2d 100644
--- a/test/source/sheet/xdatapilottable2.cxx
+++ b/test/source/sheet/xdatapilottable2.cxx
@@ -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;
diff --git a/test/source/sheet/xnamedrange.cxx b/test/source/sheet/xnamedrange.cxx
index 5234a9835eb4..5353b5416e82 100644
--- a/test/source/sheet/xnamedrange.cxx
+++ b/test/source/sheet/xnamedrange.cxx
@@ -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);
}
}
diff --git a/test/source/sheet/xnamedranges.cxx b/test/source/sheet/xnamedranges.cxx
index c31f4afe7d82..4fee1da0e23c 100644
--- a/test/source/sheet/xnamedranges.cxx
+++ b/test/source/sheet/xnamedranges.cxx
@@ -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);
}
}
diff --git a/test/source/sheet/xsheetannotation.cxx b/test/source/sheet/xsheetannotation.cxx
index b39552603d13..6643096012f3 100644
--- a/test/source/sheet/xsheetannotation.cxx
+++ b/test/source/sheet/xsheetannotation.cxx
@@ -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()
{
diff --git a/test/source/sheet/xspreadsheetdocument.cxx b/test/source/sheet/xspreadsheetdocument.cxx
index 31477643cf31..cab546accb2f 100644
--- a/test/source/sheet/xspreadsheetdocument.cxx
+++ b/test/source/sheet/xspreadsheetdocument.cxx
@@ -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() );
}
}
diff --git a/test/source/sheet/xspreadsheets2.cxx b/test/source/sheet/xspreadsheets2.cxx
index 76e2a05c6fea..fb32ea3173c2 100644
--- a/test/source/sheet/xspreadsheets2.cxx
+++ b/test/source/sheet/xspreadsheets2.cxx
@@ -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)
diff --git a/test/source/util/xsearchable.cxx b/test/source/util/xsearchable.cxx
index 91006e18118a..c58be12eb971 100644
--- a/test/source/util/xsearchable.cxx
+++ b/test/source/util/xsearchable.cxx
@@ -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()
commit 73463243129243fa71af7b1685ce9df838cfe9e7
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Fri Apr 28 14:22:31 2017 +0200
loplugin:cppunitassertequals: sw
Change-Id: I9e2dcf0e2f5ed9c542b9807683878c654edc21fb
diff --git a/sw/qa/core/Test-BigPtrArray.cxx b/sw/qa/core/Test-BigPtrArray.cxx
index 89fe504da89a..b4be867771fd 100644
--- a/sw/qa/core/Test-BigPtrArray.cxx
+++ b/sw/qa/core/Test-BigPtrArray.cxx
@@ -128,10 +128,10 @@ public:
{
sal_uLong oldCount = bparr.Count();
bparr.Insert(new BigPtrEntryMock(i), 0);
- CPPUNIT_ASSERT_MESSAGE
+ CPPUNIT_ASSERT_EQUAL_MESSAGE
(
"test_insert_entries_at_front failed",
- (bparr.Count() == oldCount + 1)
+ oldCount + 1, bparr.Count()
);
}
@@ -198,10 +198,10 @@ public:
for (sal_uLong i = 0, j = 30; i < 5; i++, j++)
bparr.Insert(new BigPtrEntryMock(j), i);
- CPPUNIT_ASSERT_MESSAGE
+ CPPUNIT_ASSERT_EQUAL_MESSAGE
(
"test_insert_at_already_used_index failed",
- (oldCount + 5 == bparr.Count())
+ oldCount + 5, bparr.Count()
);
// now, first 5 elements have counts: 30,31,..34
@@ -269,10 +269,10 @@ public:
delete bparr[0]; // release content
bparr.Remove(0); // remove item from container
- CPPUNIT_ASSERT_MESSAGE
+ CPPUNIT_ASSERT_EQUAL_MESSAGE
(
"test_remove_at_front failed (wrong count)",
- (oldCount - 1 == bparr.Count())
+ oldCount - 1, bparr.Count()
);
for (sal_uLong j = 0, k = i + 1; j < bparr.Count(); j++, k++)
@@ -351,10 +351,10 @@ public:
delete bparr[bparr.Count() / 2];
bparr.Remove(bparr.Count() / 2);
- CPPUNIT_ASSERT_MESSAGE
+ CPPUNIT_ASSERT_EQUAL_MESSAGE
(
"test_remove_in_the_middle failed (wrong count)",
- (oldCount - 1 == bparr.Count())
+ oldCount - 1, bparr.Count()
);
for (sal_uLong i = 0; i < bparr.Count(); i++)
@@ -395,10 +395,10 @@ public:
bparr.Remove(0, nRemove);
- CPPUNIT_ASSERT_MESSAGE
+ CPPUNIT_ASSERT_EQUAL_MESSAGE
(
"test_remove_multiple_elements_at_once failed",
- (oldCount - nRemove == bparr.Count())
+ oldCount - nRemove, bparr.Count()
);
CPPUNIT_ASSERT_MESSAGE
commit afe5ffaec56c7073e34f852d28ab26da59654e67
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Fri Apr 28 14:22:26 2017 +0200
loplugin:cppunitassertequals: starmath
Change-Id: I09b1d5c6ac271041963e7043487c79f6b92649ca
diff --git a/starmath/qa/cppunit/test_starmath.cxx b/starmath/qa/cppunit/test_starmath.cxx
index 8ec24004e9ad..8accbc2225ae 100644
--- a/starmath/qa/cppunit/test_starmath.cxx
+++ b/starmath/qa/cppunit/test_starmath.cxx
@@ -217,8 +217,8 @@ void Test::ParseErrorUnexpectedToken()
m_xDocShRef->SetText("\\foo");
const SmErrorDesc *pErrorDesc = m_xDocShRef->GetParser().NextError();
CPPUNIT_ASSERT(pErrorDesc);
- CPPUNIT_ASSERT_MESSAGE("SmParseError::UnexpectedToken expected",
- SmParseError::UnexpectedToken == pErrorDesc->m_eType);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("SmParseError::UnexpectedToken expected",
+ SmParseError::UnexpectedToken, pErrorDesc->m_eType);
}
void Test::ParseErrorPoundExpected()
@@ -226,8 +226,8 @@ void Test::ParseErrorPoundExpected()
m_xDocShRef->SetText("matrix {1#2##a##b#c}");
const SmErrorDesc *pErrorDesc = m_xDocShRef->GetParser().NextError();
CPPUNIT_ASSERT(pErrorDesc);
- CPPUNIT_ASSERT_MESSAGE("SmParseError::PoundExpected expected",
- SmParseError::PoundExpected == pErrorDesc->m_eType);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("SmParseError::PoundExpected expected",
+ SmParseError::PoundExpected, pErrorDesc->m_eType);
}
void Test::ParseErrorColorExpected()
@@ -235,8 +235,8 @@ void Test::ParseErrorColorExpected()
m_xDocShRef->SetText("color 42 x");
const SmErrorDesc *pErrorDesc = m_xDocShRef->GetParser().NextError();
CPPUNIT_ASSERT(pErrorDesc);
- CPPUNIT_ASSERT_MESSAGE("SmParseError::ColorExpected expected",
- SmParseError::ColorExpected == pErrorDesc->m_eType);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("SmParseError::ColorExpected expected",
+ SmParseError::ColorExpected, pErrorDesc->m_eType);
}
void Test::ParseErrorLgroupExpected()
@@ -244,8 +244,8 @@ void Test::ParseErrorLgroupExpected()
m_xDocShRef->SetText("stack 42");
const SmErrorDesc *pErrorDesc = m_xDocShRef->GetParser().NextError();
CPPUNIT_ASSERT(pErrorDesc);
- CPPUNIT_ASSERT_MESSAGE("SmParseError::LgroupExpected expected",
- SmParseError::LgroupExpected == pErrorDesc->m_eType);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("SmParseError::LgroupExpected expected",
+ SmParseError::LgroupExpected, pErrorDesc->m_eType);
}
void Test::ParseErrorRgroupExpected()
@@ -253,8 +253,8 @@ void Test::ParseErrorRgroupExpected()
m_xDocShRef->SetText("stack {a#b#c)");
const SmErrorDesc *pErrorDesc = m_xDocShRef->GetParser().NextError();
CPPUNIT_ASSERT(pErrorDesc);
- CPPUNIT_ASSERT_MESSAGE("SmParseError::RgroupExpected expected",
- SmParseError::RgroupExpected == pErrorDesc->m_eType);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("SmParseError::RgroupExpected expected",
+ SmParseError::RgroupExpected, pErrorDesc->m_eType);
}
void Test::ParseErrorLbraceExpected()
@@ -262,8 +262,8 @@ void Test::ParseErrorLbraceExpected()
m_xDocShRef->SetText("left 42");
const SmErrorDesc *pErrorDesc = m_xDocShRef->GetParser().NextError();
CPPUNIT_ASSERT(pErrorDesc);
- CPPUNIT_ASSERT_MESSAGE("SmParseError::LbraceExpected expected",
- SmParseError::LbraceExpected == pErrorDesc->m_eType);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("SmParseError::LbraceExpected expected",
+ SmParseError::LbraceExpected, pErrorDesc->m_eType);
}
void Test::ParseErrorRbraceExpected()
@@ -271,8 +271,8 @@ void Test::ParseErrorRbraceExpected()
m_xDocShRef->SetText("left ( foo right x");
const SmErrorDesc *pErrorDesc = m_xDocShRef->GetParser().NextError();
CPPUNIT_ASSERT(pErrorDesc);
- CPPUNIT_ASSERT_MESSAGE("SmParseError::RbraceExpected expected",
- SmParseError::RbraceExpected == pErrorDesc->m_eType);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("SmParseError::RbraceExpected expected",
+ SmParseError::RbraceExpected, pErrorDesc->m_eType);
}
void Test::ParseErrorParentMismatch()
@@ -280,8 +280,8 @@ void Test::ParseErrorParentMismatch()
m_xDocShRef->SetText("lbrace foo rceil");
const SmErrorDesc *pErrorDesc = m_xDocShRef->GetParser().NextError();
CPPUNIT_ASSERT(pErrorDesc);
- CPPUNIT_ASSERT_MESSAGE("SmParseError::ParentMismatch expected",
- SmParseError::ParentMismatch == pErrorDesc->m_eType);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("SmParseError::ParentMismatch expected",
+ SmParseError::ParentMismatch, pErrorDesc->m_eType);
}
void Test::ParseErrorRightExpected()
@@ -289,8 +289,8 @@ void Test::ParseErrorRightExpected()
m_xDocShRef->SetText("left ( x mline y )");
const SmErrorDesc *pErrorDesc = m_xDocShRef->GetParser().NextError();
CPPUNIT_ASSERT(pErrorDesc);
- CPPUNIT_ASSERT_MESSAGE("SmParseError::RightExpected expected",
- SmParseError::RightExpected == pErrorDesc->m_eType);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("SmParseError::RightExpected expected",
+ SmParseError::RightExpected, pErrorDesc->m_eType);
}
void Test::ParseErrorFontExpected()
@@ -298,8 +298,8 @@ void Test::ParseErrorFontExpected()
m_xDocShRef->SetText("font small bar");
const SmErrorDesc *pErrorDesc = m_xDocShRef->GetParser().NextError();
CPPUNIT_ASSERT(pErrorDesc);
- CPPUNIT_ASSERT_MESSAGE("SmParseError::FontExpected expected",
- SmParseError::FontExpected == pErrorDesc->m_eType);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("SmParseError::FontExpected expected",
+ SmParseError::FontExpected, pErrorDesc->m_eType);
}
void Test::ParseErrorSizeExpected()
@@ -307,8 +307,8 @@ void Test::ParseErrorSizeExpected()
m_xDocShRef->SetText("size small baz");
const SmErrorDesc *pErrorDesc = m_xDocShRef->GetParser().NextError();
CPPUNIT_ASSERT(pErrorDesc);
- CPPUNIT_ASSERT_MESSAGE("SmParseError::SizeExpected expected",
- SmParseError::SizeExpected == pErrorDesc->m_eType);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("SmParseError::SizeExpected expected",
+ SmParseError::SizeExpected, pErrorDesc->m_eType);
}
void Test::ParseErrorDoubleAlign()
@@ -316,8 +316,8 @@ void Test::ParseErrorDoubleAlign()
m_xDocShRef->SetText("alignl alignc x");
const SmErrorDesc *pErrorDesc = m_xDocShRef->GetParser().NextError();
CPPUNIT_ASSERT(pErrorDesc);
- CPPUNIT_ASSERT_MESSAGE("SmParseError::DoubleAlign expected",
- SmParseError::DoubleAlign == pErrorDesc->m_eType);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("SmParseError::DoubleAlign expected",
+ SmParseError::DoubleAlign, pErrorDesc->m_eType);
}
void Test::ParseErrorDoubleSubsupscript()
@@ -325,8 +325,8 @@ void Test::ParseErrorDoubleSubsupscript()
m_xDocShRef->SetText("x_y_z");
const SmErrorDesc *pErrorDesc = m_xDocShRef->GetParser().NextError();
CPPUNIT_ASSERT(pErrorDesc);
- CPPUNIT_ASSERT_MESSAGE("SmParseError::DoubleSubsupscript expected",
- SmParseError::DoubleSubsupscript == pErrorDesc->m_eType);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("SmParseError::DoubleSubsupscript expected",
+ SmParseError::DoubleSubsupscript, pErrorDesc->m_eType);
}
void Test::editUndoRedo()
commit dbd19620884893d7644d2bed8e01f5c6590f0fc5
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Fri Apr 28 14:22:14 2017 +0200
loplugin:cppunitassertequals: sdext
Change-Id: I9c00bed21ae2ca49d1be60fe2161271cb7aa334d
diff --git a/sdext/source/pdfimport/test/tests.cxx b/sdext/source/pdfimport/test/tests.cxx
index 987865c258db..578933c07ff1 100644
--- a/sdext/source/pdfimport/test/tests.cxx
+++ b/sdext/source/pdfimport/test/tests.cxx
@@ -230,8 +230,8 @@ namespace
rtl::math::approxEqual(rContext.LineWidth, 28.3) );
const char sExportString[] = "m53570 7650-35430 24100";
- CPPUNIT_ASSERT_MESSAGE( "Stroke is m535.7 518.5-354.3-241",
- basegfx::tools::exportToSvgD( aPath, true, true, false ) == sExportString );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "Stroke is m535.7 518.5-354.3-241",
+ OUString(sExportString), basegfx::tools::exportToSvgD( aPath, true, true, false ) );
m_bGreenStrokeSeen = true;
}
@@ -252,17 +252,17 @@ namespace
0, rContext.LineWidth, 0.0000001 );
const char sExportString[] = "m49890 5670.00000000001-35430 24090";
- CPPUNIT_ASSERT_MESSAGE( "Stroke is m49890 5670.00000000001-35430 24090",
- basegfx::tools::exportToSvgD( aPath, true, true, false ) == sExportString );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "Stroke is m49890 5670.00000000001-35430 24090",
+ OUString(sExportString), basegfx::tools::exportToSvgD( aPath, true, true, false ) );
m_bDashedLineSeen = true;
}
- CPPUNIT_ASSERT_MESSAGE( "Blend mode is normal",
- rContext.BlendMode == rendering::BlendMode::NORMAL );
- CPPUNIT_ASSERT_MESSAGE( "Join type is round",
- rContext.LineJoin == rendering::PathJoinType::ROUND );
- CPPUNIT_ASSERT_MESSAGE( "Cap type is butt",
- rContext.LineCap == rendering::PathCapType::BUTT );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "Blend mode is normal",
+ rendering::BlendMode::NORMAL, rContext.BlendMode );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "Join type is round",
+ rendering::PathJoinType::ROUND, rContext.LineJoin );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "Cap type is butt",
+ rendering::PathCapType::BUTT, rContext.LineCap );
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "Line miter limit is 10",
10, rContext.MiterLimit, 0.0000001 );
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "Flatness is 0",
@@ -282,8 +282,8 @@ namespace
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "Line color is black", 0.0, rContext.LineColor.Green, 0.00000001);
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "Line color is black", 0.0, rContext.LineColor.Red, 0.00000001);
- CPPUNIT_ASSERT_MESSAGE( "Blend mode is normal",
- rContext.BlendMode == rendering::BlendMode::NORMAL );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "Blend mode is normal",
+ rendering::BlendMode::NORMAL, rContext.BlendMode );
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "Flatness is 10",
10, rContext.Flatness, 0.00000001 );
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Font id is 0",
@@ -301,8 +301,8 @@ namespace
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "Line color is black", 0.0, rContext.LineColor.Green, 0.00000001);
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "Line color is black", 0.0, rContext.LineColor.Red, 0.00000001);
- CPPUNIT_ASSERT_MESSAGE( "Blend mode is normal",
- rContext.BlendMode == rendering::BlendMode::NORMAL );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "Blend mode is normal",
+ rendering::BlendMode::NORMAL, rContext.BlendMode );
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "Flatness is 0",
1, rContext.Flatness, 0.00000001 );
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Font id is 0",
@@ -310,8 +310,8 @@ namespace
const char sExportString[] = "m12050 49610c-4310 0-7800-3490-7800-7800 0-4300 "
"3490-7790 7800-7790 4300 0 7790 3490 7790 7790 0 4310-3490 7800-7790 7800z";
- CPPUNIT_ASSERT_MESSAGE( "Stroke is a 4-bezier circle",
- basegfx::tools::exportToSvgD( aPath, true, true, false ) == sExportString );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "Stroke is a 4-bezier circle",
+ OUString(sExportString), basegfx::tools::exportToSvgD( aPath, true, true, false ) );
m_bRedCircleSeen = true;
}
@@ -356,20 +356,20 @@ namespace
{
CPPUNIT_ASSERT_EQUAL_MESSAGE( "drawMask received two properties",
(sal_Int32) 3, xBitmap.getLength() );
- CPPUNIT_ASSERT_MESSAGE( "drawMask got URL param",
- xBitmap[0].Name == "URL" );
- CPPUNIT_ASSERT_MESSAGE( "drawMask got InputStream param",
- xBitmap[1].Name == "InputStream" );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "drawMask got URL param",
+ OUString("URL"), xBitmap[0].Name );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "drawMask got InputStream param",
+ OUString("InputStream"), xBitmap[1].Name );
}
virtual void drawImage(const uno::Sequence<beans::PropertyValue>& xBitmap ) override
{
CPPUNIT_ASSERT_EQUAL_MESSAGE( "drawImage received two properties",
(sal_Int32) 3, xBitmap.getLength() );
- CPPUNIT_ASSERT_MESSAGE( "drawImage got URL param",
- xBitmap[0].Name == "URL" );
- CPPUNIT_ASSERT_MESSAGE( "drawImage got InputStream param",
- xBitmap[1].Name == "InputStream" );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "drawImage got URL param",
+ OUString("URL"), xBitmap[0].Name );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "drawImage got InputStream param",
+ OUString("InputStream"), xBitmap[1].Name );
m_bImageSeen = true;
}
@@ -378,10 +378,10 @@ namespace
{
CPPUNIT_ASSERT_EQUAL_MESSAGE( "drawColorMaskedImage received two properties",
(sal_Int32) 3, xBitmap.getLength() );
- CPPUNIT_ASSERT_MESSAGE( "drawColorMaskedImage got URL param",
- xBitmap[0].Name == "URL" );
- CPPUNIT_ASSERT_MESSAGE( "drawColorMaskedImage got InputStream param",
- xBitmap[1].Name == "InputStream" );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "drawColorMaskedImage got URL param",
+ OUString("URL"), xBitmap[0].Name );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "drawColorMaskedImage got InputStream param",
+ OUString("InputStream"), xBitmap[1].Name );
}
virtual void drawMaskedImage(const uno::Sequence<beans::PropertyValue>& xBitmap,
@@ -390,17 +390,17 @@ namespace
{
CPPUNIT_ASSERT_EQUAL_MESSAGE( "drawMaskedImage received two properties #1",
(sal_Int32) 3, xBitmap.getLength() );
- CPPUNIT_ASSERT_MESSAGE( "drawMaskedImage got URL param #1",
- xBitmap[0].Name == "URL" );
- CPPUNIT_ASSERT_MESSAGE( "drawMaskedImage got InputStream param #1",
- xBitmap[1].Name == "InputStream" );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "drawMaskedImage got URL param #1",
+ OUString("URL"), xBitmap[0].Name );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "drawMaskedImage got InputStream param #1",
+ OUString("InputStream"), xBitmap[1].Name );
CPPUNIT_ASSERT_EQUAL_MESSAGE( "drawMaskedImage received two properties #2",
(sal_Int32) 3, xMask.getLength() );
- CPPUNIT_ASSERT_MESSAGE( "drawMaskedImage got URL param #2",
- xMask[0].Name == "URL" );
- CPPUNIT_ASSERT_MESSAGE( "drawMaskedImage got InputStream param #2",
- xMask[1].Name == "InputStream" );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "drawMaskedImage got URL param #2",
+ OUString("URL"), xMask[0].Name );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "drawMaskedImage got InputStream param #2",
+ OUString("InputStream"), xMask[1].Name );
}
virtual void drawAlphaMaskedImage(const uno::Sequence<beans::PropertyValue>& xBitmap,
@@ -408,17 +408,17 @@ namespace
{
CPPUNIT_ASSERT_EQUAL_MESSAGE( "drawAlphaMaskedImage received two properties #1",
(sal_Int32) 3, xBitmap.getLength() );
- CPPUNIT_ASSERT_MESSAGE( "drawAlphaMaskedImage got URL param #1",
- xBitmap[0].Name == "URL" );
- CPPUNIT_ASSERT_MESSAGE( "drawAlphaMaskedImage got InputStream param #1",
- xBitmap[1].Name == "InputStream" );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "drawAlphaMaskedImage got URL param #1",
+ OUString("URL"), xBitmap[0].Name );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "drawAlphaMaskedImage got InputStream param #1",
+ OUString("InputStream"), xBitmap[1].Name );
CPPUNIT_ASSERT_EQUAL_MESSAGE( "drawAlphaMaskedImage received two properties #2",
(sal_Int32) 3, xMask.getLength() );
- CPPUNIT_ASSERT_MESSAGE( "drawAlphaMaskedImage got URL param #2",
- xMask[0].Name == "URL" );
- CPPUNIT_ASSERT_MESSAGE( "drawAlphaMaskedImage got InputStream param #2",
- xMask[1].Name == "InputStream" );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "drawAlphaMaskedImage got URL param #2",
+ OUString("URL"), xMask[0].Name );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "drawAlphaMaskedImage got InputStream param #2",
+ OUString("InputStream"), xMask[1].Name );
}
virtual void setTextRenderMode( sal_Int32 ) override
@@ -469,7 +469,7 @@ namespace
xAdaptor->setTreeVisitorFactory( createDrawTreeVisitorFactory() );
OUString tempFileURL;
- CPPUNIT_ASSERT( osl::File::createTempFile( nullptr, nullptr, &tempFileURL ) == osl::File::E_None );
+ CPPUNIT_ASSERT_EQUAL( osl::File::E_None, osl::File::createTempFile( nullptr, nullptr, &tempFileURL ) );
osl::File::remove( tempFileURL ); // FIXME the below apparently fails silently if the file already exists
CPPUNIT_ASSERT_MESSAGE("Exporting to ODF",
xAdaptor->odfConvert( m_directories.getURLFromSrc("/sdext/source/pdfimport/test/testinput.pdf"),
@@ -484,7 +484,7 @@ namespace
xAdaptor->setTreeVisitorFactory( createWriterTreeVisitorFactory() );
OUString tempFileURL;
- CPPUNIT_ASSERT( osl::File::createTempFile( nullptr, nullptr, &tempFileURL ) == osl::File::E_None );
+ CPPUNIT_ASSERT_EQUAL( osl::File::E_None, osl::File::createTempFile( nullptr, nullptr, &tempFileURL ) );
osl::File::remove( tempFileURL ); // FIXME the below apparently fails silently if the file already exists
CPPUNIT_ASSERT_MESSAGE("Exporting to ODF",
xAdaptor->odfConvert( m_directories.getURLFromSrc("/sdext/source/pdfimport/test/testinput.pdf"),
commit 8cab8bdfe3fd14a07fb472d6af752ee946dc2cad
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Fri Apr 28 14:22:08 2017 +0200
loplugin:cppunitassertequals: sc
Change-Id: Ifc250cf5bc293b4c87b9abb2d00be62078c2338a
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index d96a3b62025d..1b62334c6b43 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -3175,7 +3175,7 @@ void ScFiltersTest::testCustomNumFormatHybridCellODS()
// Make sure the cell doesn't have an error value.
ScFormulaCell* pFC = rDoc.GetFormulaCell(ScAddress(1,17,0));
CPPUNIT_ASSERT(pFC);
- CPPUNIT_ASSERT(pFC->GetErrCode() == FormulaError::NONE);
+ CPPUNIT_ASSERT_EQUAL(FormulaError::NONE, pFC->GetErrCode());
xDocSh->DoClose();
}
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 4ee671a7122f..220a1a271e3b 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -33,6 +33,8 @@
#include <svx/svdpage.hxx>
#include <chrono>
+#include <cstddef>
+
#include <tabvwsh.hxx>
#include <docsh.hxx>
#include <document.hxx>
@@ -1173,38 +1175,38 @@ void ScTiledRenderingTest::testUndoLimiting()
Scheduler::ProcessEventsToIdle();
// check that undo action count in not 0
- CPPUNIT_ASSERT(pUndoManager->GetUndoActionCount() == 1);
+ CPPUNIT_ASSERT_EQUAL(std::size_t(1), pUndoManager->GetUndoActionCount());
// try to execute undo in view #2
SfxLokHelper::setView(nView2);
comphelper::dispatchCommand(".uno:Undo", {});
Scheduler::ProcessEventsToIdle();
// check that undo has not been executed on view #2
- CPPUNIT_ASSERT(pUndoManager->GetUndoActionCount() == 1);
+ CPPUNIT_ASSERT_EQUAL(std::size_t(1), pUndoManager->GetUndoActionCount());
// try to execute undo in view #1
SfxLokHelper::setView(nView1);
comphelper::dispatchCommand(".uno:Undo", {});
Scheduler::ProcessEventsToIdle();
// check that undo has been executed on view #1
- CPPUNIT_ASSERT(pUndoManager->GetUndoActionCount() == 0);
+ CPPUNIT_ASSERT_EQUAL(std::size_t(0), pUndoManager->GetUndoActionCount());
// check that redo action count in not 0
- CPPUNIT_ASSERT(pUndoManager->GetRedoActionCount() == 1);
+ CPPUNIT_ASSERT_EQUAL(std::size_t(1), pUndoManager->GetRedoActionCount());
// try to execute redo in view #2
SfxLokHelper::setView(nView2);
comphelper::dispatchCommand(".uno:Redo", {});
Scheduler::ProcessEventsToIdle();
// check that redo has not been executed on view #2
- CPPUNIT_ASSERT(pUndoManager->GetRedoActionCount() == 1);
+ CPPUNIT_ASSERT_EQUAL(std::size_t(1), pUndoManager->GetRedoActionCount());
// try to execute redo in view #1
SfxLokHelper::setView(nView1);
comphelper::dispatchCommand(".uno:Redo", {});
Scheduler::ProcessEventsToIdle();
// check that redo has been executed on view #1
- CPPUNIT_ASSERT(pUndoManager->GetRedoActionCount() == 0);
+ CPPUNIT_ASSERT_EQUAL(std::size_t(0), pUndoManager->GetRedoActionCount());
mxComponent->dispose();
mxComponent.clear();
@@ -1244,14 +1246,14 @@ void ScTiledRenderingTest::testUndoRepairDispatch()
Scheduler::ProcessEventsToIdle();
// check that undo action count in not 0
- CPPUNIT_ASSERT(pUndoManager->GetUndoActionCount() == 1);
+ CPPUNIT_ASSERT_EQUAL(std::size_t(1), pUndoManager->GetUndoActionCount());
// try to execute undo in view #2
SfxLokHelper::setView(nView2);
comphelper::dispatchCommand(".uno:Undo", {});
Scheduler::ProcessEventsToIdle();
// check that undo has not been executed on view #2
- CPPUNIT_ASSERT(pUndoManager->GetUndoActionCount() == 1);
+ CPPUNIT_ASSERT_EQUAL(std::size_t(1), pUndoManager->GetUndoActionCount());
// try to execute undo in view #2 in repair mode
SfxLokHelper::setView(nView2);
@@ -1262,7 +1264,7 @@ void ScTiledRenderingTest::testUndoRepairDispatch()
comphelper::dispatchCommand(".uno:Undo", aPropertyValues);
Scheduler::ProcessEventsToIdle();
// check that undo has been executed on view #2 in repair mode
- CPPUNIT_ASSERT(pUndoManager->GetUndoActionCount() == 0);
+ CPPUNIT_ASSERT_EQUAL(std::size_t(0), pUndoManager->GetUndoActionCount());
mxComponent->dispose();
mxComponent.clear();
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 9918e88e7f25..9e159df21875 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -5415,7 +5415,7 @@ void Test::testNoteLifeCycle()
ScPostIt* pUndoNoteB4 = m_pDoc->GetNote(aPosB4);
CPPUNIT_ASSERT_MESSAGE("No cell comment at B4 after Undo.", pUndoNoteB4);
const SdrCaptionObj* pUndoCaptionB4 = pUndoNoteB4->GetCaption();
- CPPUNIT_ASSERT_MESSAGE("Captions not identical after Merge Undo.", pCaptionB4 == pUndoCaptionB4);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Captions not identical after Merge Undo.", pCaptionB4, pUndoCaptionB4);
// In a second document copy a note from B5 to clipboard, close the
commit 9384a34644fb1a6c791681c1bd7c4985f2437bea
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Fri Apr 28 14:22:04 2017 +0200
loplugin:cppunitassertequals: sal
Change-Id: I6ba9a18a1d227461e023259662635e3008ad7c9b
diff --git a/sal/qa/OStringBuffer/rtl_OStringBuffer.cxx b/sal/qa/OStringBuffer/rtl_OStringBuffer.cxx
index caad268044da..6e33ea5b2b70 100644
--- a/sal/qa/OStringBuffer/rtl_OStringBuffer.cxx
+++ b/sal/qa/OStringBuffer/rtl_OStringBuffer.cxx
@@ -49,8 +49,17 @@ namespace rtl_OStringBuffer
CPPUNIT_ASSERT_MESSAGE
(
"New OStringBuffer containing no characters",
- aStrBuf.isEmpty() &&
- *pStr == '\0' && aStrBuf.getCapacity() == 16
+ aStrBuf.isEmpty()
+ );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE
+ (
+ "New OStringBuffer containing no characters",
+ '\0', *pStr
+ );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE
+ (
+ "New OStringBuffer containing no characters",
+ sal_Int32(16), aStrBuf.getCapacity()
);
}
@@ -66,11 +75,19 @@ namespace rtl_OStringBuffer
rtl::OString sStr(aStrBuftmp.getStr());
bool res = aStrtmp.equals( sStr );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE
+ (
+ "New OStringBuffer from another OStringBuffer",
+ nLenStrBuftmp, aStrBuf.getLength()
+ );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE
+ (
+ "New OStringBuffer from another OStringBuffer",
+ aStrBuftmp.getCapacity(), aStrBuf.getCapacity()
+ );
CPPUNIT_ASSERT_MESSAGE
(
"New OStringBuffer from another OStringBuffer",
- aStrBuf.getLength() == nLenStrBuftmp &&
- aStrBuf.getCapacity() == aStrBuftmp.getCapacity() &&
res
);
@@ -87,12 +104,32 @@ namespace rtl_OStringBuffer
CPPUNIT_ASSERT_MESSAGE
(
"New OStringBuffer containing no characters and contain assigned capacity",
- aStrBuf1.isEmpty() &&
- *pStr1 == '\0' &&
- aStrBuf1.getCapacity() == kTestStr2Len &&
- aStrBuf2.isEmpty() &&
- *pStr2 == '\0' &&
- aStrBuf2.getCapacity() == 0
+ aStrBuf1.isEmpty()
+ );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE
+ (
+ "New OStringBuffer containing no characters and contain assigned capacity",
+ '\0', *pStr1
+ );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE
+ (
+ "New OStringBuffer containing no characters and contain assigned capacity",
+ kTestStr2Len, aStrBuf1.getCapacity()
+ );
+ CPPUNIT_ASSERT_MESSAGE
+ (
+ "New OStringBuffer containing no characters and contain assigned capacity",
+ aStrBuf2.isEmpty()
+ );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE
+ (
+ "New OStringBuffer containing no characters and contain assigned capacity",
+ '\0', *pStr2
+ );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE
+ (
+ "New OStringBuffer containing no characters and contain assigned capacity",
+ sal_Int32(0), aStrBuf2.getCapacity()
);
}
@@ -108,9 +145,17 @@ namespace rtl_OStringBuffer
CPPUNIT_ASSERT_MESSAGE
(
"New OStringBuffer containing no characters and contain assigned capacity",
- aStrBuf3.isEmpty() &&
- *pStr == '\0' &&
- aStrBuf3.getCapacity() == kNonSInt32Max
+ aStrBuf3.isEmpty()
+ );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE
+ (
+ "New OStringBuffer containing no characters and contain assigned capacity",
+ '\0', *pStr
+ );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE
+ (
+ "New OStringBuffer containing no characters and contain assigned capacity",
+ kNonSInt32Max, aStrBuf3.getCapacity()
);
}
@@ -120,12 +165,20 @@ namespace rtl_OStringBuffer
::rtl::OStringBuffer aStrBuf( aStrtmp );
sal_Int32 leg = aStrBuf.getLength();
- CPPUNIT_ASSERT_MESSAGE
+ CPPUNIT_ASSERT_EQUAL_MESSAGE
+ (
+ "New OStringBuffer from OString",
+ aStrtmp, OString(aStrBuf.getStr())
+ );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE
+ (
+ "New OStringBuffer from OString",
+ aStrtmp.pData->length, leg
+ );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE
(
"New OStringBuffer from OString",
- aStrBuf.getStr() == aStrtmp &&
- leg == aStrtmp.pData->length &&
- aStrBuf.getCapacity() == leg+16
+ leg+16, aStrBuf.getCapacity()
);
}
@@ -145,11 +198,15 @@ namespace rtl_OStringBuffer
::rtl::OStringBuffer aStrBuf(kTestStr1);
sal_Int32 leg = aStrBuf.getLength();
- CPPUNIT_ASSERT_MESSAGE
+ CPPUNIT_ASSERT_EQUAL_MESSAGE
+ (
+ "New OStringBuffer from const char*",
+ rtl_str_getLength(kTestStr1), leg
+ );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE
(
"New OStringBuffer from const char*",
- leg == rtl_str_getLength(kTestStr1) &&
- aStrBuf.getCapacity() == leg+16
+ leg+16, aStrBuf.getCapacity()
);
}
@@ -196,8 +253,17 @@ namespace rtl_OStringBuffer
CPPUNIT_ASSERT_MESSAGE
(
"two empty strings(def. constructor)",
- lastRes && ( aStrBuf1.getCapacity() == 0 ) &&
- ( *(aStrBuf1.getStr()) == '\0' )
+ lastRes
+ );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE
+ (
+ "two empty strings(def. constructor)",
+ sal_Int32(0), aStrBuf1.getCapacity()
+ );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE
+ (
+ "two empty strings(def. constructor)",
+ '\0', *(aStrBuf1.getStr())
);
}
diff --git a/sal/qa/osl/condition/osl_Condition.cxx b/sal/qa/osl/condition/osl_Condition.cxx
index 8ee37b2c0aac..6d0245d2905b 100644
--- a/sal/qa/osl/condition/osl_Condition.cxx
+++ b/sal/qa/osl/condition/osl_Condition.cxx
@@ -131,7 +131,11 @@ namespace osl_Condition
myThread2.join( );
CPPUNIT_ASSERT_MESSAGE( "#test comment#: use one thread to set the condition in order to release another thread.",
- bRes && !bRes1 && bRes2 );
+ bRes );
+ CPPUNIT_ASSERT_MESSAGE( "#test comment#: use one thread to set the condition in order to release another thread.",
+ !bRes1 );
+ CPPUNIT_ASSERT_MESSAGE( "#test comment#: use one thread to set the condition in order to release another thread.",
+ bRes2 );
}
CPPUNIT_TEST_SUITE( set );
@@ -163,7 +167,11 @@ namespace osl_Condition
bRes1 = myThread.isRunning( );
CPPUNIT_ASSERT_MESSAGE( "#test comment#: wait will cause a reset thread block, use set to release it.",
- bRes && !bRes1 && !bRes2 );
+ bRes );
+ CPPUNIT_ASSERT_MESSAGE( "#test comment#: wait will cause a reset thread block, use set to release it.",
+ !bRes1 );
+ CPPUNIT_ASSERT_MESSAGE( "#test comment#: wait will cause a reset thread block, use set to release it.",
+ !bRes2 );
}
void reset_002( )
@@ -175,7 +183,9 @@ namespace osl_Condition
bRes1 = aCond.check( );
CPPUNIT_ASSERT_MESSAGE( "#test comment#: create a condition and reset/set it.",
- !bRes && bRes1 );
+ !bRes );
+ CPPUNIT_ASSERT_MESSAGE( "#test comment#: create a condition and reset/set it.",
+ bRes1 );
}
CPPUNIT_TEST_SUITE( reset );
@@ -219,10 +229,12 @@ namespace osl_Condition
osl::Condition::Result r2=cond2.wait();
osl::Condition::Result r3=cond3.wait(tv1);
- CPPUNIT_ASSERT_MESSAGE( "#test comment#: test three types of wait.",
- (r1 == ::osl::Condition::result_ok) &&
- (r2 == ::osl::Condition::result_ok) &&
- (r3 == ::osl::Condition::result_timeout) );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "#test comment#: test three types of wait.",
+ ::osl::Condition::result_ok, r1 );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "#test comment#: test three types of wait.",
+ ::osl::Condition::result_ok, r2 );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "#test comment#: test three types of wait.",
+ ::osl::Condition::result_timeout, r3 );
}
void wait_002( )
@@ -239,9 +251,13 @@ namespace osl_Condition
bRes1 = aCond.check( );
CPPUNIT_ASSERT_MESSAGE( "#test comment#: wait a condition after set/reset.",
- !bRes && bRes1 &&
- ( ::osl::Condition::result_timeout == wRes ) &&
- ( ::osl::Condition::result_ok == wRes1 ) );
+ !bRes );
+ CPPUNIT_ASSERT_MESSAGE( "#test comment#: wait a condition after set/reset.",
+ bRes1 );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "#test comment#: wait a condition after set/reset.",
+ ::osl::Condition::result_timeout, wRes );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "#test comment#: wait a condition after set/reset.",
+ ::osl::Condition::result_ok, wRes1 );
}
CPPUNIT_TEST_SUITE( wait );
@@ -268,7 +284,9 @@ namespace osl_Condition
bRes1 = aCond.check( );
CPPUNIT_ASSERT_MESSAGE( "#test comment#: check the condition states.",
- !bRes && bRes1 );
+ !bRes );
+ CPPUNIT_ASSERT_MESSAGE( "#test comment#: check the condition states.",
+ bRes1 );
}
void check_002( )
@@ -287,7 +305,9 @@ namespace osl_Condition
bRes1 = aCond.check( );
CPPUNIT_ASSERT_MESSAGE( "#test comment#: use threads to set/reset Condition and check it in main routine.",
- bRes && !bRes1 );
+ bRes );
+ CPPUNIT_ASSERT_MESSAGE( "#test comment#: use threads to set/reset Condition and check it in main routine.",
+ !bRes1 );
}
CPPUNIT_TEST_SUITE( check );
diff --git a/sal/qa/osl/file/osl_File.cxx b/sal/qa/osl/file/osl_File.cxx
index 027c556d5cb8..f2bfb47c2c41 100644
--- a/sal/qa/osl/file/osl_File.cxx
+++ b/sal/qa/osl/file/osl_File.cxx
@@ -689,8 +689,10 @@ namespace osl_FileBase
if (!_sAssumeResultStr.isEmpty())
{
bool bStrAreEqual = _sAssumeResultStr.equals(sStr);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "Assumption is wrong",
+ _nAssumeError, nError );
CPPUNIT_ASSERT_MESSAGE( "Assumption is wrong",
- nError == _nAssumeError && bStrAreEqual );
+ bStrAreEqual );
}
else
{
@@ -908,7 +910,8 @@ namespace osl_FileBase
sError += outputError(::rtl::OUStringToOString( aUStr, RTL_TEXTENCODING_ASCII_US ),
::rtl::OUStringToOString( aUResultURL, RTL_TEXTENCODING_ASCII_US ));
- CPPUNIT_ASSERT_MESSAGE(sError.getStr(), ( osl::FileBase::E_None == nError ) && bOk );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sError.getStr(), osl::FileBase::E_None, nError );
+ CPPUNIT_ASSERT_MESSAGE(sError.getStr(), bOk );
}
@@ -931,7 +934,8 @@ namespace osl_FileBase
::rtl::OUStringToOString( aUResultURL, RTL_TEXTENCODING_ASCII_US ));
deleteTestDirectory( aTmpName10 );
- CPPUNIT_ASSERT_MESSAGE( sError.getStr(), ( osl::FileBase::E_None == nError ) && bOk );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( sError.getStr(), osl::FileBase::E_None, nError );
+ CPPUNIT_ASSERT_MESSAGE( sError.getStr(), bOk );
}
void SystemPath_FileURL::getFileURLFromSystemPath_001()
@@ -999,10 +1003,12 @@ namespace osl_FileBase
/* search file is passed by relative file path */
nError3 = ::osl::FileBase::searchFileURL( aRelURL4, aUserDirectorySys, aUStr );
- CPPUNIT_ASSERT_MESSAGE( "test for searchFileURL function: system filename/URL filename/relative path, system directory, searched files that is not exist, but it reply invalid error, did not pass in (W32) ",
- ( osl::FileBase::E_NOENT == nError1 ) &&
- ( osl::FileBase::E_NOENT == nError2 ) &&
- ( osl::FileBase::E_NOENT == nError3 ));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for searchFileURL function: system filename/URL filename/relative path, system directory, searched files that is not exist, but it reply invalid error, did not pass in (W32) ",
+ osl::FileBase::E_NOENT, nError1 );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for searchFileURL function: system filename/URL filename/relative path, system directory, searched files that is not exist, but it reply invalid error, did not pass in (W32) ",
+ osl::FileBase::E_NOENT, nError2 );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for searchFileURL function: system filename/URL filename/relative path, system directory, searched files that is not exist, but it reply invalid error, did not pass in (W32) ",
+ osl::FileBase::E_NOENT, nError3 );
}
void searchFileURL_002()
@@ -1022,12 +1028,22 @@ namespace osl_FileBase
bool bOk4 = compareFileName( aUStr, aCanURL1 );
deleteTestFile( aCanURL1 );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for searchFileURL function: system filename/URL filename/relative path, system directory, searched file already exist.",
+ osl::FileBase::E_None, nError1 );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for searchFileURL function: system filename/URL filename/relative path, system directory, searched file already exist.",
+ osl::FileBase::E_None, nError2 );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for searchFileURL function: system filename/URL filename/relative path, system directory, searched file already exist.",
+ osl::FileBase::E_None, nError3 );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for searchFileURL function: system filename/URL filename/relative path, system directory, searched file already exist.",
+ osl::FileBase::E_None, nError4 );
CPPUNIT_ASSERT_MESSAGE( "test for searchFileURL function: system filename/URL filename/relative path, system directory, searched file already exist.",
- ( osl::FileBase::E_None == nError1 ) &&
- ( osl::FileBase::E_None == nError2 ) &&
- ( osl::FileBase::E_None == nError3 ) &&
- ( osl::FileBase::E_None == nError4 ) &&
- bOk1 && bOk2 && bOk3 && bOk4 );
+ bOk1 );
+ CPPUNIT_ASSERT_MESSAGE( "test for searchFileURL function: system filename/URL filename/relative path, system directory, searched file already exist.",
+ bOk2 );
+ CPPUNIT_ASSERT_MESSAGE( "test for searchFileURL function: system filename/URL filename/relative path, system directory, searched file already exist.",
+ bOk3 );
+ CPPUNIT_ASSERT_MESSAGE( "test for searchFileURL function: system filename/URL filename/relative path, system directory, searched file already exist.",
+ bOk4 );
}
void searchFileURL_003()
@@ -1035,8 +1051,9 @@ namespace osl_FileBase
OUString aSystemPathList( TEST_PLATFORM_ROOT ":" TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP ":" TEST_PLATFORM_ROOT "system/path" );
nError1 = ::osl::FileBase::searchFileURL( aUserDirectoryURL, aSystemPathList, aUStr );
bool bOk = compareFileName( aUStr, aUserDirectoryURL );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for searchFileURL function: search directory is a list of system paths",
+ osl::FileBase::E_None, nError1 );
CPPUNIT_ASSERT_MESSAGE( "test for searchFileURL function: search directory is a list of system paths",
- ( osl::FileBase::E_None == nError1 ) &&
bOk );
}
@@ -1045,8 +1062,9 @@ namespace osl_FileBase
OUString aSystemPathList( TEST_PLATFORM_ROOT PATH_LIST_DELIMITER TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP PATH_LIST_DELIMITER TEST_PLATFORM_ROOT "system/path/../name" );
nError1 = ::osl::FileBase::searchFileURL( aUserDirectoryURL, aSystemPathList, aUStr );
bool bOk = compareFileName( aUStr, aUserDirectoryURL );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for searchFileURL function: search directory is a list of system paths",
+ osl::FileBase::E_None, nError1 );
CPPUNIT_ASSERT_MESSAGE( "test for searchFileURL function: search directory is a list of system paths",
- ( osl::FileBase::E_None == nError1 ) &&
bOk );
}
@@ -1054,8 +1072,9 @@ namespace osl_FileBase
{
nError1 = ::osl::FileBase::searchFileURL( aUserDirectoryURL, aNullURL, aUStr );
bool bOk = compareFileName( aUStr, aUserDirectoryURL );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for searchFileURL function: search directory is NULL",
+ osl::FileBase::E_None, nError1 );
CPPUNIT_ASSERT_MESSAGE( "test for searchFileURL function: search directory is NULL",
- ( osl::FileBase::E_None == nError1 ) &&
bOk );
}
@@ -1089,15 +1108,17 @@ namespace osl_FileBase
void getTempDirURL_001()
{
- CPPUNIT_ASSERT_MESSAGE( "test for getTempDirURL function: excution",
- ( osl::FileBase::E_None == nError ) );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for getTempDirURL function: excution",
+ osl::FileBase::E_None, nError );
}
void getTempDirURL_002()
{
CPPUNIT_ASSERT_MESSAGE( "test for getTempDirURL function: test for open and write access rights",
- checkDirectory( aUStr, oslCheckMode::OpenAccess ) &&
- checkDirectory( aUStr, oslCheckMode::ReadAccess ) &&
+ checkDirectory( aUStr, oslCheckMode::OpenAccess ) );
+ CPPUNIT_ASSERT_MESSAGE( "test for getTempDirURL function: test for open and write access rights",
+ checkDirectory( aUStr, oslCheckMode::ReadAccess ) );
+ CPPUNIT_ASSERT_MESSAGE( "test for getTempDirURL function: test for open and write access rights",
checkDirectory( aUStr, oslCheckMode::WriteAccess ) );
}
@@ -1160,8 +1181,12 @@ namespace osl_FileBase
deleteTestFile( *pUStr_FileURL );
}
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for createTempFile function: create temp file and test the existence",
+ osl::FileBase::E_None, nError1 );
CPPUNIT_ASSERT_MESSAGE( "test for createTempFile function: create temp file and test the existence",
- ( osl::FileBase::E_None == nError1 ) && ( pHandle != nullptr ) && ( osl::FileBase::E_EXIST== nError2 ) );
+ ( pHandle != nullptr ) );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for createTempFile function: create temp file and test the existence",
+ osl::FileBase::E_EXIST, nError2 );
}
void createTempFile_002()
@@ -1171,9 +1196,12 @@ namespace osl_FileBase
::osl::File testFile( *pUStr_FileURL );
nError2 = testFile.open( osl_File_OpenFlag_Create );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "createTempFile function: create a temp file, but it does not exist",
+ osl::FileBase::E_None, nError1 );
CPPUNIT_ASSERT_MESSAGE( "createTempFile function: create a temp file, but it does not exist",
- ( osl::FileBase::E_None == nError1 ) && ( pHandle != nullptr ) &&
- ( osl::FileBase::E_EXIST == nError2 ) );
+ ( pHandle != nullptr ) );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "createTempFile function: create a temp file, but it does not exist",
+ osl::FileBase::E_EXIST, nError2 );
//check file if have the write permission
if ( osl::FileBase::E_EXIST == nError2 ) {
@@ -1194,8 +1222,10 @@ namespace osl_FileBase
if ( bOK )
osl_closeFile( *pHandle );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for createTempFile function: set pUStrFileURL to 0 to let it remove the file after call.",
+ ::osl::FileBase::E_None, nError1 );
CPPUNIT_ASSERT_MESSAGE( "test for createTempFile function: set pUStrFileURL to 0 to let it remove the file after call.",
- ( ::osl::FileBase::E_None == nError1 ) && bOK );
+ bOK );
}
void createTempFile_004()
{
@@ -1205,8 +1235,12 @@ namespace osl_FileBase
::osl::File testFile( *pUStr_FileURL );
nError2 = testFile.open( osl_File_OpenFlag_Create );
deleteTestFile( *pUStr_FileURL );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "createTempFile function: create a temp file, but it does not exist",
+ osl::FileBase::E_None, nError1 );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "createTempFile function: create a temp file, but it does not exist",
+ osl::FileBase::E_EXIST, nError2 );
CPPUNIT_ASSERT_MESSAGE( "createTempFile function: create a temp file, but it does not exist",
- ( osl::FileBase::E_None == nError1 ) && ( osl::FileBase::E_EXIST == nError2 ) && bOK );
+ bOK );
}
@@ -1789,7 +1823,8 @@ namespace osl_FileStatus
::osl::FileStatus rFileStatus( osl_FileStatus_Mask_AccessTime );
nError = rItem.getFileStatus( rFileStatus );
bool bOk = osl_getSystemTime( pTV_current );
- CPPUNIT_ASSERT( bOk && nError == FileBase::E_None );
+ CPPUNIT_ASSERT( bOk );
+ CPPUNIT_ASSERT_EQUAL( FileBase::E_None, nError );
*pTV_access = rFileStatus.getAccessTime();
@@ -2129,8 +2164,10 @@ namespace osl_File
::osl::FileBase::RC nError1 = testFile.open( osl_File_OpenFlag_Read | osl_File_OpenFlag_Write );
::osl::FileBase::RC nError2 = testFile.close();
- CPPUNIT_ASSERT_MESSAGE( "test for ctors function: initialize a File and test its open and close",
- ( ::osl::FileBase::E_None == nError1 ) && ( ::osl::FileBase::E_None == nError2 ) );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for ctors function: initialize a File and test its open and close",
+ ::osl::FileBase::E_None, nError1 );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for ctors function: initialize a File and test its open and close",
+ ::osl::FileBase::E_None, nError2 );
}
void ctors_002()
@@ -2143,8 +2180,10 @@ namespace osl_File
::osl::FileBase::RC nError2 = testFile.write( buffer, 30, nCount );
testFile.close();
- CPPUNIT_ASSERT_MESSAGE( "test for ctors function: test relative file URL, this test show that relative file URL is also acceptable",
- ( ::osl::FileBase::E_None == nError1 ) && ( ::osl::FileBase::E_None == nError2 ) );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for ctors function: test relative file URL, this test show that relative file URL is also acceptable",
+ ::osl::FileBase::E_None, nError1 );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for ctors function: test relative file URL, this test show that relative file URL is also acceptable",
+ ::osl::FileBase::E_None, nError2 );
}
CPPUNIT_TEST_SUITE( ctors );
@@ -2259,12 +2298,16 @@ namespace osl_File
::osl::FileBase::RC nError6 = osl::File::remove( aCanURL1 );
CPPUNIT_ASSERT_EQUAL( nError6, ::osl::FileBase::E_None );
- CPPUNIT_ASSERT_MESSAGE( "test for open function: test for osl_File_OpenFlag_Read, osl_File_OpenFlag_Write and osl_File_OpenFlag_Create",
- ( ::osl::FileBase::E_None == nError1 ) &&
- ( ::osl::FileBase::E_None == nError2 ) &&
- ( ::osl::FileBase::E_None == nError3 ) &&
- ( 30 == nCount_write ) &&
- ( 10 == nCount_read ) );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for open function: test for osl_File_OpenFlag_Read, osl_File_OpenFlag_Write and osl_File_OpenFlag_Create",
+ ::osl::FileBase::E_None, nError1 );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for open function: test for osl_File_OpenFlag_Read, osl_File_OpenFlag_Write and osl_File_OpenFlag_Create",
+ ::osl::FileBase::E_None, nError2 );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for open function: test for osl_File_OpenFlag_Read, osl_File_OpenFlag_Write and osl_File_OpenFlag_Create",
+ ::osl::FileBase::E_None, nError3 );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for open function: test for osl_File_OpenFlag_Read, osl_File_OpenFlag_Write and osl_File_OpenFlag_Create",
+ sal_uInt64(30), nCount_write );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for open function: test for osl_File_OpenFlag_Read, osl_File_OpenFlag_Write and osl_File_OpenFlag_Create",
+ sal_uInt64(10), nCount_read );
}
CPPUNIT_TEST_SUITE( open );
@@ -2329,8 +2372,9 @@ namespace osl_File
nError3 = testFile.setPos( osl_Pos_Absolut, 0 );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for close function: manipulate a file after it has been closed",
+ ::osl::FileBase::E_None, nError2 );
CPPUNIT_ASSERT_MESSAGE( "test for close function: manipulate a file after it has been closed",
- ( ::osl::FileBase::E_None == nError2 ) &&
( ::osl::FileBase::E_None != nError3 ) );
}
@@ -2774,8 +2818,10 @@ namespace osl_File
nError1 = testFile.close();
CPPUNIT_ASSERT_EQUAL( nError1, ::osl::FileBase::E_None );
- CPPUNIT_ASSERT_MESSAGE( "test for read function: read whole content in the file to a buffer",
- ( 10 == nFilePointer ) && ( 0 == strncmp( buffer_read, pBuffer_Char, 10 ) ) );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for read function: read whole content in the file to a buffer",
+ sal_uInt64(10), nFilePointer );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for read function: read whole content in the file to a buffer",
+ 0, strncmp( buffer_read, pBuffer_Char, 10 ) );
}
void read_002()
@@ -2797,8 +2843,12 @@ namespace osl_File
nError1 = testFile.close();
CPPUNIT_ASSERT_EQUAL( nError1, ::osl::FileBase::E_None );
- CPPUNIT_ASSERT_MESSAGE( "test for read function: read from a special position in the file",
- ( 52 == nFilePointer ) && ( 26 == nCount_read ) && ( 0 == strncmp( buffer_read, &pBuffer_Char[26], 26 ) ) );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for read function: read from a special position in the file",
+ sal_uInt64(52), nFilePointer );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for read function: read from a special position in the file",
+ sal_uInt64(26), nCount_read );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for read function: read from a special position in the file",
+ 0, strncmp( buffer_read, &pBuffer_Char[26], 26 ) );
}
CPPUNIT_TEST_SUITE( read );
@@ -2861,10 +2911,12 @@ namespace osl_File
nError1 = testFile.close();
CPPUNIT_ASSERT_EQUAL( nError1, ::osl::FileBase::E_None );
- CPPUNIT_ASSERT_MESSAGE( "test for write function: read whole content in the file to a buffer. Note, buffer size can not smaller than the read size",
- ( 10 == nFilePointer ) &&
- ( 0 == strncmp( buffer_read, pBuffer_Char, 10 ) ) &&
- ( 10 == nCount_write ) );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for write function: read whole content in the file to a buffer. Note, buffer size can not smaller than the read size",
+ sal_uInt64(10), nFilePointer );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for write function: read whole content in the file to a buffer. Note, buffer size can not smaller than the read size",
+ 0, strncmp( buffer_read, pBuffer_Char, 10 ) );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for write function: read whole content in the file to a buffer. Note, buffer size can not smaller than the read size",
+ sal_uInt64(10), nCount_write );
}
CPPUNIT_TEST_SUITE( write );
@@ -2928,9 +2980,10 @@ namespace osl_File
CPPUNIT_ASSERT_EQUAL( nError1, ::osl::FileBase::E_None );
nError1 = testFile.readLine( aSequence );
CPPUNIT_ASSERT_EQUAL( nError1, ::osl::FileBase::E_None );
- CPPUNIT_ASSERT_MESSAGE( "test for readLine function: read the first line of the file.",
- ( ::osl::FileBase::E_None == nError1 ) &&
- ( 0 == strncmp( reinterpret_cast<char *>(aSequence.getArray()), pBuffer_Char, 5 ) ) );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for readLine function: read the first line of the file.",
+ ::osl::FileBase::E_None, nError1 );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for readLine function: read the first line of the file.",
+ 0, strncmp( reinterpret_cast<char *>(aSequence.getArray()), pBuffer_Char, 5 ) );
}
void readLine_002()
@@ -2950,8 +3003,9 @@ namespace osl_File
CPPUNIT_ASSERT_EQUAL( nError1, ::osl::FileBase::E_None );
CPPUNIT_ASSERT_MESSAGE( "test for readLine function: read three lines of the file and check the file pointer moving.",
- *pEOF &&
- ( 0 == strncmp( reinterpret_cast<char *>(aSequence.getArray()), &pBuffer_Char[26], 26 ) ) );
+ *pEOF );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for readLine function: read three lines of the file and check the file pointer moving.",
+ 0, strncmp( reinterpret_cast<char *>(aSequence.getArray()), &pBuffer_Char[26], 26 ) );
}
CPPUNIT_TEST_SUITE( readLine );
CPPUNIT_TEST( readLine_001 );
@@ -3199,8 +3253,10 @@ namespace osl_File
nError1 = ::osl::FileBase::E_NOTDIR;
nError2 = ::osl::FileBase::E_ISDIR;
#endif
- CPPUNIT_ASSERT_MESSAGE( "test for move function: move a directory to an exist file with same name, did not pass in (W32)",
- ::osl::FileBase::E_NOTDIR == nError1 && ::osl::FileBase::E_ISDIR == nError2 );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for move function: move a directory to an exist file with same name, did not pass in (W32)",
+ ::osl::FileBase::E_NOTDIR, nError1 );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for move function: move a directory to an exist file with same name, did not pass in (W32)",
+ ::osl::FileBase::E_ISDIR, nError2 );
}
void move_007()
@@ -3214,9 +3270,10 @@ namespace osl_File
::osl::File::move( aTmpName8, aTmpName3 );
deleteTestDirectory( aTmpName6 );
- CPPUNIT_ASSERT_MESSAGE( "test for move function: move a directory to an exist file with same name",
- (::osl::FileBase::E_None == nError1 ) &&
- (::osl::FileBase::E_EXIST == nError2 ) );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for move function: move a directory to an exist file with same name",
+ ::osl::FileBase::E_None, nError1 );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for move function: move a directory to an exist file with same name",
+ ::osl::FileBase::E_EXIST, nError2 );
}
//bugid# 115420, after the bug fix, add the case
CPPUNIT_TEST_SUITE( move );
@@ -3280,8 +3337,9 @@ namespace osl_File
::osl::File testFile( aTmpName4 );
nError2 = testFile.open( osl_File_OpenFlag_Create );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for remove function: remove a file",
+ ::osl::FileBase::E_None, nError1 );
CPPUNIT_ASSERT_MESSAGE( "test for remove function: remove a file",
- ( ::osl::FileBase::E_None == nError1 ) &&
( ::osl::FileBase::E_EXIST != nError2 ) );
}
@@ -3290,8 +3348,8 @@ namespace osl_File
//remove $TEMP/tmpname.
nError1 = ::osl::File::remove( aTmpName6 );
- CPPUNIT_ASSERT_MESSAGE( "test for remove function: remove a file not exist",
- ( ::osl::FileBase::E_NOENT == nError1 ) );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for remove function: remove a file not exist",
+ ::osl::FileBase::E_NOENT, nError1 );
}
void remove_003()
@@ -3299,8 +3357,8 @@ namespace osl_File
//remove $TEMP/system/path.
nError1 = ::osl::File::remove( aSysPath2 );
- CPPUNIT_ASSERT_MESSAGE( "test for remove function: removing a file not using full qualified URL",
- ( ::osl::FileBase::E_INVAL == nError1 ) );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for remove function: removing a file not using full qualified URL",
+ ::osl::FileBase::E_INVAL, nError1 );
}
void remove_004()
@@ -3767,8 +3825,9 @@ namespace osl_DirectoryItem
nError1 = rItem.getFileStatus( rFileStatus );
CPPUNIT_ASSERT_EQUAL( FileBase::E_None, nError1 );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for get function: use copy constructor to get an item and check filename.",
+ ::osl::FileBase::E_None, nError2 );
CPPUNIT_ASSERT_MESSAGE( "test for get function: use copy constructor to get an item and check filename.",
- ( ::osl::FileBase::E_None == nError2 ) &&
compareFileName( rFileStatus.getFileName(), aTmpName2 ) );
}
@@ -3835,8 +3894,9 @@ namespace osl_DirectoryItem
::osl::FileStatus rFileStatus( osl_FileStatus_Mask_FileName );
nError2 = rItem.getFileStatus( rFileStatus );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for getFileStatus function: get file status and check filename",
+ ::osl::FileBase::E_None, nError2 );
CPPUNIT_ASSERT_MESSAGE( "test for getFileStatus function: get file status and check filename",
- ( ::osl::FileBase::E_None == nError2 ) &&
compareFileName( rFileStatus.getFileName(), aTmpName2 ) );
}
@@ -3850,8 +3910,8 @@ namespace osl_DirectoryItem
::osl::FileStatus rFileStatus( osl_FileStatus_Mask_FileName );
nError2 = rItem.getFileStatus( rFileStatus );
- CPPUNIT_ASSERT_MESSAGE( "test for getFileStatus function: file not existed",
- ( ::osl::FileBase::E_INVAL == nError2 ) );
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list