diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2017-04-28 14:22:04 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2017-04-28 14:22:04 +0200 |
commit | 9384a34644fb1a6c791681c1bd7c4985f2437bea (patch) | |
tree | 1b28c931b6de892502921b2f0812e1204e771b5f /sal | |
parent | a46141f2e02fe50d21dd4f79df86bcdb90ba36c2 (diff) |
loplugin:cppunitassertequals: sal
Change-Id: I6ba9a18a1d227461e023259662635e3008ad7c9b
Diffstat (limited to 'sal')
-rw-r--r-- | sal/qa/OStringBuffer/rtl_OStringBuffer.cxx | 110 | ||||
-rw-r--r-- | sal/qa/osl/condition/osl_Condition.cxx | 44 | ||||
-rw-r--r-- | sal/qa/osl/file/osl_File.cxx | 298 | ||||
-rw-r--r-- | sal/qa/osl/file/test_cpy_wrt_file.cxx | 4 | ||||
-rw-r--r-- | sal/qa/osl/module/osl_Module.cxx | 22 | ||||
-rw-r--r-- | sal/qa/osl/mutex/osl_Mutex.cxx | 42 | ||||
-rw-r--r-- | sal/qa/osl/pipe/osl_Pipe.cxx | 43 | ||||
-rw-r--r-- | sal/qa/osl/process/osl_Thread.cxx | 170 | ||||
-rw-r--r-- | sal/qa/osl/security/osl_Security.cxx | 15 | ||||
-rw-r--r-- | sal/qa/rtl/uri/rtl_testuri.cxx | 268 |
10 files changed, 673 insertions, 343 deletions
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 ) ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for getFileStatus function: file not existed", + ::osl::FileBase::E_INVAL, nError2 ); } void getFileStatus_003() @@ -3865,8 +3925,9 @@ namespace osl_DirectoryItem ::osl::FileStatus rFileStatus( osl_FileStatus_Mask_FileName ); nError2 = rItem.getFileStatus( rFileStatus ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for getFileStatus function: get directory information", + ::osl::FileBase::E_None, nError2 ); CPPUNIT_ASSERT_MESSAGE( "test for getFileStatus function: get directory information", - ( ::osl::FileBase::E_None == nError2 ) && compareFileName( rFileStatus.getFileName(), aTmpName1 ) ); } @@ -3926,9 +3987,10 @@ namespace osl_Directory nError2 = testDirectory.close(); CPPUNIT_ASSERT_EQUAL( nError2, ::osl::FileBase::E_None ); - CPPUNIT_ASSERT_MESSAGE( "test for ctors function: create an instance and check open and close", - ( ::osl::FileBase::E_None == nError1 ) && - ( ::osl::FileBase::E_None == nError2 ) ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for ctors function: create an instance and check open and close", + ::osl::FileBase::E_None, nError1 ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for ctors function: create an instance and check open and close", + ::osl::FileBase::E_None, nError2 ); } void ctors_002() @@ -3942,9 +4004,10 @@ namespace osl_Directory nError2 = testDirectory.close(); CPPUNIT_ASSERT_EQUAL( nError2, ::osl::FileBase::E_None ); - CPPUNIT_ASSERT_MESSAGE( "test for ctors function: relative URL, :-), it is also worked", - ( ::osl::FileBase::E_None == nError1 ) && - ( ::osl::FileBase::E_None == nError2 ) ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for ctors function: relative URL, :-), it is also worked", + ::osl::FileBase::E_None, nError1 ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for ctors function: relative URL, :-), it is also worked", + ::osl::FileBase::E_None, nError2 ); } CPPUNIT_TEST_SUITE( ctors ); @@ -3990,9 +4053,11 @@ namespace osl_Directory nError2 = testDirectory.close(); CPPUNIT_ASSERT_MESSAGE( "test for open function: open a directory and check for open", - bOk && - ( ::osl::FileBase::E_None == nError1 ) && - ( ::osl::FileBase::E_None == nError2 ) ); + bOk ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for open function: open a directory and check for open", + ::osl::FileBase::E_None, nError1 ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for open function: open a directory and check for open", + ::osl::FileBase::E_None, nError2 ); } void open_002() @@ -4007,8 +4072,8 @@ namespace osl_Directory CPPUNIT_ASSERT_EQUAL( nError2, ::osl::FileBase::E_None ); } - CPPUNIT_ASSERT_MESSAGE( "test for open function: open a file that is not existed", - ( ::osl::FileBase::E_NOENT == nError1 ) ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for open function: open a file that is not existed", + ::osl::FileBase::E_NOENT, nError1 ); } void open_003() @@ -4023,8 +4088,8 @@ namespace osl_Directory CPPUNIT_ASSERT_EQUAL( nError2, ::osl::FileBase::E_None ); } - CPPUNIT_ASSERT_MESSAGE( "test for open function: using system path", - ( ::osl::FileBase::E_INVAL == nError1 ) ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for open function: using system path", + ::osl::FileBase::E_INVAL, nError1 ); } void open_004() @@ -4153,8 +4218,8 @@ namespace osl_Directory //close a directory nError1 = testDirectory.close(); - CPPUNIT_ASSERT_MESSAGE( "test for isOpen function: close a not opened directory", - ( ::osl::FileBase::E_BADF == nError1 ) ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for isOpen function: close a not opened directory", + ::osl::FileBase::E_BADF, nError1 ); } CPPUNIT_TEST_SUITE( close ); @@ -4231,8 +4296,9 @@ namespace osl_Directory bOK1 = compareFileName( rFileStatus.getFileName(), aTmpName2 ); bOK2 = compareFileName( rFileStatus.getFileName(), aHidURL1 ); bOK3 = compareFileName( rFileStatus.getFileName(), rFileStatusFirst.getFileName() ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for reset function: get two directory item, reset it, then get again, check the filename", + ::osl::FileBase::E_None, nError2 ); CPPUNIT_ASSERT_MESSAGE( "test for reset function: get two directory item, reset it, then get again, check the filename", - ( ::osl::FileBase::E_None == nError2 ) && ( bOK1 || bOK2 || bOK3 ) ); } @@ -4243,8 +4309,8 @@ namespace osl_Directory //close a directory nError1 = testDirectory.reset(); - CPPUNIT_ASSERT_MESSAGE( "test for reset function: reset a non existed directory", - ( ::osl::FileBase::E_NOENT == nError1 ) ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for reset function: reset a non existed directory", + ::osl::FileBase::E_NOENT, nError1 ); } void reset_003() @@ -4265,8 +4331,8 @@ namespace osl_Directory //close a directory nError1 = testDirectory.reset(); - CPPUNIT_ASSERT_MESSAGE( "test for reset function: use a system path", - ( ::osl::FileBase::E_INVAL == nError1 ) ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for reset function: use a system path", + ::osl::FileBase::E_INVAL, nError1 ); } CPPUNIT_TEST_SUITE( reset ); @@ -4354,7 +4420,11 @@ namespace osl_Directory CPPUNIT_ASSERT_EQUAL( nError1, ::osl::FileBase::E_None ); CPPUNIT_ASSERT_MESSAGE( "test for getNextItem function: retrieve three items and check their names.", - bOk1 && bOk2 && bOk3 ); + bOk1 ); + CPPUNIT_ASSERT_MESSAGE( "test for getNextItem function: retrieve three items and check their names.", + bOk2 ); + CPPUNIT_ASSERT_MESSAGE( "test for getNextItem function: retrieve three items and check their names.", + bOk3 ); } void getNextItem_002() @@ -4362,8 +4432,8 @@ namespace osl_Directory ::osl::Directory testDirectory( aTmpName3 ); //constructor nError1 = testDirectory.getNextItem( rItem ); - CPPUNIT_ASSERT_MESSAGE( "test for getNextItem function: retrieve an item in a directory which is not opened, also test for nHint's default value.", - ( ::osl::FileBase::E_INVAL == nError1 ) ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for getNextItem function: retrieve an item in a directory which is not opened, also test for nHint's default value.", + ::osl::FileBase::E_INVAL, nError1 ); } void getNextItem_003() @@ -4383,8 +4453,8 @@ namespace osl_Directory nError1 = testDirectory.close(); CPPUNIT_ASSERT_EQUAL( nError1, ::osl::FileBase::E_None ); - CPPUNIT_ASSERT_MESSAGE( "test for getNextItem function: retrieve 4 times in a directory which contain only 3 files.", - ( ::osl::FileBase::E_NOENT == nError2 ) ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for getNextItem function: retrieve 4 times in a directory which contain only 3 files.", + ::osl::FileBase::E_NOENT, nError2 ); } void getNextItem_004() @@ -4467,8 +4537,9 @@ namespace osl_Directory aFileSysName = _aVolumeInfo.getFileSystemName(); bool bRes2 = compareFileName( aFileSysName, aNullURL ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for getVolumeInfo function: getVolumeInfo of root directory.", + osl::FileBase::E_None, nError1 ); CPPUNIT_ASSERT_MESSAGE( "test for getVolumeInfo function: getVolumeInfo of root directory.", - ( osl::FileBase::E_None == nError1 ) && !bRes2 ); } if (_nMask == osl_VolumeInfo_Mask_Attributes) @@ -4591,8 +4662,8 @@ namespace osl_Directory nError1 = ::osl::Directory::getVolumeInfo( aRootSys, aVolumeInfo ); - CPPUNIT_ASSERT_MESSAGE( "test for getVolumeInfo function: use system path as parameter.", - ( osl::FileBase::E_INVAL == nError1 ) ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for getVolumeInfo function: use system path as parameter.", + osl::FileBase::E_INVAL, nError1 ); } void getVolumeInfo_003() @@ -4604,8 +4675,8 @@ namespace osl_Directory // LLA: in Windows, it reply no error, it did not pass in (W32). #if defined(UNX) && !defined(IOS) - CPPUNIT_ASSERT_MESSAGE( "test for getVolumeInfo function: non-existence test. ", - ( osl::FileBase::E_NOENT == nError1 ) ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for getVolumeInfo function: non-existence test. ", + osl::FileBase::E_NOENT, nError1 ); #endif } @@ -4643,9 +4714,10 @@ namespace osl_Directory //remove it deleteTestDirectory( aTmpName3 ); - CPPUNIT_ASSERT_MESSAGE( "test for create function: create a directory and check its existence.", - ( osl::FileBase::E_None == nError1 ) && - ( osl::FileBase::E_EXIST== nError2 ) ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for create function: create a directory and check its existence.", + osl::FileBase::E_None, nError1 ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for create function: create a directory and check its existence.", + osl::FileBase::E_EXIST, nError2 ); } void create_002() @@ -4690,8 +4762,8 @@ namespace osl_Directory //create directory in /tmpname nError1 = ::osl::Directory::create( aSysPath1 ); - CPPUNIT_ASSERT_MESSAGE( "test for create function: create a directory using system path.", - ( osl::FileBase::E_INVAL == nError1 ) ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for create function: create a directory using system path.", + osl::FileBase::E_INVAL, nError1 ); } CPPUNIT_TEST_SUITE( create ); @@ -4723,9 +4795,10 @@ namespace osl_Directory ::osl::Directory rDirectory( aTmpName3 ); nError2 = rDirectory.open(); - CPPUNIT_ASSERT_MESSAGE( "test for remove function: remove a directory and check its existence.", - ( osl::FileBase::E_None == nError1 ) && - ( osl::FileBase::E_NOENT == nError2 ) ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for remove function: remove a directory and check its existence.", + osl::FileBase::E_None, nError1 ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for remove function: remove a directory and check its existence.", + osl::FileBase::E_NOENT, nError2 ); } void remove_002() @@ -4741,8 +4814,8 @@ namespace osl_Directory if ( osl::FileBase::E_NOENT != nError2 ) ::osl::Directory::remove( aTmpName3 ); - CPPUNIT_ASSERT_MESSAGE( "test for remove function: remove a directory by its system path, and check its existence.", - ( osl::FileBase::E_INVAL == nError1 ) ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for remove function: remove a directory by its system path, and check its existence.", + osl::FileBase::E_INVAL, nError1 ); } void remove_003() @@ -4750,8 +4823,8 @@ namespace osl_Directory //try to remove a non-existed directory nError1 = ::osl::Directory::remove( aTmpName6 ); - CPPUNIT_ASSERT_MESSAGE( "test for remove function: try to remove a non-existed directory.", - ( osl::FileBase::E_NOENT == nError1 ) ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "test for remove function: try to remove a non-existed directory.", + osl::FileBase::E_NOENT, nError1 ); } void remove_004() @@ -4763,7 +4836,9 @@ namespace osl_Directory deleteTestFile( aTmpName6 ); CPPUNIT_ASSERT_MESSAGE( "test for remove function: try to remove a file but not directory.", - bExist &&(( osl::FileBase::E_NOTDIR == nError1 ) || ( osl::FileBase::E_NOENT == nError1 )) ); + bExist ); + CPPUNIT_ASSERT_MESSAGE( "test for remove function: try to remove a file but not directory.", + ( osl::FileBase::E_NOTDIR == nError1 ) || ( osl::FileBase::E_NOENT == nError1 ) ); } void remove_005() @@ -4781,7 +4856,7 @@ namespace osl_Directory printf("#Solaris test\n"); CPPUNIT_ASSERT_MESSAGE( sError.getStr(), ( osl::FileBase::E_EXIST == nError1 ) ); #else - CPPUNIT_ASSERT_MESSAGE( sError.getStr(), ( osl::FileBase::E_NOTEMPTY == nError1 ) ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( sError.getStr(), osl::FileBase::E_NOTEMPTY, nError1 ); #endif } @@ -4946,10 +5021,15 @@ namespace osl_Directory rm_test_path(tp_url); + CPPUNIT_ASSERT_EQUAL_MESSAGE + ( + "osl_createDirectoryPath failed", + FileBase::E_None, rc + ); CPPUNIT_ASSERT_MESSAGE ( "osl_createDirectoryPath failed", - (rc == FileBase::E_None) && (nDirs > 0) + nDirs > 0 ); } diff --git a/sal/qa/osl/file/test_cpy_wrt_file.cxx b/sal/qa/osl/file/test_cpy_wrt_file.cxx index 1d4fac1ca2e2..a4c1ba44b0f6 100644 --- a/sal/qa/osl/file/test_cpy_wrt_file.cxx +++ b/sal/qa/osl/file/test_cpy_wrt_file.cxx @@ -52,7 +52,9 @@ public: sal_uInt64 written = 0; err = tmp_file.write(static_cast<void*>(buffer), sizeof(buffer), written); CPPUNIT_ASSERT_MESSAGE("write on unconnected file should fail", - err != osl::FileBase::E_None && written == 0); + err != osl::FileBase::E_None); + CPPUNIT_ASSERT_EQUAL_MESSAGE("write on unconnected file should fail", + sal_uInt64(0), written); err = tmp_file.sync(); CPPUNIT_ASSERT_MESSAGE("sync on unconnected file should fail", err != FileBase::E_None); diff --git a/sal/qa/osl/module/osl_Module.cxx b/sal/qa/osl/module/osl_Module.cxx index 8f9a2f29fe26..ab2a47fa360d 100644 --- a/sal/qa/osl/module/osl_Module.cxx +++ b/sal/qa/osl/module/osl_Module.cxx @@ -125,7 +125,9 @@ namespace osl_Module } CPPUNIT_ASSERT_MESSAGE( "#test comment#: test get Module URL from address.", - bRes && 0 < aFileURL.lastIndexOf('/') ); + bRes ); + CPPUNIT_ASSERT_MESSAGE( "#test comment#: test get Module URL from address.", + 0 < aFileURL.lastIndexOf('/') ); } void getUrlFromAddress_002( ) @@ -145,7 +147,11 @@ namespace osl_Module aMod.unload( ); CPPUNIT_ASSERT_MESSAGE( "#test comment#: load an external library, get its function address and get its URL.", - bRes && 0 < aFileURL.lastIndexOf('/') && aFileURL.equalsIgnoreAsciiCase( getDllURL( ) ) ); + bRes ); + CPPUNIT_ASSERT_MESSAGE( "#test comment#: load an external library, get its function address and get its URL.", + 0 < aFileURL.lastIndexOf('/') ); + CPPUNIT_ASSERT_MESSAGE( "#test comment#: load an external library, get its function address and get its URL.", + aFileURL.equalsIgnoreAsciiCase( getDllURL( ) ) ); #endif } @@ -236,7 +242,9 @@ namespace osl_Module aMod.unload( ); CPPUNIT_ASSERT_MESSAGE( "#test comment#: test if a module is a loaded module.", - !bRes && bRes1 ); + !bRes ); + CPPUNIT_ASSERT_MESSAGE( "#test comment#: test if a module is a loaded module.", + bRes1 ); } CPPUNIT_TEST_SUITE( is ); CPPUNIT_TEST( is_001 ); @@ -293,7 +301,9 @@ namespace osl_Module aMod.unload( ); CPPUNIT_ASSERT_MESSAGE( "#test comment#: the m_Module of a Module instance will be NULL when is not loaded, it will not be NULL after loaded.", - bRes && bRes1 ); + bRes ); + CPPUNIT_ASSERT_MESSAGE( "#test comment#: the m_Module of a Module instance will be NULL when is not loaded, it will not be NULL after loaded.", + bRes1 ); #endif } @@ -340,7 +350,9 @@ namespace osl_Module bRes = ::osl::Module::getUrlFromAddress( oslFunc, aLibraryURL); aMod.unload(); CPPUNIT_ASSERT_MESSAGE( "#test comment#: load a dll and get its function addr and get its URL.", - bRes && aLibraryURL.equalsIgnoreAsciiCase( getDllURL() ) ); + bRes ); + CPPUNIT_ASSERT_MESSAGE( "#test comment#: load a dll and get its function addr and get its URL.", + aLibraryURL.equalsIgnoreAsciiCase( getDllURL() ) ); #endif } diff --git a/sal/qa/osl/mutex/osl_Mutex.cxx b/sal/qa/osl/mutex/osl_Mutex.cxx index a016210952b3..476e285792c4 100644 --- a/sal/qa/osl/mutex/osl_Mutex.cxx +++ b/sal/qa/osl/mutex/osl_Mutex.cxx @@ -354,7 +354,9 @@ namespace osl_Mutex bool bRes2 = myThread.isRunning( ); myThread.join( ); - CPPUNIT_ASSERT_MESSAGE( "Mutex acquire", bRes && bRes1 && !bRes2 ); + CPPUNIT_ASSERT_MESSAGE( "Mutex acquire", bRes ); + CPPUNIT_ASSERT_MESSAGE( "Mutex acquire", bRes1 ); + CPPUNIT_ASSERT_MESSAGE( "Mutex acquire", !bRes2 ); } //in the same thread, acquire twice should success @@ -369,7 +371,9 @@ namespace osl_Mutex aMutex.release(); - CPPUNIT_ASSERT_MESSAGE("Mutex acquire", bRes && bRes1 && bRes2); + CPPUNIT_ASSERT_MESSAGE("Mutex acquire", bRes); + CPPUNIT_ASSERT_MESSAGE("Mutex acquire", bRes1); + CPPUNIT_ASSERT_MESSAGE("Mutex acquire", bRes2); } @@ -408,7 +412,8 @@ namespace osl_Mutex if (bRes2) aMutex.release(); - CPPUNIT_ASSERT_MESSAGE("Try to acquire Mutex", !bRes1 && bRes2); + CPPUNIT_ASSERT_MESSAGE("Try to acquire Mutex", !bRes1); + CPPUNIT_ASSERT_MESSAGE("Try to acquire Mutex", bRes2); } CPPUNIT_TEST_SUITE(tryToAcquire); @@ -444,7 +449,11 @@ namespace osl_Mutex aMutex.release( ); CPPUNIT_ASSERT_MESSAGE( "release Mutex: try to acquire before and after the mutex has been released", - !bRes1 && bRes2 && bRunning ); + !bRes1 ); + CPPUNIT_ASSERT_MESSAGE( "release Mutex: try to acquire before and after the mutex has been released", + bRes2 ); + CPPUNIT_ASSERT_MESSAGE( "release Mutex: try to acquire before and after the mutex has been released", + bRunning ); } @@ -482,7 +491,8 @@ namespace osl_Mutex // after release mutex, myThread stops blocking and will terminate immediately bool bRes2 = myThread.isRunning(); - CPPUNIT_ASSERT_MESSAGE("Global Mutex works", bRes1 && !bRes2); + CPPUNIT_ASSERT_MESSAGE("Global Mutex works", bRes1); + CPPUNIT_ASSERT_MESSAGE("Global Mutex works", !bRes2); } void getGlobalMutex_002( ) @@ -559,7 +569,11 @@ namespace osl_Guard bool bRes2 = aMutex.tryToAcquire(); CPPUNIT_ASSERT_MESSAGE("GuardThread constructor", - !bRes && bRes1 && bRes2); + !bRes); + CPPUNIT_ASSERT_MESSAGE("GuardThread constructor", + bRes1); + CPPUNIT_ASSERT_MESSAGE("GuardThread constructor", + bRes2); } void ctor_002( ) @@ -694,7 +708,9 @@ namespace osl_ClearableGuard myThread.join(); CPPUNIT_ASSERT_MESSAGE("ClearableGuard method: clear", - nSec < 7 && nSec > 1); + nSec < 7); + CPPUNIT_ASSERT_MESSAGE("ClearableGuard method: clear", + nSec > 1); } void clear_002( ) @@ -718,7 +734,9 @@ namespace osl_ClearableGuard bool bRes1 = myThread.isRunning( ); CPPUNIT_ASSERT_MESSAGE( "ClearableGuard method: clear, control the HoldThread's running status!", - bRes && !bRes1 ); + bRes ); + CPPUNIT_ASSERT_MESSAGE( "ClearableGuard method: clear, control the HoldThread's running status!", + !bRes1 ); } CPPUNIT_TEST_SUITE( clear ); @@ -819,7 +837,9 @@ namespace osl_ResettableGuard myThread.join( ); CPPUNIT_ASSERT_MESSAGE( "ResettableMutexGuard method: reset", - bRes && bRes1 ); + bRes ); + CPPUNIT_ASSERT_MESSAGE( "ResettableMutexGuard method: reset", + bRes1 ); } #ifdef LINUX @@ -837,7 +857,9 @@ namespace osl_ResettableGuard bool bRes1 = aMutex.release( ); CPPUNIT_ASSERT_MESSAGE( "ResettableMutexGuard method: reset, release after clear and reset, on Solaris, the mutex can be release without acquire, so it can not passed on (SOLARIS), but not the reason for reset_002", - !bRes && bRes1 ); + !bRes ); + CPPUNIT_ASSERT_MESSAGE( "ResettableMutexGuard method: reset, release after clear and reset, on Solaris, the mutex can be release without acquire, so it can not passed on (SOLARIS), but not the reason for reset_002", + bRes1 ); } #endif diff --git a/sal/qa/osl/pipe/osl_Pipe.cxx b/sal/qa/osl/pipe/osl_Pipe.cxx index ece2a1320a3c..2505918e14f9 100644 --- a/sal/qa/osl/pipe/osl_Pipe.cxx +++ b/sal/qa/osl/pipe/osl_Pipe.cxx @@ -205,7 +205,9 @@ namespace osl_Pipe bRes1 = aAcquirePipe1.is( ); CPPUNIT_ASSERT_MESSAGE( "#test comment#: test constructor with no acquire of handle.only validation test, do not know how to test no acquire.", - bRes && !bRes1 ); + bRes ); + CPPUNIT_ASSERT_MESSAGE( "#test comment#: test constructor with no acquire of handle.only validation test, do not know how to test no acquire.", + !bRes1 ); } CPPUNIT_TEST_SUITE( ctors ); @@ -287,7 +289,9 @@ namespace osl_Pipe aPipe.clear( ); CPPUNIT_ASSERT_MESSAGE( "#test comment#: test creation.", - bRes && !bRes1); + bRes); + CPPUNIT_ASSERT_MESSAGE( "#test comment#: test creation.", + !bRes1); } void create_named_security_002( ) @@ -299,7 +303,9 @@ namespace osl_Pipe aPipe.clear( ); CPPUNIT_ASSERT_MESSAGE( "#test comment#: test creation and open.", - bRes && bRes1); + bRes); + CPPUNIT_ASSERT_MESSAGE( "#test comment#: test creation and open.", + bRes1); } void create_named_001( ) @@ -310,7 +316,9 @@ namespace osl_Pipe aPipe.clear( ); CPPUNIT_ASSERT_MESSAGE( "#test comment#: test creation.", - bRes && !bRes1); + bRes); + CPPUNIT_ASSERT_MESSAGE( "#test comment#: test creation.", + !bRes1); } void create_named_002( ) @@ -321,7 +329,9 @@ namespace osl_Pipe aPipe.clear( ); CPPUNIT_ASSERT_MESSAGE( "#test comment#: test creation and open.", - bRes && bRes1); + bRes); + CPPUNIT_ASSERT_MESSAGE( "#test comment#: test creation and open.", + bRes1); } void create_named_003( ) @@ -387,7 +397,9 @@ namespace osl_Pipe aPipe1.close( ); CPPUNIT_ASSERT_MESSAGE( "#test comment#: test assign with reference.", - bRes && bRes1 ); + bRes ); + CPPUNIT_ASSERT_MESSAGE( "#test comment#: test assign with reference.", + bRes1 ); } void assign_handle( ) @@ -401,7 +413,9 @@ namespace osl_Pipe aPipe1.close( ); CPPUNIT_ASSERT_MESSAGE( "#test comment#: test assign with handle.", - bRes && bRes1 ); + bRes ); + CPPUNIT_ASSERT_MESSAGE( "#test comment#: test assign with handle.", + bRes1 ); } CPPUNIT_TEST_SUITE( assign ); @@ -449,7 +463,9 @@ namespace osl_Pipe aPipe2.close( ); CPPUNIT_ASSERT_MESSAGE( "#test comment#: test isEqual(),create one copy instance, and compare.", - bRes && !bRes1 ); + bRes ); + CPPUNIT_ASSERT_MESSAGE( "#test comment#: test isEqual(),create one copy instance, and compare.", + !bRes1 ); } CPPUNIT_TEST_SUITE( isEqual ); @@ -476,7 +492,9 @@ namespace osl_Pipe bRes1 = aPipe.is( ); CPPUNIT_ASSERT_MESSAGE( "#test comment#: difference between close and clear.", - bRes && !bRes1); + bRes); + CPPUNIT_ASSERT_MESSAGE( "#test comment#: difference between close and clear.", + !bRes1); } void close_002( ) @@ -617,7 +635,9 @@ namespace osl_StreamPipe aStreamPipe1.clear( ); CPPUNIT_ASSERT_MESSAGE( "#test comment#: test constructor with no parameter, before and after assign.", - !bRes && bRes1 ); + !bRes ); + CPPUNIT_ASSERT_MESSAGE( "#test comment#: test constructor with no parameter, before and after assign.", + bRes1 ); } void ctors_handle( ) @@ -846,7 +866,8 @@ namespace osl_StreamPipe int nCompare1 = strcmp( myDataSinkThread.buf, m_pTestString1.getStr() ); int nCompare2 = strcmp( myDataSourceThread.buf, m_pTestString2.getStr() ); - CPPUNIT_ASSERT_MESSAGE( "test send/recv/write/read.", nCompare1 == 0 && nCompare2 == 0 ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "test send/recv/write/read.", 0, nCompare1 ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "test send/recv/write/read.", 0, nCompare2 ); } //close pipe when accept void recv_002() diff --git a/sal/qa/osl/process/osl_Thread.cxx b/sal/qa/osl/process/osl_Thread.cxx index ecb669c7b796..dc0434d23cb3 100644 --- a/sal/qa/osl/process/osl_Thread.cxx +++ b/sal/qa/osl/process/osl_Thread.cxx @@ -470,7 +470,11 @@ namespace osl_Thread CPPUNIT_ASSERT_MESSAGE( "Creates a new thread", - nValue >= 1 && isRunning + nValue >= 1 + ); + CPPUNIT_ASSERT_MESSAGE( + "Creates a new thread", + isRunning ); } @@ -488,7 +492,11 @@ namespace osl_Thread CPPUNIT_ASSERT_MESSAGE( "Creates a new thread: can not create two threads per instance", - res1 && !res2 + res1 + ); + CPPUNIT_ASSERT_MESSAGE( + "Creates a new thread: can not create two threads per instance", + !res2 ); } @@ -524,9 +532,13 @@ namespace osl_Thread termAndJoinThread(newthread); delete newthread; + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "Creates a new suspended thread", + sal_Int32(0), nValue + ); CPPUNIT_ASSERT_MESSAGE( "Creates a new suspended thread", - nValue == 0 && isRunning + isRunning ); } @@ -544,7 +556,11 @@ namespace osl_Thread CPPUNIT_ASSERT_MESSAGE( "Creates a new thread: can not create two threads per instance", - res1 && !res2 + res1 + ); + CPPUNIT_ASSERT_MESSAGE( + "Creates a new thread: can not create two threads per instance", + !res2 ); } @@ -604,7 +620,11 @@ namespace osl_Thread CPPUNIT_ASSERT_MESSAGE( "Suspend the thread", - bRes && nValue == nLaterValue + bRes + ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "Suspend the thread", + nValue, nLaterValue ); } @@ -656,8 +676,14 @@ namespace osl_Thread /* LLA: this assumption is no longer relevant: nResumeValue == nSuspendValue && */ CPPUNIT_ASSERT_MESSAGE( "Suspend then resume the thread", - nLaterValue >= 9 && - nResumeValue > nSuspendValue && + nLaterValue >= 9 + ); + CPPUNIT_ASSERT_MESSAGE( + "Suspend then resume the thread", + nResumeValue > nSuspendValue + ); + CPPUNIT_ASSERT_MESSAGE( + "Suspend then resume the thread", nLaterValue > nResumeValue ); @@ -724,7 +750,11 @@ namespace osl_Thread CPPUNIT_ASSERT_MESSAGE( "Terminate the thread", - !isRunning && nLaterValue >= nValue + !isRunning + ); + CPPUNIT_ASSERT_MESSAGE( + "Terminate the thread", + nLaterValue >= nValue ); } /** Check if a suspended thread will terminate after call terminate, different on w32 and on UNX @@ -865,7 +895,11 @@ namespace osl_Thread CPPUNIT_ASSERT_MESSAGE( "Test isRunning", - bRun && !bTer + bRun + ); + CPPUNIT_ASSERT_MESSAGE( + "Test isRunning", + !bTer ); } /** check the value of isRunning when suspending and after resume @@ -891,7 +925,13 @@ namespace osl_Thread CPPUNIT_ASSERT_MESSAGE( "Test isRunning", - bRes && bRunning_sup && bRunning_res && !bRunning_ter ); + bRes && bRunning_sup ); + CPPUNIT_ASSERT_MESSAGE( + "Test isRunning", + bRunning_res ); + CPPUNIT_ASSERT_MESSAGE( + "Test isRunning", + !bRunning_ter ); } @@ -1078,8 +1118,14 @@ namespace osl_Thread #ifndef _WIN32 CPPUNIT_ASSERT_MESSAGE( "SetPriority", - nValueHighest > 0 && - nValueAboveNormal > 0 && + nValueHighest > 0 + ); + CPPUNIT_ASSERT_MESSAGE( + "SetPriority", + nValueAboveNormal > 0 + ); + CPPUNIT_ASSERT_MESSAGE( + "SetPriority", nValueNormal > 0 ); #endif @@ -1157,8 +1203,14 @@ namespace osl_Thread "SetPriority", nValueHighest > 0 && nValueAboveNormal > 0 && - nValueNormal > 0 && - nValueBelowNormal > 0 && + nValueNormal > 0 + ); + CPPUNIT_ASSERT_MESSAGE( + "SetPriority", + nValueBelowNormal > 0 + ); + CPPUNIT_ASSERT_MESSAGE( + "SetPriority", nValueLowest > 0 ); #endif @@ -1237,8 +1289,14 @@ namespace osl_Thread "SetPriority", /* nValueHighest > 0 && */ nValueAboveNormal > 0 && - nValueNormal > 0 && - nValueBelowNormal > 0 && + nValueNormal > 0 + ); + CPPUNIT_ASSERT_MESSAGE( + "SetPriority", + nValueBelowNormal > 0 + ); + CPPUNIT_ASSERT_MESSAGE( + "SetPriority", nValueLowest > 0 ); #endif @@ -1313,8 +1371,14 @@ namespace osl_Thread "SetPriority", /* nValueHighest > 0 && */ /* nValueAboveNormal > 0 && */ - nValueNormal > 0 && - nValueBelowNormal > 0 && + nValueNormal > 0 + ); + CPPUNIT_ASSERT_MESSAGE( + "SetPriority", + nValueBelowNormal > 0 + ); + CPPUNIT_ASSERT_MESSAGE( + "SetPriority", nValueLowest > 0 ); #endif @@ -1357,9 +1421,9 @@ namespace osl_Thread // LLA: Priority settings may not work within some OS versions. #if defined(_WIN32) || defined(__sun) - CPPUNIT_ASSERT_MESSAGE( + CPPUNIT_ASSERT_EQUAL_MESSAGE( "getPriority", - aPriority == osl_Thread_PriorityHighest + osl_Thread_PriorityHighest, aPriority ); #else // LLA: Linux @@ -1464,7 +1528,11 @@ namespace osl_Thread CPPUNIT_ASSERT_MESSAGE( "Wait: Blocks the calling thread for the given number of time.", - nTenthSec >= 5 && nValue == 1 + nTenthSec >= 5 + ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "Wait: Blocks the calling thread for the given number of time.", + sal_Int32(1), nValue ); } @@ -1544,7 +1612,11 @@ namespace osl_Thread //check if thread really terminate after call terminate, if join immediately return CPPUNIT_ASSERT_MESSAGE( "Schedule: Returns False if the thread should terminate.", - nValue_join - nValue_term <= 1 && nValue_join - nValue_term >= 0 + nValue_join - nValue_term <= 1 + ); + CPPUNIT_ASSERT_MESSAGE( + "Schedule: Returns False if the thread should terminate.", + nValue_join - nValue_term >= 0 ); } @@ -1572,9 +1644,9 @@ namespace osl_Thread //On windows, suspend works, so the values are same #ifdef _WIN32 - CPPUNIT_ASSERT_MESSAGE( + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Schedule: don't schedule in thread run method, suspend works.", - nLaterValue == nValue + nValue, nLaterValue ); #endif @@ -1732,9 +1804,13 @@ namespace osl_ThreadData oslThreadIdentifier aThreadId1 = aThread1.getIdentifier(); oslThreadIdentifier aThreadId2 = aThread2.getIdentifier(); - CPPUNIT_ASSERT_MESSAGE( + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "ThreadData setData: ", + aThread1.m_Id, aThreadId1 + ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "ThreadData setData: ", - aThread1.m_Id == aThreadId1 && aThread2.m_Id == aThreadId2 + aThread2.m_Id, aThreadId2 ); } @@ -1764,9 +1840,17 @@ namespace osl_ThreadData char cData1 = aThread1.m_Char_Test; char cData2 = aThread2.m_Char_Test; - CPPUNIT_ASSERT_MESSAGE( + CPPUNIT_ASSERT_EQUAL_MESSAGE( "ThreadData setData: ", - cData1 == 'a' && cData2 == 'b' && aChar == 'm' + 'a', cData1 + ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "ThreadData setData: ", + 'b', cData2 + ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "ThreadData setData: ", + 'm', aChar ); } @@ -1803,9 +1887,17 @@ namespace osl_ThreadData char cData1 = aThread1.m_Char_Test; char cData2 = aThread2.m_Char_Test; - CPPUNIT_ASSERT_MESSAGE( + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "ThreadData setData: ", + 'a', cData1 + ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "ThreadData setData: ", - cData1 == 'a' && cData2 == 'b' && aChar == 'o' + 'b', cData2 + ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "ThreadData setData: ", + 'o', aChar ); } @@ -1841,9 +1933,17 @@ namespace osl_ThreadData char* pChar = static_cast<char*>(myThreadData.getData()); char aChar = *pChar; - CPPUNIT_ASSERT_MESSAGE( + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "ThreadData setData: ", + 'c', cData1 + ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "ThreadData setData: ", - cData1 == 'c' && cData2 == 'd' && aChar == 'i' + 'd', cData2 + ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "ThreadData setData: ", + 'i', aChar ); } @@ -1879,7 +1979,11 @@ namespace osl_ThreadData CPPUNIT_ASSERT_MESSAGE( "ThreadData setData: ", - cData1 == 'a' && cData2 == 'b' && aChar == 'j' + cData1 == 'a' && cData2 == 'b' + ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "ThreadData setData: ", + 'j', aChar ); } diff --git a/sal/qa/osl/security/osl_Security.cxx b/sal/qa/osl/security/osl_Security.cxx index 05ef80b62afc..4c699ab18d6e 100644 --- a/sal/qa/osl/security/osl_Security.cxx +++ b/sal/qa/osl/security/osl_Security.cxx @@ -133,7 +133,8 @@ namespace osl_Security aMessage.append(", bRes: "); aMessage.append(bRes); - CPPUNIT_ASSERT_MESSAGE( aMessage.getStr(), strUserID.equals(strID) && bRes ); + CPPUNIT_ASSERT_MESSAGE( aMessage.getStr(), strUserID.equals(strID) ); + CPPUNIT_ASSERT_MESSAGE( aMessage.getStr(), bRes ); } CPPUNIT_TEST_SUITE( getUserIdent ); @@ -165,7 +166,9 @@ namespace osl_Security nPos = strGetName.indexOf(strName); } CPPUNIT_ASSERT_MESSAGE( "#test comment#: get UserName and compare it with names got at the beginning of the test.", - ( nPos >= 0 ) && bRes ); + ( nPos >= 0 ) ); + CPPUNIT_ASSERT_MESSAGE( "#test comment#: get UserName and compare it with names got at the beginning of the test.", + bRes ); } CPPUNIT_TEST_SUITE( getUserName ); @@ -377,15 +380,15 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *, lRet = RegQueryValueEx(hRegKey, "AppData", nullptr, &Type, reinterpret_cast<unsigned char *>(PathA), &lSize); if ( ( lRet == ERROR_SUCCESS ) && ( Type == REG_SZ ) && ( _access( PathA, 0 ) == 0 ) ) { - CPPUNIT_ASSERT_MESSAGE( "#Convert from system path to URL failed.", - ::osl::File::E_None == ::osl::File::getFileURLFromSystemPath( ::rtl::OUString::createFromAscii( PathA ), strConfigDirectory ) ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "#Convert from system path to URL failed.", + ::osl::File::E_None, ::osl::File::getFileURLFromSystemPath( ::rtl::OUString::createFromAscii( PathA ), strConfigDirectory ) ); } lRet = RegQueryValueEx(hRegKey, "Personal", nullptr, &Type, reinterpret_cast<unsigned char *>(PathA), &lSize); if ( ( lRet == ERROR_SUCCESS ) && ( Type == REG_SZ ) && ( _access( PathA, 0 ) == 0 ) ) { - CPPUNIT_ASSERT_MESSAGE( "#Convert from system path to URL failed.", - ::osl::File::E_None == ::osl::File::getFileURLFromSystemPath( ::rtl::OUString::createFromAscii( PathA ), strHomeDirectory ) ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "#Convert from system path to URL failed.", + ::osl::File::E_None, ::osl::File::getFileURLFromSystemPath( ::rtl::OUString::createFromAscii( PathA ), strHomeDirectory ) ); } RegCloseKey(hRegKey); diff --git a/sal/qa/rtl/uri/rtl_testuri.cxx b/sal/qa/rtl/uri/rtl_testuri.cxx index e3ced41cddbe..05c3349d5bb8 100644 --- a/sal/qa/rtl/uri/rtl_testuri.cxx +++ b/sal/qa/rtl/uri/rtl_testuri.cxx @@ -73,54 +73,54 @@ void Test::test_Uri() { eCharClass <= eLastCharClass; eCharClass = static_cast< rtl_UriCharClass >(eCharClass + 1)) { - CPPUNIT_ASSERT_MESSAGE( + CPPUNIT_ASSERT_EQUAL_MESSAGE( "failure 1", - (rtl::Uri::decode( + aText2, + rtl::Uri::decode( rtl::Uri::encode( aText1, eCharClass, rtl_UriEncodeKeepEscapes, RTL_TEXTENCODING_ISO_8859_1), - rtl_UriDecodeWithCharset, RTL_TEXTENCODING_ASCII_US) - == aText2)); - CPPUNIT_ASSERT_MESSAGE( + rtl_UriDecodeWithCharset, RTL_TEXTENCODING_ASCII_US)); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "failure 2", - (rtl::Uri::decode( + aText2, + rtl::Uri::decode( rtl::Uri::encode( aText1, eCharClass, rtl_UriEncodeCheckEscapes, RTL_TEXTENCODING_ISO_8859_1), - rtl_UriDecodeWithCharset, RTL_TEXTENCODING_ASCII_US) - == aText2)); - CPPUNIT_ASSERT_MESSAGE( + rtl_UriDecodeWithCharset, RTL_TEXTENCODING_ASCII_US)); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "failure 3", - (rtl::Uri::decode( + aText2, + rtl::Uri::decode( rtl::Uri::encode( aText1, eCharClass, rtl_UriEncodeKeepEscapes, RTL_TEXTENCODING_ISO_8859_1), - rtl_UriDecodeWithCharset, RTL_TEXTENCODING_ISO_8859_1) - == aText2)); - CPPUNIT_ASSERT_MESSAGE( + rtl_UriDecodeWithCharset, RTL_TEXTENCODING_ISO_8859_1)); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "failure 4", - (rtl::Uri::decode( + aText2, + rtl::Uri::decode( rtl::Uri::encode( aText1, eCharClass, rtl_UriEncodeCheckEscapes, RTL_TEXTENCODING_ISO_8859_1), - rtl_UriDecodeWithCharset, RTL_TEXTENCODING_ISO_8859_1) - == aText2)); - CPPUNIT_ASSERT_MESSAGE( + rtl_UriDecodeWithCharset, RTL_TEXTENCODING_ISO_8859_1)); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "failure 5", - (rtl::Uri::decode( + aText2, + rtl::Uri::decode( rtl::Uri::encode( aText1, eCharClass, rtl_UriEncodeKeepEscapes, RTL_TEXTENCODING_ISO_8859_1), - rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8) - == aText2)); - CPPUNIT_ASSERT_MESSAGE( + rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8)); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "failure 6", - (rtl::Uri::decode( + aText2, + rtl::Uri::decode( rtl::Uri::encode( aText1, eCharClass, rtl_UriEncodeCheckEscapes, RTL_TEXTENCODING_ISO_8859_1), - rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8) - == aText2)); + rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8)); } aText1 = rtl::OUString( @@ -146,38 +146,38 @@ void Test::test_Uri() { eCharClass <= eLastCharClass; eCharClass = static_cast< rtl_UriCharClass >(eCharClass + 1)) { - CPPUNIT_ASSERT_MESSAGE( + CPPUNIT_ASSERT_EQUAL_MESSAGE( "failure 7", - (rtl::Uri::decode( + aText2, + rtl::Uri::decode( rtl::Uri::encode( aText1, eCharClass, rtl_UriEncodeKeepEscapes, RTL_TEXTENCODING_ISO_8859_1), - rtl_UriDecodeWithCharset, RTL_TEXTENCODING_ISO_8859_1) - == aText2)); - CPPUNIT_ASSERT_MESSAGE( + rtl_UriDecodeWithCharset, RTL_TEXTENCODING_ISO_8859_1)); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "failure 8", - (rtl::Uri::decode( + aText2, + rtl::Uri::decode( rtl::Uri::encode( aText1, eCharClass, rtl_UriEncodeCheckEscapes, RTL_TEXTENCODING_ISO_8859_1), - rtl_UriDecodeWithCharset, RTL_TEXTENCODING_ISO_8859_1) - == aText2)); - CPPUNIT_ASSERT_MESSAGE( + rtl_UriDecodeWithCharset, RTL_TEXTENCODING_ISO_8859_1)); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "failure 9", - (rtl::Uri::decode( + aText2, + rtl::Uri::decode( rtl::Uri::encode( aText1, eCharClass, rtl_UriEncodeKeepEscapes, RTL_TEXTENCODING_UTF8), - rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8) - == aText2)); - CPPUNIT_ASSERT_MESSAGE( + rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8)); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "failure 10", - (rtl::Uri::decode( + aText2, + rtl::Uri::decode( rtl::Uri::encode( aText1, eCharClass, rtl_UriEncodeCheckEscapes, RTL_TEXTENCODING_UTF8), - rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8) - == aText2)); + rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8)); } // Check surrogate handling: @@ -189,24 +189,24 @@ void Test::test_Uri() { aBuffer.append('A'); // A aText1 = aBuffer.makeStringAndClear(); aText2 = "%ED%A0%80" "%F0%90%8F%BF" "%ED%BF%BF" "A"; - CPPUNIT_ASSERT_MESSAGE( + CPPUNIT_ASSERT_EQUAL_MESSAGE( "failure 11", - (rtl::Uri::encode( + aText2, + rtl::Uri::encode( aText1, rtl_UriCharClassUric, rtl_UriEncodeIgnoreEscapes, - RTL_TEXTENCODING_UTF8) - == aText2)); - CPPUNIT_ASSERT_MESSAGE( + RTL_TEXTENCODING_UTF8)); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "failure 12", - (rtl::Uri::encode( + aText2, + rtl::Uri::encode( aText1, rtl_UriCharClassUric, rtl_UriEncodeKeepEscapes, - RTL_TEXTENCODING_UTF8) - == aText2)); - CPPUNIT_ASSERT_MESSAGE( + RTL_TEXTENCODING_UTF8)); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "failure 13", - (rtl::Uri::encode( + aText2, + rtl::Uri::encode( aText1, rtl_UriCharClassUric, rtl_UriEncodeCheckEscapes, - RTL_TEXTENCODING_UTF8) - == aText2)); + RTL_TEXTENCODING_UTF8)); aText1 = "%ed%a0%80" "%f0%90%8f%bf" "%ed%bf%bf" "A"; aBuffer.append("%ED%A0%80"); @@ -215,37 +215,37 @@ void Test::test_Uri() { aBuffer.append("%ED%BF%BF"); aBuffer.append('A'); aText2 = aBuffer.makeStringAndClear(); - CPPUNIT_ASSERT_MESSAGE( + CPPUNIT_ASSERT_EQUAL_MESSAGE( "failure 14", - (rtl::Uri::decode(aText1, rtl_UriDecodeToIuri, RTL_TEXTENCODING_UTF8) - == aText2)); - CPPUNIT_ASSERT_MESSAGE( + aText2, + rtl::Uri::decode(aText1, rtl_UriDecodeToIuri, RTL_TEXTENCODING_UTF8)); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "failure 15", - (rtl::Uri::decode( - aText1, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8) - == aText2)); + aText2, + rtl::Uri::decode( + aText1, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8)); // Check UTF-8 handling: aText1 = "%E0%83%BF"; // \U+00FF encoded with three instead of two bytes aText2 = aText1; - CPPUNIT_ASSERT_MESSAGE( + CPPUNIT_ASSERT_EQUAL_MESSAGE( "failure 16", - (rtl::Uri::encode( + aText2, + rtl::Uri::encode( aText1, rtl_UriCharClassUric, rtl_UriEncodeCheckEscapes, - RTL_TEXTENCODING_UTF8) - == aText2)); + RTL_TEXTENCODING_UTF8)); aText1 = "%EF%BF%BF"; // \U+FFFF is no legal character aText2 = aText1; - CPPUNIT_ASSERT_MESSAGE( + CPPUNIT_ASSERT_EQUAL_MESSAGE( "failure 17", - (rtl::Uri::encode( + aText2, + rtl::Uri::encode( aText1, rtl_UriCharClassUric, rtl_UriEncodeCheckEscapes, - RTL_TEXTENCODING_UTF8) - == aText2)); + RTL_TEXTENCODING_UTF8)); // Check IURI handling: @@ -253,21 +253,21 @@ void Test::test_Uri() { aBuffer.append("%30"); aBuffer.append(static_cast< sal_Unicode >(0x00FF)); aText2 = aBuffer.makeStringAndClear(); - CPPUNIT_ASSERT_MESSAGE( + CPPUNIT_ASSERT_EQUAL_MESSAGE( "failure 18", - (rtl::Uri::decode(aText1, rtl_UriDecodeToIuri, RTL_TEXTENCODING_UTF8) - == aText2)); + aText2, + rtl::Uri::decode(aText1, rtl_UriDecodeToIuri, RTL_TEXTENCODING_UTF8)); // Check modified rtl_UriCharClassUnoParamValue (removed '[' and ']'): aText1 = "[]%5B%5D"; aText2 = "%5B%5D%5B%5D"; - CPPUNIT_ASSERT_MESSAGE( + CPPUNIT_ASSERT_EQUAL_MESSAGE( "failure 19", - (rtl::Uri::encode( + aText2, + rtl::Uri::encode( aText1, rtl_UriCharClassUnoParamValue, rtl_UriEncodeCheckEscapes, - RTL_TEXTENCODING_ASCII_US) - == aText2)); + RTL_TEXTENCODING_ASCII_US)); // Check Uri::convertRelToAbs: @@ -370,17 +370,17 @@ void Test::test_Uri() { sal_Unicode const aText1U[] = { ' ', '!', 0x0401, 0x045F, 0 }; aText1 = rtl::OUString(aText1U); aText2 = "%20!%A1%FF"; - CPPUNIT_ASSERT_MESSAGE( + CPPUNIT_ASSERT_EQUAL_MESSAGE( "failure 20", - (rtl::Uri::encode( + aText2, + rtl::Uri::encode( aText1, rtl_UriCharClassUric, rtl_UriEncodeIgnoreEscapes, - RTL_TEXTENCODING_ISO_8859_5) - == aText2)); - CPPUNIT_ASSERT_MESSAGE( + RTL_TEXTENCODING_ISO_8859_5)); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "failure 20a", - (rtl::Uri::decode( - aText2, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_ISO_8859_5) - == aText1)); + aText1, + rtl::Uri::decode( + aText2, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_ISO_8859_5)); } { sal_Unicode const aText1U[] = { ' ', '!', 0x0401, 0x0700, 0x045F, 0 }; @@ -388,34 +388,34 @@ void Test::test_Uri() { sal_Unicode const aText2U[] = { '%', '2', '0', '!', '%', 'A', '1', 0x0700, '%', 'F', 'F', 0 }; aText2 = rtl::OUString(aText2U); - CPPUNIT_ASSERT_MESSAGE( + CPPUNIT_ASSERT_EQUAL_MESSAGE( "failure 21", - (rtl::Uri::encode( + aText2, + rtl::Uri::encode( aText1, rtl_UriCharClassUric, rtl_UriEncodeIgnoreEscapes, - RTL_TEXTENCODING_ISO_8859_5) - == aText2)); - CPPUNIT_ASSERT_MESSAGE( + RTL_TEXTENCODING_ISO_8859_5)); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "failure 21a", - (rtl::Uri::decode( - aText2, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_ISO_8859_5) - == aText1)); + aText1, + rtl::Uri::decode( + aText2, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_ISO_8859_5)); } #if WITH_LOCALE_ALL || WITH_LOCALE_zh { sal_Unicode const aText1U[] = { ' ', '!', 0x028A, 0xD849, 0xDD13, 0 }; aText1 = rtl::OUString(aText1U); aText2 = "%20!%81%30%B1%33%95%39%C5%37"; - CPPUNIT_ASSERT_MESSAGE( + CPPUNIT_ASSERT_EQUAL_MESSAGE( "failure 22", - (rtl::Uri::encode( + aText2, + rtl::Uri::encode( aText1, rtl_UriCharClassUric, rtl_UriEncodeIgnoreEscapes, - RTL_TEXTENCODING_GB_18030) - == aText2)); - CPPUNIT_ASSERT_MESSAGE( + RTL_TEXTENCODING_GB_18030)); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "failure 22a", - (rtl::Uri::decode( - aText2, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_GB_18030) - == aText1)); + aText1, + rtl::Uri::decode( + aText2, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_GB_18030)); } #endif // Check strict mode: @@ -424,60 +424,60 @@ void Test::test_Uri() { sal_Unicode const aText1U[] = { ' ', '!', 0x0401, 0x0700, 0x045F, 0 }; aText1 = rtl::OUString(aText1U); aText2 = rtl::OUString(); - CPPUNIT_ASSERT_MESSAGE( + CPPUNIT_ASSERT_EQUAL_MESSAGE( "failure 23", - (rtl::Uri::encode( + aText2, + rtl::Uri::encode( aText1, rtl_UriCharClassUric, rtl_UriEncodeStrict, - RTL_TEXTENCODING_ISO_8859_5) - == aText2)); + RTL_TEXTENCODING_ISO_8859_5)); } { aText1 = "%20%C4%80%FF"; aText2 = rtl::OUString(); - CPPUNIT_ASSERT_MESSAGE( + CPPUNIT_ASSERT_EQUAL_MESSAGE( "failure 24", - (rtl::Uri::decode( - aText1, rtl_UriDecodeStrict, RTL_TEXTENCODING_UTF8) - == aText2)); + aText2, + rtl::Uri::decode( + aText1, rtl_UriDecodeStrict, RTL_TEXTENCODING_UTF8)); } #if WITH_LOCALE_ALL || WITH_LOCALE_zh { aText1 = "%81 "; aText2 = rtl::OUString(); - CPPUNIT_ASSERT_MESSAGE( + CPPUNIT_ASSERT_EQUAL_MESSAGE( "failure 25", - (rtl::Uri::decode( - aText1, rtl_UriDecodeStrict, RTL_TEXTENCODING_GB_18030) - == aText2)); + aText2, + rtl::Uri::decode( + aText1, rtl_UriDecodeStrict, RTL_TEXTENCODING_GB_18030)); } { aText1 = "%81%20"; aText2 = rtl::OUString(); - CPPUNIT_ASSERT_MESSAGE( + CPPUNIT_ASSERT_EQUAL_MESSAGE( "failure 26", - (rtl::Uri::decode( - aText1, rtl_UriDecodeStrict, RTL_TEXTENCODING_GB_18030) - == aText2)); + aText2, + rtl::Uri::decode( + aText1, rtl_UriDecodeStrict, RTL_TEXTENCODING_GB_18030)); } { aText1 = "%81%30%B1%33"; sal_Unicode const aText2U[] = { 0x028A, 0 }; aText2 = rtl::OUString(aText2U); - CPPUNIT_ASSERT_MESSAGE( + CPPUNIT_ASSERT_EQUAL_MESSAGE( "failure 27", - (rtl::Uri::decode( - aText1, rtl_UriDecodeStrict, RTL_TEXTENCODING_GB_18030) - == aText2)); + aText2, + rtl::Uri::decode( + aText1, rtl_UriDecodeStrict, RTL_TEXTENCODING_GB_18030)); } { aText1 = "%810%B13"; sal_Unicode const aText2U[] = { 0x028A, 0 }; aText2 = rtl::OUString(aText2U); - CPPUNIT_ASSERT_MESSAGE( + CPPUNIT_ASSERT_EQUAL_MESSAGE( "failure 28", - (rtl::Uri::decode( - aText1, rtl_UriDecodeStrict, RTL_TEXTENCODING_GB_18030) - == aText2)); + aText2, + rtl::Uri::decode( + aText1, rtl_UriDecodeStrict, RTL_TEXTENCODING_GB_18030)); } #endif // Check rtl_UriEncodeStrictKeepEscapes mode: @@ -485,34 +485,34 @@ void Test::test_Uri() { { aText1 = "%%ea%c3%aa"; aText2 = "%25%EA%C3%AA"; - CPPUNIT_ASSERT_MESSAGE( + CPPUNIT_ASSERT_EQUAL_MESSAGE( "failure 29", - (rtl::Uri::encode( + aText2, + rtl::Uri::encode( aText1, rtl_UriCharClassUric, rtl_UriEncodeStrictKeepEscapes, - RTL_TEXTENCODING_UTF8) - == aText2)); + RTL_TEXTENCODING_UTF8)); } { sal_Unicode const aText1U[] = { 0x00EA, 0 }; aText1 = rtl::OUString(aText1U); aText2 = "%C3%AA"; - CPPUNIT_ASSERT_MESSAGE( + CPPUNIT_ASSERT_EQUAL_MESSAGE( "failure 30", - (rtl::Uri::encode( + aText2, + rtl::Uri::encode( aText1, rtl_UriCharClassUric, rtl_UriEncodeStrictKeepEscapes, - RTL_TEXTENCODING_UTF8) - == aText2)); + RTL_TEXTENCODING_UTF8)); } { sal_Unicode const aText1U[] = { ' ', '!', 0x0401, 0x0700, 0x045F, 0 }; aText1 = rtl::OUString(aText1U); aText2 = rtl::OUString(); - CPPUNIT_ASSERT_MESSAGE( + CPPUNIT_ASSERT_EQUAL_MESSAGE( "failure 23", - (rtl::Uri::encode( + aText2, + rtl::Uri::encode( aText1, rtl_UriCharClassUric, rtl_UriEncodeStrictKeepEscapes, - RTL_TEXTENCODING_ISO_8859_5) - == aText2)); + RTL_TEXTENCODING_ISO_8859_5)); } } |