diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-12-09 08:11:47 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-12-09 12:07:19 +0100 |
commit | a0ab0c79fdbaa0a915bc29655cfd03f378599203 (patch) | |
tree | bb1e0c7a3d35d5732f009ee888b2d52e9112f212 /tools | |
parent | ff3d175eef06d67133ba686ff8b2ea9261de2c2b (diff) |
CppunitTest_tools_test: fix loplugin:cppunitassertequals warnings
Change-Id: I6738b6b5159403f1654b401a27f08fc829521e73
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qa/cppunit/test_stream.cxx | 44 | ||||
-rw-r--r-- | tools/qa/cppunit/test_urlobj.cxx | 120 |
2 files changed, 82 insertions, 82 deletions
diff --git a/tools/qa/cppunit/test_stream.cxx b/tools/qa/cppunit/test_stream.cxx index 22d66a556492..166315672363 100644 --- a/tools/qa/cppunit/test_stream.cxx +++ b/tools/qa/cppunit/test_stream.cxx @@ -46,11 +46,11 @@ namespace char std_a(78); iss >> std_a; - CPPUNIT_ASSERT(std_a == 'f'); + CPPUNIT_ASSERT_EQUAL('f', std_a); char tools_a(78); aMemStream.ReadChar( tools_a ); - CPPUNIT_ASSERT(tools_a == 'f'); + CPPUNIT_ASSERT_EQUAL('f', tools_a); iss.seekg(0, std::ios_base::end); //seeking to end doesn't set eof, reading past eof does @@ -67,19 +67,19 @@ namespace //so, now eof is set CPPUNIT_ASSERT(iss.eof()); //a failed read doesn't change the data, it remains unchanged - CPPUNIT_ASSERT(std_a == 78); + CPPUNIT_ASSERT_EQUAL(static_cast<char>(78), std_a); //nothing wrong with the stream, so not bad CPPUNIT_ASSERT(!iss.bad()); //yet, the read didn't succeed CPPUNIT_ASSERT(!iss.good()); - CPPUNIT_ASSERT(iss.rdstate() == (std::ios::failbit|std::ios::eofbit)); + CPPUNIT_ASSERT_EQUAL((std::ios::failbit|std::ios::eofbit), iss.rdstate()); tools_a = 78; aMemStream.ReadChar( tools_a ); //so, now eof is set CPPUNIT_ASSERT(aMemStream.eof()); //a failed read doesn't change the data, it remains unchanged - CPPUNIT_ASSERT(tools_a == 78); + CPPUNIT_ASSERT_EQUAL(static_cast<char>(78), tools_a); //nothing wrong with the stream, so not bad CPPUNIT_ASSERT(!aMemStream.bad()); //yet, the read didn't succeed @@ -95,18 +95,18 @@ namespace aMemStream.ReadUInt16( tools_b ); CPPUNIT_ASSERT(!aMemStream.good()); CPPUNIT_ASSERT(aMemStream.eof()); - CPPUNIT_ASSERT(tools_b == 0x1122); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(0x1122), tools_b); iss.clear(); iss.seekg(0); CPPUNIT_ASSERT(iss.good()); iss >> std_a; - CPPUNIT_ASSERT(std_a == 'f'); + CPPUNIT_ASSERT_EQUAL('f', std_a); aMemStream.Seek(0); CPPUNIT_ASSERT(aMemStream.good()); aMemStream.ReadChar( tools_a ); - CPPUNIT_ASSERT(tools_a == 'f'); + CPPUNIT_ASSERT_EQUAL('f', tools_a); //failbit is rather subtle wrt e.g seeks @@ -116,7 +116,7 @@ namespace iss.seekg(0); CPPUNIT_ASSERT(iss.good()); iss.read(buffer, sizeof(buffer)); - CPPUNIT_ASSERT(iss.gcount() == 3); + CPPUNIT_ASSERT_EQUAL(static_cast<std::streamsize>(3), iss.gcount()); CPPUNIT_ASSERT(!iss.good()); CPPUNIT_ASSERT(!iss.bad()); CPPUNIT_ASSERT(iss.eof()); @@ -124,7 +124,7 @@ namespace aMemStream.Seek(0); CPPUNIT_ASSERT(aMemStream.good()); std::size_t nRet = aMemStream.ReadBytes(buffer, sizeof(buffer)); - CPPUNIT_ASSERT(nRet == 3); + CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(3), nRet); CPPUNIT_ASSERT(!aMemStream.good()); CPPUNIT_ASSERT(!aMemStream.bad()); CPPUNIT_ASSERT(aMemStream.eof()); @@ -136,10 +136,10 @@ namespace SvMemoryStream aMemStream(foo, SAL_N_ELEMENTS(foo)-1, StreamMode::READ); OString aOne = read_uInt8s_ToOString(aMemStream, 3); - CPPUNIT_ASSERT(aOne == "foo"); + CPPUNIT_ASSERT_EQUAL(OString("foo"), aOne); OString aTwo = read_uInt8s_ToOString(aMemStream, 3); - CPPUNIT_ASSERT(aTwo == "bar"); + CPPUNIT_ASSERT_EQUAL(OString("bar"), aTwo); OString aThree = read_uInt8s_ToOString(aMemStream, 3); CPPUNIT_ASSERT(aThree.isEmpty()); @@ -147,7 +147,7 @@ namespace aMemStream.Seek(0); OString aFour = read_uInt8s_ToOString(aMemStream, 100); - CPPUNIT_ASSERT(aFour == foo); + CPPUNIT_ASSERT_EQUAL(OString(foo), aFour); } void Test::test_read_cstring() @@ -156,7 +156,7 @@ namespace SvMemoryStream aMemStream(foo, SAL_N_ELEMENTS(foo)-1, StreamMode::READ); OString aOne = read_zeroTerminated_uInt8s_ToOString(aMemStream); - CPPUNIT_ASSERT(aOne == "foobar"); + CPPUNIT_ASSERT_EQUAL(OString("foobar"), aOne); CPPUNIT_ASSERT(!aMemStream.good()); CPPUNIT_ASSERT(!aMemStream.bad()); CPPUNIT_ASSERT(aMemStream.eof()); @@ -164,7 +164,7 @@ namespace aMemStream.Seek(0); foo[3] = 0; OString aTwo = read_zeroTerminated_uInt8s_ToOString(aMemStream); - CPPUNIT_ASSERT(aTwo == "foo"); + CPPUNIT_ASSERT_EQUAL(OString("foo"), aTwo); CPPUNIT_ASSERT(aMemStream.good()); } @@ -174,7 +174,7 @@ namespace SvMemoryStream aMemStream(foo, SAL_N_ELEMENTS(foo)-1, StreamMode::READ); OString aFoo = read_uInt8_lenPrefixed_uInt8s_ToOString(aMemStream); - CPPUNIT_ASSERT(aFoo == "foo"); + CPPUNIT_ASSERT_EQUAL(OString("foo"), aFoo); CPPUNIT_ASSERT(aMemStream.good()); CPPUNIT_ASSERT(!aMemStream.bad()); CPPUNIT_ASSERT(!aMemStream.eof()); @@ -182,7 +182,7 @@ namespace aMemStream.Seek(0); foo[0] = 10; aFoo = read_uInt8_lenPrefixed_uInt8s_ToOString(aMemStream); - CPPUNIT_ASSERT(aFoo == "foobar"); + CPPUNIT_ASSERT_EQUAL(OString("foobar"), aFoo); CPPUNIT_ASSERT(!aMemStream.good()); CPPUNIT_ASSERT(!aMemStream.bad()); CPPUNIT_ASSERT(aMemStream.eof()); @@ -192,7 +192,7 @@ namespace foo[0] = 0; foo[1] = 3; aFoo = read_uInt16_lenPrefixed_uInt8s_ToOString(aMemStream); - CPPUNIT_ASSERT(aFoo == "oob"); + CPPUNIT_ASSERT_EQUAL(OString("oob"), aFoo); CPPUNIT_ASSERT(aMemStream.good()); CPPUNIT_ASSERT(!aMemStream.bad()); CPPUNIT_ASSERT(!aMemStream.eof()); @@ -208,12 +208,12 @@ namespace bRet = aMemStream.ReadLine(aFoo); CPPUNIT_ASSERT(bRet); - CPPUNIT_ASSERT(aFoo == "foo"); + CPPUNIT_ASSERT_EQUAL(OString("foo"), aFoo); CPPUNIT_ASSERT(aMemStream.good()); bRet = aMemStream.ReadLine(aFoo); CPPUNIT_ASSERT(bRet); - CPPUNIT_ASSERT(aFoo == "bar"); + CPPUNIT_ASSERT_EQUAL(OString("bar"), aFoo); CPPUNIT_ASSERT(aMemStream.good()); bRet = aMemStream.ReadLine(aFoo); @@ -263,12 +263,12 @@ namespace SvMemoryStream aMemStreamB(bar, SAL_N_ELEMENTS(bar)-1, StreamMode::READ); bRet = aMemStreamB.ReadLine(aFoo); CPPUNIT_ASSERT(bRet); - CPPUNIT_ASSERT(aFoo == "foo"); + CPPUNIT_ASSERT_EQUAL(OString("foo"), aFoo); CPPUNIT_ASSERT(!aMemStreamB.eof()); //<-- diff A std::istringstream issB(bar, std::istringstream::in); std::getline(issB, sStr, '\n'); - CPPUNIT_ASSERT(sStr == "foo"); + CPPUNIT_ASSERT_EQUAL(std::string("foo"), sStr); CPPUNIT_ASSERT(issB.eof()); //<-- diff A } diff --git a/tools/qa/cppunit/test_urlobj.cxx b/tools/qa/cppunit/test_urlobj.cxx index d2b74237cab8..00ca3f720621 100644 --- a/tools/qa/cppunit/test_urlobj.cxx +++ b/tools/qa/cppunit/test_urlobj.cxx @@ -49,23 +49,23 @@ namespace tools_urlobj { INetURLObject aUrl( OUString( "file://10.10.1.1/sampledir/sample.file" ) ); #ifdef LINUX - CPPUNIT_ASSERT( aUrl.GetMainURL( INetURLObject::DecodeMechanism::NONE ) - == "smb://10.10.1.1/sampledir/sample.file" ); - CPPUNIT_ASSERT( aUrl.GetProtocol( ) == INetProtocol::Smb ); + CPPUNIT_ASSERT_EQUAL(OUString("smb://10.10.1.1/sampledir/sample.file"), + aUrl.GetMainURL(INetURLObject::DecodeMechanism::NONE)); + 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 ); #endif - CPPUNIT_ASSERT( aUrl.GetHost( INetURLObject::DecodeMechanism::NONE ) - == "10.10.1.1" ); - CPPUNIT_ASSERT( aUrl.GetURLPath( INetURLObject::DecodeMechanism::NONE ) - == "/sampledir/sample.file" ); - CPPUNIT_ASSERT( aUrl.getName( ) - == "sample.file" ); - CPPUNIT_ASSERT( aUrl.getBase( ) == "sample" ); - CPPUNIT_ASSERT( aUrl.getExtension( ) == "file" ); + CPPUNIT_ASSERT_EQUAL(OUString("10.10.1.1"), + aUrl.GetHost(INetURLObject::DecodeMechanism::NONE)); + CPPUNIT_ASSERT_EQUAL(OUString("/sampledir/sample.file"), + aUrl.GetURLPath(INetURLObject::DecodeMechanism::NONE)); + CPPUNIT_ASSERT_EQUAL(OUString("sample.file"), + aUrl.getName()); + CPPUNIT_ASSERT_EQUAL(OUString("sample"), aUrl.getBase()); + CPPUNIT_ASSERT_EQUAL(OUString("file"), aUrl.getExtension()); } void urlobjTest_002( ) @@ -75,22 +75,22 @@ namespace tools_urlobj setFSysPath( "\\\\137.65.170.24\\c$\\Img0001.jpg", FSysStyle::Detect ); #ifdef LINUX - CPPUNIT_ASSERT( aUrl.GetMainURL( INetURLObject::DecodeMechanism::NONE ) - == "smb://137.65.170.24/c$/Img0001.jpg" ); - CPPUNIT_ASSERT( aUrl.GetProtocol( ) == INetProtocol::Smb ); + CPPUNIT_ASSERT_EQUAL(OUString("smb://137.65.170.24/c$/Img0001.jpg"), + aUrl.GetMainURL(INetURLObject::DecodeMechanism::NONE)); + 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 ); #endif - CPPUNIT_ASSERT( aUrl.GetHost( INetURLObject::DecodeMechanism::NONE ) - == "137.65.170.24" ); - CPPUNIT_ASSERT( aUrl.GetURLPath( INetURLObject::DecodeMechanism::NONE ) - == "/c$/Img0001.jpg" ); - CPPUNIT_ASSERT( aUrl.getName( ) == "Img0001.jpg" ); - CPPUNIT_ASSERT( aUrl.getBase( ) == "Img0001" ); - CPPUNIT_ASSERT( aUrl.getExtension( ) == "jpg" ); + CPPUNIT_ASSERT_EQUAL(OUString("137.65.170.24"), + aUrl.GetHost(INetURLObject::DecodeMechanism::NONE)); + CPPUNIT_ASSERT_EQUAL(OUString("/c$/Img0001.jpg"), + aUrl.GetURLPath(INetURLObject::DecodeMechanism::NONE)); + CPPUNIT_ASSERT_EQUAL(OUString("Img0001.jpg"), aUrl.getName()); + CPPUNIT_ASSERT_EQUAL(OUString("Img0001"), aUrl.getBase()); + CPPUNIT_ASSERT_EQUAL(OUString("jpg"), aUrl.getExtension()); } @@ -101,41 +101,41 @@ namespace tools_urlobj setFSysPath( "\\\\hive-winxp-x86\\pmladek\\test2.odt", FSysStyle::Detect ); #ifdef LINUX - CPPUNIT_ASSERT( aUrl.GetMainURL( INetURLObject::DecodeMechanism::NONE ) - == "smb://hive-winxp-x86/pmladek/test2.odt" ); - CPPUNIT_ASSERT( aUrl.GetProtocol( ) == INetProtocol::Smb ); + CPPUNIT_ASSERT_EQUAL(OUString("smb://hive-winxp-x86/pmladek/test2.odt"), + aUrl.GetMainURL(INetURLObject::DecodeMechanism::NONE)); + 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 ); #endif - CPPUNIT_ASSERT( aUrl.GetHost( INetURLObject::DecodeMechanism::NONE ) - == "hive-winxp-x86" ); - CPPUNIT_ASSERT( aUrl.GetURLPath( INetURLObject::DecodeMechanism::NONE ) - == "/pmladek/test2.odt" ); + CPPUNIT_ASSERT_EQUAL(OUString("hive-winxp-x86"), + aUrl.GetHost(INetURLObject::DecodeMechanism::NONE)); + CPPUNIT_ASSERT_EQUAL(OUString("/pmladek/test2.odt"), + aUrl.GetURLPath(INetURLObject::DecodeMechanism::NONE)); } void urlobjTest_004( ) { INetURLObject aUrl( OUString( "smb://10.10.1.1/sampledir/sample.file" ) ); #ifdef LINUX - CPPUNIT_ASSERT( aUrl.GetMainURL( INetURLObject::DecodeMechanism::NONE ) - == "smb://10.10.1.1/sampledir/sample.file" ); - CPPUNIT_ASSERT( aUrl.GetProtocol( ) == INetProtocol::Smb ); + CPPUNIT_ASSERT_EQUAL(OUString("smb://10.10.1.1/sampledir/sample.file"), + aUrl.GetMainURL(INetURLObject::DecodeMechanism::NONE)); + 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 ); #endif - CPPUNIT_ASSERT( aUrl.GetHost( INetURLObject::DecodeMechanism::NONE ) - == "10.10.1.1" ); - CPPUNIT_ASSERT( aUrl.GetURLPath( INetURLObject::DecodeMechanism::NONE ) - == "/sampledir/sample.file" ); - CPPUNIT_ASSERT( aUrl.getName( ) == "sample.file" ); - CPPUNIT_ASSERT( aUrl.getBase( ) == "sample" ); - CPPUNIT_ASSERT( aUrl.getExtension( ) == "file" ); + CPPUNIT_ASSERT_EQUAL(OUString("10.10.1.1"), + aUrl.GetHost(INetURLObject::DecodeMechanism::NONE)); + CPPUNIT_ASSERT_EQUAL(OUString("/sampledir/sample.file"), + aUrl.GetURLPath(INetURLObject::DecodeMechanism::NONE)); + CPPUNIT_ASSERT_EQUAL(OUString("sample.file"), aUrl.getName()); + CPPUNIT_ASSERT_EQUAL(OUString("sample"), aUrl.getBase()); + CPPUNIT_ASSERT_EQUAL(OUString("file"), aUrl.getExtension()); } void urlobjTest_005( ) @@ -144,22 +144,22 @@ namespace tools_urlobj aUrl.setFSysPath( "//137.65.170.24/c$/Img0001.jpg", FSysStyle::Detect ); #ifdef LINUX - CPPUNIT_ASSERT( aUrl.GetMainURL( INetURLObject::DecodeMechanism::NONE ) - == "smb://137.65.170.24/c$/Img0001.jpg" ); - CPPUNIT_ASSERT( aUrl.GetProtocol( ) == INetProtocol::Smb ); + CPPUNIT_ASSERT_EQUAL(OUString("smb://137.65.170.24/c$/Img0001.jpg"), + aUrl.GetMainURL(INetURLObject::DecodeMechanism::NONE)); + 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 ); #endif - CPPUNIT_ASSERT( aUrl.GetHost( INetURLObject::DecodeMechanism::NONE ) - == "137.65.170.24" ); - CPPUNIT_ASSERT( aUrl.GetURLPath( INetURLObject::DecodeMechanism::NONE ) - == "/c$/Img0001.jpg" ); - CPPUNIT_ASSERT( aUrl.getName( ) == "Img0001.jpg" ); - CPPUNIT_ASSERT( aUrl.getBase( ) == "Img0001" ); - CPPUNIT_ASSERT( aUrl.getExtension( ) == "jpg" ); + CPPUNIT_ASSERT_EQUAL(OUString("137.65.170.24"), + aUrl.GetHost(INetURLObject::DecodeMechanism::NONE)); + CPPUNIT_ASSERT_EQUAL(OUString("/c$/Img0001.jpg"), + aUrl.GetURLPath(INetURLObject::DecodeMechanism::NONE)); + CPPUNIT_ASSERT_EQUAL(OUString("Img0001.jpg"), aUrl.getName( )); + CPPUNIT_ASSERT_EQUAL(OUString("Img0001"), aUrl.getBase( )); + CPPUNIT_ASSERT_EQUAL(OUString("jpg"), aUrl.getExtension( )); } @@ -169,19 +169,19 @@ namespace tools_urlobj aUrl.setFSysPath( "//hive-winxp-x86/pmladek/test2.odt", FSysStyle::Detect ); #ifdef LINUX - CPPUNIT_ASSERT( aUrl.GetMainURL( INetURLObject::DecodeMechanism::NONE ) - == "smb://hive-winxp-x86/pmladek/test2.odt" ); - CPPUNIT_ASSERT( aUrl.GetProtocol( ) == INetProtocol::Smb ); + CPPUNIT_ASSERT_EQUAL(OUString("smb://hive-winxp-x86/pmladek/test2.odt"), + aUrl.GetMainURL(INetURLObject::DecodeMechanism::NONE)); + 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 ); #endif - CPPUNIT_ASSERT( aUrl.GetHost( INetURLObject::DecodeMechanism::NONE ) - == "hive-winxp-x86" ); - CPPUNIT_ASSERT( aUrl.GetURLPath( INetURLObject::DecodeMechanism::NONE ) - == "/pmladek/test2.odt" ); + CPPUNIT_ASSERT_EQUAL(OUString("hive-winxp-x86"), + aUrl.GetHost(INetURLObject::DecodeMechanism::NONE)); + CPPUNIT_ASSERT_EQUAL(OUString("/pmladek/test2.odt"), + aUrl.GetURLPath( INetURLObject::DecodeMechanism::NONE)); } void urlobjCmisTest( ) @@ -239,7 +239,7 @@ namespace tools_urlobj url = INetURLObject("data:"); //TODO: CPPUNIT_ASSERT(url.HasError()); strm = url.getData(); - CPPUNIT_ASSERT(strm == nullptr); + CPPUNIT_ASSERT(!strm); url = INetURLObject("data:,"); CPPUNIT_ASSERT(!url.HasError()); @@ -263,7 +263,7 @@ namespace tools_urlobj url = INetURLObject("data:base64,"); //TODO: CPPUNIT_ASSERT(url.HasError()); strm = url.getData(); - CPPUNIT_ASSERT(strm == nullptr); + CPPUNIT_ASSERT(!strm); url = INetURLObject("data:;base64,"); CPPUNIT_ASSERT(!url.HasError()); @@ -294,12 +294,12 @@ namespace tools_urlobj url = INetURLObject("data:;base64,YWJjCg="); CPPUNIT_ASSERT(!url.HasError()); strm = url.getData(); - CPPUNIT_ASSERT(strm == nullptr); + CPPUNIT_ASSERT(!strm); url = INetURLObject("data:;base64,YWJ$Cg=="); CPPUNIT_ASSERT(!url.HasError()); strm = url.getData(); - CPPUNIT_ASSERT(strm == nullptr); + CPPUNIT_ASSERT(!strm); url = INetURLObject("data:text/plain;param=%22;base64,%22,YQ=="); CPPUNIT_ASSERT(!url.HasError()); @@ -316,7 +316,7 @@ namespace tools_urlobj url = INetURLObject("http://example.com"); CPPUNIT_ASSERT(!url.HasError()); strm = url.getData(); - CPPUNIT_ASSERT(strm == nullptr); + CPPUNIT_ASSERT(!strm); } void urlobjTest_isSchemeEqualTo() { |