From 883844f21af50f2a395fddc6fe86fdced6832c14 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Fri, 4 Apr 2014 08:49:11 +0200 Subject: Remove dead test code Change-Id: Id03246fa9eefce718c36d73f84875f26d58caeba --- sal/CppunitTest_sal_rtl_ostringbuffer.mk | 1 - sal/qa/OStringBuffer/rtl_OStringBuffer.cxx | 319 ------ sal/qa/OStringBuffer/rtl_String_Const.h | 2 - sal/qa/OStringBuffer/rtl_String_Utils.cxx | 169 ---- sal/qa/OStringBuffer/rtl_String_Utils.hxx | 62 -- sal/qa/osl/condition/osl_Condition.cxx | 21 - sal/qa/osl/file/osl_File.cxx | 1486 ++++------------------------ sal/qa/osl/module/osl_Module.cxx | 96 -- sal/qa/osl/mutex/osl_Mutex.cxx | 23 +- sal/qa/osl/process/osl_Thread.cxx | 92 -- sal/qa/osl/process/osl_process.cxx | 257 ----- sal/qa/osl/security/osl_Security.cxx | 10 - sal/qa/rtl/oustring/rtl_OUString2.cxx | 60 +- sal/qa/rtl/uri/rtl_Uri.cxx | 159 --- sal/qa/rtl/uuid/rtl_Uuid.cxx | 31 - 15 files changed, 191 insertions(+), 2597 deletions(-) delete mode 100644 sal/qa/OStringBuffer/rtl_String_Utils.cxx delete mode 100644 sal/qa/OStringBuffer/rtl_String_Utils.hxx diff --git a/sal/CppunitTest_sal_rtl_ostringbuffer.mk b/sal/CppunitTest_sal_rtl_ostringbuffer.mk index 27946a6eb429..30d9466c50cc 100644 --- a/sal/CppunitTest_sal_rtl_ostringbuffer.mk +++ b/sal/CppunitTest_sal_rtl_ostringbuffer.mk @@ -12,7 +12,6 @@ $(eval $(call gb_CppunitTest_CppunitTest,sal_rtl_ostringbuffer)) $(eval $(call gb_CppunitTest_add_exception_objects,sal_rtl_ostringbuffer,\ sal/qa/OStringBuffer/rtl_OStringBuffer \ - sal/qa/OStringBuffer/rtl_String_Utils \ )) $(eval $(call gb_CppunitTest_use_libraries,sal_rtl_ostringbuffer,\ diff --git a/sal/qa/OStringBuffer/rtl_OStringBuffer.cxx b/sal/qa/OStringBuffer/rtl_OStringBuffer.cxx index 7491bcf3a292..d31488b716e9 100644 --- a/sal/qa/OStringBuffer/rtl_OStringBuffer.cxx +++ b/sal/qa/OStringBuffer/rtl_OStringBuffer.cxx @@ -20,7 +20,6 @@ #include #include #include -#include #include #include "cppunit/TestAssert.h" @@ -15112,165 +15111,6 @@ namespace rtl_OStringBuffer } - void append_026() - { - ::rtl::OStringBuffer aStrBuf( *arrOUS[3] ); - float input = (float)atof("3.141592"); - - sal_Int32 nLen = aStrBuf.getLength(); - aStrBuf.append( input ); - - CPPUNIT_ASSERT_MESSAGE - ( - "arrOUS[3] append 3.141592", - checkIfStrBufContainAtPosTheFloat(aStrBuf, nLen, input) - ); - - } - - void append_027() - { - ::rtl::OStringBuffer aStrBuf( *arrOUS[3] ); - float input = (float)atof("3.5025255"); - - sal_Int32 nLen = aStrBuf.getLength(); - aStrBuf.append( input ); - - CPPUNIT_ASSERT_MESSAGE - ( - "arrOUS[3] append 3.5025255", - checkIfStrBufContainAtPosTheFloat(aStrBuf, nLen, input) - ); - - } - - void append_028() - { - ::rtl::OStringBuffer aStrBuf( *arrOUS[3] ); - float input = (float)atof("3.00390625"); - - sal_Int32 nLen = aStrBuf.getLength(); - aStrBuf.append( input ); - - CPPUNIT_ASSERT_MESSAGE - ( - "arrOUS[3] append 3.0039062", - checkIfStrBufContainAtPosTheFloat(aStrBuf, nLen, input) - ); - - } - - void append_029() - { - ::rtl::OStringBuffer aStrBuf( *arrOUS[4] ); - float input = (float)atof("3.0"); - - sal_Int32 nLen = aStrBuf.getLength(); - aStrBuf.append( input ); - - CPPUNIT_ASSERT_MESSAGE - ( - "arrOUS[4] append 3.0", - checkIfStrBufContainAtPosTheFloat(aStrBuf, nLen, input) - ); - - } - - void append_030() - { - ::rtl::OStringBuffer aStrBuf( *arrOUS[4] ); - float input = (float)atof("3.5"); - - sal_Int32 nLen = aStrBuf.getLength(); - aStrBuf.append( input ); - - CPPUNIT_ASSERT_MESSAGE - ( - "arrOUS[4] append 3.5", - checkIfStrBufContainAtPosTheFloat(aStrBuf, nLen, input) - ); - - } - - void append_031() - { - ::rtl::OStringBuffer aStrBuf( *arrOUS[4] ); - float input = (float)atof("3.0625"); - - sal_Int32 nLen = aStrBuf.getLength(); - aStrBuf.append( input ); - - CPPUNIT_ASSERT_MESSAGE - ( - "arrOUS[4] append 3.0625", - checkIfStrBufContainAtPosTheFloat(aStrBuf, nLen, input) - ); - - } - - void append_032() - { - ::rtl::OStringBuffer aStrBuf( *arrOUS[4] ); - float input = (float)atof("3.502525"); - - sal_Int32 nLen = aStrBuf.getLength(); - aStrBuf.append( input ); - - CPPUNIT_ASSERT_MESSAGE - ( - "arrOUS[4] append 3.502525", - checkIfStrBufContainAtPosTheFloat(aStrBuf, nLen, input) - ); - - } - - void append_033() - { - ::rtl::OStringBuffer aStrBuf( *arrOUS[4] ); - float input = (float)atof("3.141592"); - - sal_Int32 nLen = aStrBuf.getLength(); - aStrBuf.append( input ); - - CPPUNIT_ASSERT_MESSAGE - ( - "arrOUS[4] append 3.141592", - checkIfStrBufContainAtPosTheFloat(aStrBuf, nLen, input) - ); - - } - - void append_034() - { - ::rtl::OStringBuffer aStrBuf( *arrOUS[4] ); - float input = (float)atof("3.5025255"); - - sal_Int32 nLen = aStrBuf.getLength(); - aStrBuf.append( input ); - - CPPUNIT_ASSERT_MESSAGE - ( - "arrOUS[4] append 3.5025255", - checkIfStrBufContainAtPosTheFloat(aStrBuf, nLen, input) - ); - - } - - void append_035() - { - ::rtl::OStringBuffer aStrBuf( *arrOUS[4] ); - float input = (float)atof("3.00390625"); - - sal_Int32 nLen = aStrBuf.getLength(); - aStrBuf.append( input ); - - CPPUNIT_ASSERT_MESSAGE - ( - "arrOUS[4] append 3.0039062", - checkIfStrBufContainAtPosTheFloat(aStrBuf, nLen, input) - ); - - } #ifdef WITH_CORE void append_036() { @@ -15844,165 +15684,6 @@ namespace rtl_OStringBuffer } - void append_026() - { - ::rtl::OStringBuffer aStrBuf( *arrOUS[3] ); - float input = (float)atof("-3.141592"); - - sal_Int32 nLen = aStrBuf.getLength(); - aStrBuf.append( input ); - - CPPUNIT_ASSERT_MESSAGE - ( - "arrOUS[3] append -3.141592", - checkIfStrBufContainAtPosTheFloat(aStrBuf, nLen, input) - ); - - } - - void append_027() - { - ::rtl::OStringBuffer aStrBuf( *arrOUS[3] ); - float input = (float)atof("-3.5025255"); - - sal_Int32 nLen = aStrBuf.getLength(); - aStrBuf.append( input ); - - CPPUNIT_ASSERT_MESSAGE - ( - "arrOUS[3] append -3.5025255", - checkIfStrBufContainAtPosTheFloat(aStrBuf, nLen, input) - ); - - } - - void append_028() - { - ::rtl::OStringBuffer aStrBuf( *arrOUS[3] ); - float input = (float)atof("-3.00390625"); - - sal_Int32 nLen = aStrBuf.getLength(); - aStrBuf.append( input ); - - CPPUNIT_ASSERT_MESSAGE - ( - "arrOUS[3] append -3.0039062", - checkIfStrBufContainAtPosTheFloat(aStrBuf, nLen, input) - ); - - } - - void append_029() - { - ::rtl::OStringBuffer aStrBuf( *arrOUS[4] ); - float input = (float)atof("-3.0"); - - sal_Int32 nLen = aStrBuf.getLength(); - aStrBuf.append( input ); - - CPPUNIT_ASSERT_MESSAGE - ( - "arrOUS[4] append -3.0", - checkIfStrBufContainAtPosTheFloat(aStrBuf, nLen, input) - ); - - } - - void append_030() - { - ::rtl::OStringBuffer aStrBuf( *arrOUS[4] ); - float input = (float)atof("-3.5"); - - sal_Int32 nLen = aStrBuf.getLength(); - aStrBuf.append( input ); - - CPPUNIT_ASSERT_MESSAGE - ( - "arrOUS[4] append -3.5", - checkIfStrBufContainAtPosTheFloat(aStrBuf, nLen, input) - ); - - } - - void append_031() - { - ::rtl::OStringBuffer aStrBuf( *arrOUS[4] ); - float input = (float)atof("-3.0625"); - - sal_Int32 nLen = aStrBuf.getLength(); - aStrBuf.append( input ); - - CPPUNIT_ASSERT_MESSAGE - ( - "arrOUS[4] append -3.0625", - checkIfStrBufContainAtPosTheFloat(aStrBuf, nLen, input) - ); - - } - - void append_032() - { - ::rtl::OStringBuffer aStrBuf( *arrOUS[4] ); - float input = (float)atof("-3.502525"); - - sal_Int32 nLen = aStrBuf.getLength(); - aStrBuf.append( input ); - - CPPUNIT_ASSERT_MESSAGE - ( - "arrOUS[4] append -3.502525", - checkIfStrBufContainAtPosTheFloat(aStrBuf, nLen, input) - ); - - } - - void append_033() - { - ::rtl::OStringBuffer aStrBuf( *arrOUS[4] ); - float input = (float)atof("-3.141592"); - - sal_Int32 nLen = aStrBuf.getLength(); - aStrBuf.append( input ); - - CPPUNIT_ASSERT_MESSAGE - ( - "arrOUS[4] append -3.141592", - checkIfStrBufContainAtPosTheFloat(aStrBuf, nLen, input) - ); - - } - - void append_034() - { - ::rtl::OStringBuffer aStrBuf( *arrOUS[4] ); - float input = (float)atof("-3.5025255"); - - sal_Int32 nLen = aStrBuf.getLength(); - aStrBuf.append( input ); - - CPPUNIT_ASSERT_MESSAGE - ( - "arrOUS[4] append -3.5025255", - checkIfStrBufContainAtPosTheFloat(aStrBuf, nLen, input) - ); - - } - - void append_035() - { - ::rtl::OStringBuffer aStrBuf( *arrOUS[4] ); - float input = (float)atof("-3.00390625"); - - sal_Int32 nLen = aStrBuf.getLength(); - aStrBuf.append( input ); - - CPPUNIT_ASSERT_MESSAGE - ( - "arrOUS[4] append -3.0039062", - checkIfStrBufContainAtPosTheFloat(aStrBuf, nLen, input) - ); - - } #ifdef WITH_CORE void append_036() { diff --git a/sal/qa/OStringBuffer/rtl_String_Const.h b/sal/qa/OStringBuffer/rtl_String_Const.h index c0c647eb757b..7cc383701954 100644 --- a/sal/qa/OStringBuffer/rtl_String_Const.h +++ b/sal/qa/OStringBuffer/rtl_String_Const.h @@ -20,8 +20,6 @@ #ifndef _RTL_STRING_CONST_H_ #define _RTL_STRING_CONST_H_ -#include - #include #include #include diff --git a/sal/qa/OStringBuffer/rtl_String_Utils.cxx b/sal/qa/OStringBuffer/rtl_String_Utils.cxx deleted file mode 100644 index 04404660cf3b..000000000000 --- a/sal/qa/OStringBuffer/rtl_String_Utils.cxx +++ /dev/null @@ -1,169 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include -#include - -#include - -#include -#include -#include - -using ::rtl::OString; -sal_uInt32 AStringLen( const sal_Char *pAStr ) -{ - sal_uInt32 nStrLen = 0; - - if ( pAStr != NULL ) - { - const sal_Char *pTempStr = pAStr; - - while( *pTempStr ) - { - pTempStr++; - } // while - - nStrLen = (sal_uInt32)( pTempStr - pAStr ); - } // if - - return nStrLen; -} // AStringLen - -sal_Char* cpystr( sal_Char* dst, const sal_Char* src ) -{ - const sal_Char* psrc = src; - sal_Char* pdst = dst; - - while( (*pdst++ = *psrc++) ) {} - - return dst; -} - -sal_Char* cpynstr( sal_Char* dst, const sal_Char* src, sal_uInt32 cnt ) -{ - - const sal_Char* psrc = src; - sal_Char* pdst = dst; - sal_uInt32 len = cnt; - sal_uInt32 i; - - if ( len >= AStringLen(src) ) - { - return( cpystr( dst, src ) ); - } - - // copy string by char - for( i = 0; i < len; i++ ) - *pdst++ = *psrc++; - *pdst = '\0'; - - return ( dst ); -} - -bool cmpstr( const sal_Char* str1, const sal_Char* str2, sal_uInt32 len ) -{ - const sal_Char* pBuf1 = str1; - const sal_Char* pBuf2 = str2; - sal_uInt32 i = 0; - - while ( (*pBuf1 == *pBuf2) && i < len ) - { - (pBuf1)++; - (pBuf2)++; - i++; - } - return( i == len ); -} - -bool cmpstr( const sal_Char* str1, const sal_Char* str2 ) -{ - const sal_Char* pBuf1 = str1; - const sal_Char* pBuf2 = str2; - bool res = true; - - while ( (*pBuf1 == *pBuf2) && *pBuf1 !='\0' && *pBuf2 != '\0') - { - (pBuf1)++; - (pBuf2)++; - } - if (*pBuf1 == '\0' && *pBuf2 == '\0') - res = true; - else - res = false; - return (res); -} - -bool cmpustr( const sal_Unicode* str1, const sal_Unicode* str2, sal_uInt32 len ) -{ - const sal_Unicode* pBuf1 = str1; - const sal_Unicode* pBuf2 = str2; - sal_uInt32 i = 0; - - while ( (*pBuf1 == *pBuf2) && i < len ) - { - (pBuf1)++; - (pBuf2)++; - i++; - } - return( i == len ); -} - -bool cmpustr( const sal_Unicode* str1, const sal_Unicode* str2 ) -{ - const sal_Unicode* pBuf1 = str1; - const sal_Unicode* pBuf2 = str2; - bool res = true; - - while ( (*pBuf1 == *pBuf2) && *pBuf1 !='\0' && *pBuf2 != '\0') - { - (pBuf1)++; - (pBuf2)++; - } - if (*pBuf1 == '\0' && *pBuf2 == '\0') - res = true; - else - res = false; - return (res); -} - -sal_Char* createName( sal_Char* dst, const sal_Char* meth, sal_uInt32 cnt ) -{ - sal_Char* pdst = dst; - sal_Char nstr[16]; - sal_Char* pstr = nstr; - rtl_str_valueOfInt32( pstr, cnt, 10 ); - - cpystr( pdst, meth ); - cpystr( pdst+ AStringLen(meth), "_" ); - - if ( cnt < 100 ) - { - cpystr(pdst + AStringLen(pdst), "0" ); - } - if ( cnt < 10 ) - { - cpystr(pdst + AStringLen(pdst), "0" ); - } - - cpystr( pdst + AStringLen(pdst), nstr ); - return( pdst ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/qa/OStringBuffer/rtl_String_Utils.hxx b/sal/qa/OStringBuffer/rtl_String_Utils.hxx deleted file mode 100644 index 3a674a8c64df..000000000000 --- a/sal/qa/OStringBuffer/rtl_String_Utils.hxx +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef _RTL_STRING_UTILS_HXX_ -#define _RTL_STRING_UTILS_HXX_ - -#ifdef __cplusplus - -#include -#include - -#include -#include -#include - -sal_Char* cpystr( sal_Char* dst, const sal_Char* src ); -sal_Char* cpynstr( sal_Char* dst, const sal_Char* src, sal_uInt32 cnt ); - -bool cmpstr( const sal_Char* str1, const sal_Char* str2, sal_uInt32 len ); -bool cmpstr( const sal_Char* str1, const sal_Char* str2 ); -bool cmpustr( const sal_Unicode* str1, const sal_Unicode* str2, sal_uInt32 len ); -bool cmpustr( const sal_Unicode* str1, const sal_Unicode* str2 ); - -sal_Char* createName( sal_Char* dst, const sal_Char* src, sal_uInt32 cnt ); - -sal_uInt32 AStringLen( const sal_Char *pAStr ); - -bool AStringNIsValid( const sal_Char *pAStr, - const sal_uInt32 nStrLen - ); - -sal_Int32 AStringToUStringCompare( const sal_Unicode *pUStr, - const sal_Char *pAStr - ); - -sal_Int32 AStringToUStringNCompare( const sal_Unicode *pUStr, - const sal_Char *pAStr, - const sal_uInt32 nAStrCount - ); - -#endif /* __cplusplus */ - -#endif /* _RTL_STRING_UTILS_HXX */ - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/qa/osl/condition/osl_Condition.cxx b/sal/qa/osl/condition/osl_Condition.cxx index 1f1a14b180e7..160a4d5374bf 100644 --- a/sal/qa/osl/condition/osl_Condition.cxx +++ b/sal/qa/osl/condition/osl_Condition.cxx @@ -25,27 +25,6 @@ using namespace osl; using namespace rtl; -// helper functions and classes - -/** print Boolean value. -*/ -inline void printBool( bool bOk ) -{ - printf("#printBool# " ); - bOk ? printf("TRUE!\n" ): printf("FALSE!\n" ); -} - -/** print a UNI_CODE String. -*/ -inline void printUString( const ::rtl::OUString & str ) -{ - rtl::OString aString; - - printf("#printUString_u# " ); - aString = ::rtl::OUStringToOString( str, RTL_TEXTENCODING_ASCII_US ); - printf("%s\n", aString.getStr( ) ); -} - enum ConditionType { thread_type_set, diff --git a/sal/qa/osl/file/osl_File.cxx b/sal/qa/osl/file/osl_File.cxx index fcf3a8b15739..8a16c605fdba 100644 --- a/sal/qa/osl/file/osl_File.cxx +++ b/sal/qa/osl/file/osl_File.cxx @@ -100,133 +100,6 @@ rtl::OString errorToStr( ::osl::FileBase::RC const& nError) return suBuf; } -/** print a file type name. -*/ -inline void printFileType( const ::osl::FileStatus::Type nType ) -{ - printf( "#printFileType# " ); - switch ( nType ) { - case ::osl::FileStatus::Directory: - printf( "This file is a: Directory.\n" ); - break; - case ::osl::FileStatus::Volume: - printf( "This file is a: volume device.\n" ); - break; - case ::osl::FileStatus::Regular: - printf( "This file is a: regular file.\n" ); - break; - case ::osl::FileStatus::Fifo: - printf( "This file is a: fifo.\n" ); - break; - case ::osl::FileStatus::Socket: - printf( "This file is a: socket.\n" ); - break; - case ::osl::FileStatus::Link: - printf( "This file is a: link file.\n" ); - break; - case ::osl::FileStatus::Special: - printf( "This file is a: special.\n" ); - break; - case ::osl::FileStatus::Unknown: - printf( "The file type is unknown %d \n", nType ); - break; - } -} - -/** print a file attributes. -*/ -inline void printFileAttributes( const sal_Int64 nAttributes ) -{ - printf( "#printFileAttributes# This file is a: (" ); - if ( ( nAttributes | osl_File_Attribute_ReadOnly ) == nAttributes ) - printf( " ReadOnly " ); - if ( ( nAttributes | osl_File_Attribute_Hidden ) == nAttributes ) - printf( " Hidden " ); - if ( ( nAttributes | osl_File_Attribute_Executable ) == nAttributes ) - printf( " Executable " ); - if ( ( nAttributes | osl_File_Attribute_GrpWrite ) == nAttributes ) - printf( " GrpWrite " ); - if ( ( nAttributes | osl_File_Attribute_GrpRead ) == nAttributes ) - printf( " GrpRead " ); - if ( ( nAttributes | osl_File_Attribute_GrpExe ) == nAttributes ) - printf( " GrpExe " ); - if ( ( nAttributes | osl_File_Attribute_OwnWrite ) == nAttributes ) - printf( " OwnWrite " ); - if ( ( nAttributes | osl_File_Attribute_OwnRead ) == nAttributes ) - printf( " OwnRead " ); - if ( ( nAttributes | osl_File_Attribute_OwnExe ) == nAttributes ) - printf( " OwnExe " ); - if ( ( nAttributes | osl_File_Attribute_OthWrite ) == nAttributes ) - printf( " OthWrite " ); - if ( ( nAttributes | osl_File_Attribute_OthRead ) == nAttributes ) - printf( " OthRead " ); - if ( ( nAttributes | osl_File_Attribute_OthExe ) == nAttributes ) - printf( " OthExe " ); - printf( ") file!\n" ); -} - -/** print an output wrong message. -*/ -inline void printError( const ::osl::FileBase::RC nError ) -{ - printf( "#printError# " ); - printf( "%s\n", errorToStr(nError).getStr() ); -} - -/** print an signed Integer Number. -*/ -inline void printInt( sal_Int64 i ) -{ - printf( "#printInt_i64# " ); - printf( "The Integer64 is %" SAL_PRIdINT64 "\n", i); -} - -/** print an unsigned Integer Number. -*/ -inline void printInt( sal_uInt64 i ) -{ - printf( "#printInt_u64# " ); - printf( "The unsigned Integer64 is %" SAL_PRIuUINT64 "\n", i); -} - -/** print Boolean value. -*/ -inline void printBool( bool bOk ) -{ - printf( "#printBool# " ); - bOk ? printf( "YES!\n" ): printf( "NO!\n" ); -} - -/** print struct TimeValue in local time format. -*/ -inline void printTime( TimeValue *tv ) -{ - oslDateTime *pDateTime = ( oslDateTime* )malloc( sizeof( oslDateTime ) ) ; - CPPUNIT_ASSERT_MESSAGE( "Error in printTime() function,malloc ", pDateTime != NULL ); - TimeValue *pLocalTV = ( TimeValue* )malloc( sizeof( TimeValue ) ); - CPPUNIT_ASSERT_MESSAGE( "Error in printTime() function,malloc ", pLocalTV != NULL ); - - CPPUNIT_ASSERT_MESSAGE( "Error in printTime() function,osl_getLocalTimeFromSystemTime ",sal_True == osl_getLocalTimeFromSystemTime( tv, pLocalTV ) ); - CPPUNIT_ASSERT_MESSAGE( "Error in printTime() function,osl_gepDateTimeFromTimeValue ",sal_True == osl_getDateTimeFromTimeValue( pLocalTV, pDateTime ) ); - - printf( "#printTime# " ); - printf( " Time is: %d/%d/%d ", pDateTime->Month, pDateTime->Day, pDateTime->Year); - switch ( pDateTime->DayOfWeek ) - { - case 0: printf("Sun. "); break; - case 1: printf("Mon. "); break; - case 2: printf("Tue. "); break; - case 3: printf("Wed. "); break; - case 4: printf("Thu. "); break; - case 5: printf("Fri. "); break; - case 6: printf("Sat. "); break; - } - printf( " %d:%d:%d %d nsecs\n", pDateTime->Hours, pDateTime->Minutes, pDateTime->Seconds, (int) pDateTime->NanoSeconds); - - free( pDateTime ); - free( pLocalTV ); -} - /** compare two TimeValue, unit is "ms", since Windows time precision is better than UNX. */ /* FIXME: the above assertion is bogus */ @@ -237,20 +110,6 @@ inline void printTime( TimeValue *tv ) # define delta 1800 //time precision, 1.8s #endif -inline sal_Int64 t_abs64(sal_Int64 _nValue) -{ - // std::abs() seems to have some ambiguity problems (so-texas) - // return abs(_nValue); - printf("t_abs64(%ld)\n", (long) _nValue); - // CPPUNIT_ASSERT(_nValue < 2147483647); - - if (_nValue < 0) - { - _nValue = -_nValue; - } - return _nValue; -} - inline bool t_compareTime( TimeValue *m_aEndTime, TimeValue *m_aStartTime, sal_Int32 nDelta) { // sal_uInt64 uTimeValue; @@ -296,25 +155,6 @@ inline bool compareFileName( const ::rtl::OUString & ustr1, const ::rtl::OUStrin return bOk; } -/** compare a OUString and an ASCII file name. -*/ -inline bool compareFileName( const ::rtl::OUString & ustr, const sal_Char *astr ) -{ - (void)ustr; - ::rtl::OUString ustr1 = rtl::OUString::createFromAscii( astr ); - bool bOk = ustr1.equalsIgnoreAsciiCase( ustr1 ); // TODO: does it really compare with the same var? - - return bOk; -} - -/** simple version to judge if a file name or directory name is a URL or a system path, just to see if it - is start with "file:///";. -*/ -inline bool isURL( const sal_Char *pathname ) -{ - return ( 0 == strncmp( pathname, FILE_PREFIX, sizeof( FILE_PREFIX ) - 1 ) ); -} - /** simple version to judge if a file name or directory name is a URL or a system path, just to see if it is start with "file:///";. */ @@ -464,49 +304,6 @@ typedef enum { osl_Check_Mode_WriteAccess } oslCheckMode; -// not used here -inline bool checkFile( const ::rtl::OUString & str, oslCheckMode nCheckMode ) -{ - ::osl::FileBase::RC nError1, nError2; - ::osl::File testFile( str ); - bool bCheckResult; - - bCheckResult = false; - nError1 = testFile.open ( osl_File_OpenFlag_Read ); - if ( ( ::osl::FileBase::E_NOENT != nError1 ) && ( ::osl::FileBase::E_ACCES != nError1 ) ){ - - switch ( nCheckMode ) { - case osl_Check_Mode_Exist: - /// check if the file is exist. - if ( ::osl::FileBase::E_None == nError1 ) - bCheckResult = true; - break; - case osl_Check_Mode_OpenAccess: - /// check if the file is openable. - if ( ::osl::FileBase::E_None == nError1 ) - bCheckResult = true; - break; - case osl_Check_Mode_WriteAccess: - /// check the file name and whether it can be written. - /// write chars into the file. - sal_uInt64 nCount_write; - nError2 = testFile.write( pBuffer_Char, 10, nCount_write ); - if ( ::osl::FileBase::E_None == nError2 ) - bCheckResult = true; - break; - - default: - bCheckResult = false; - }/// swith - - nError2 = testFile.close(); - CPPUNIT_ASSERT_MESSAGE( " in CheckFile() function, close file ", nError2 == FileBase::E_None ); - - } - - return bCheckResult; -} - //check if the file exist inline bool ifFileExist( const ::rtl::OUString & str ) { @@ -1187,1130 +984,257 @@ namespace osl_FileBase class searchFileURL:public CppUnit::TestFixture { - //::osl::FileBase aFileBase; - ::rtl::OUString aUStr; - ::osl::FileBase::RC nError1, nError2, nError3,nError4; - - public: - - searchFileURL() - : nError1(FileBase::E_None) - , nError2(FileBase::E_None) - , nError3(FileBase::E_None) - , nError4(FileBase::E_None) {} - // test code. - void searchFileURL_001() - { - /* search file is passed by system filename */ - nError1 = ::osl::FileBase::searchFileURL( aTmpName1, aUserDirectorySys, aUStr ); - /* search file is passed by full qualified file URL */ - nError2 = ::osl::FileBase::searchFileURL( aCanURL1, aUserDirectorySys, aUStr ); - /* 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 )); - } - - void searchFileURL_002() - { - /* search file is passed by system filename */ - nError1 = ::osl::FileBase::searchFileURL( aTempDirectorySys, aRootSys, aUStr ); - bool bOk1 = compareFileName( aUStr, aTempDirectoryURL ); - /* search file is passed by full qualified file URL */ - nError2 = ::osl::FileBase::searchFileURL( aTempDirectoryURL, aRootSys, aUStr ); - bool bOk2 = compareFileName( aUStr, aTempDirectoryURL ); - /* search file is passed by relative file path */ - nError3 = ::osl::FileBase::searchFileURL( aRelURL5, aRootSys, aUStr ); - bool bOk3 = compareFileName( aUStr, aTempDirectoryURL ); - /* search file is passed by an exist file */ - createTestFile( aCanURL1 ); - nError4 = ::osl::FileBase::searchFileURL( aCanURL4, aUserDirectorySys, aUStr ); - bool bOk4 = compareFileName( aUStr, aCanURL1 ); - deleteTestFile( aCanURL1 ); - - 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 ); - } - - void searchFileURL_003() - { - OSLTEST_DECLARE( SystemPathList, 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_MESSAGE( "test for searchFileURL function: search directory is a list of system paths", - ( osl::FileBase::E_None == nError1 ) && - bOk ); - } - - void searchFileURL_004() - { - OSLTEST_DECLARE( SystemPathList, 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_MESSAGE( "test for searchFileURL function: search directory is a list of system paths", - ( osl::FileBase::E_None == nError1 ) && - bOk ); - } - - void searchFileURL_005() - { - nError1 = ::osl::FileBase::searchFileURL( aUserDirectoryURL, aNullURL, aUStr ); - bool bOk = compareFileName( aUStr, aUserDirectoryURL ); - CPPUNIT_ASSERT_MESSAGE( "test for searchFileURL function: search directory is NULL", - ( osl::FileBase::E_None == nError1 ) && - bOk ); - } - - CPPUNIT_TEST_SUITE( searchFileURL ); - CPPUNIT_TEST( searchFileURL_001 ); - CPPUNIT_TEST( searchFileURL_002 ); - CPPUNIT_TEST( searchFileURL_003 ); - CPPUNIT_TEST( searchFileURL_004 ); - CPPUNIT_TEST( searchFileURL_005 ); - CPPUNIT_TEST_SUITE_END(); - };// class searchFileURL - - // testing the method - // static inline RC getTempDirURL( ::rtl::OUString& ustrTempDirURL ) - - class getTempDirURL:public CppUnit::TestFixture - { - //::osl::FileBase aFileBase; - ::rtl::OUString aUStr; - ::osl::FileBase::RC nError; - - public: - getTempDirURL() :nError(FileBase::E_None) {} - // initialization - void setUp() SAL_OVERRIDE - { - nError = FileBase::getTempDirURL( aUStr ); - } - - void tearDown() SAL_OVERRIDE - { - } - - // test code. - void getTempDirURL_001() - { - - CPPUNIT_ASSERT_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, osl_Check_Mode_OpenAccess ) && - checkDirectory( aUStr, osl_Check_Mode_ReadAccess ) && - checkDirectory( aUStr,osl_Check_Mode_WriteAccess ) ); - } - - CPPUNIT_TEST_SUITE( getTempDirURL ); - CPPUNIT_TEST( getTempDirURL_001 ); - CPPUNIT_TEST( getTempDirURL_002 ); - CPPUNIT_TEST_SUITE_END(); - };// class getTempDirURL - - // testing the method - // static inline RC createTempFile( ::rtl::OUString* pustrDirectoryURL, - // oslFileHandle* pHandle, - // ::rtl::OUString* pustrTempFileURL) - - class createTempFile:public CppUnit::TestFixture - { - //::osl::FileBase aFileBase; - ::osl::FileBase::RC nError1, nError2; - bool bOK; - - oslFileHandle *pHandle; - ::rtl::OUString *pUStr_DirURL; - ::rtl::OUString *pUStr_FileURL; - - public: - createTempFile() - : nError1(FileBase::E_None) - , nError2(FileBase::E_None) - , bOK(false) - , pHandle(NULL) - , pUStr_DirURL(NULL) - , pUStr_FileURL(NULL) - { - } - - // initialization - void setUp() SAL_OVERRIDE - { - pHandle = new oslFileHandle(); - pUStr_DirURL = new ::rtl::OUString( aUserDirectoryURL ); - pUStr_FileURL = new ::rtl::OUString(); - //*pUStr_DirURL = aUserDirectoryURL; /// create temp file in /tmp/PID or c:\temp\PID.*/ - } - - void tearDown() SAL_OVERRIDE - { - delete pUStr_DirURL; - delete pUStr_FileURL; - delete pHandle; - } - - // test code. - void createTempFile_001() - { - nError1 = FileBase::createTempFile( pUStr_DirURL, pHandle, pUStr_FileURL ); - ::osl::File testFile( *pUStr_FileURL ); - nError2 = testFile.open( osl_File_OpenFlag_Create ); - if ( osl::FileBase::E_EXIST == nError2 ) { - osl_closeFile( *pHandle ); - deleteTestFile( *pUStr_FileURL ); - } - - CPPUNIT_ASSERT_MESSAGE( "test for createTempFile function: create temp file and test the existence", - ( osl::FileBase::E_None == nError1 ) && ( pHandle != NULL ) && ( osl::FileBase::E_EXIST== nError2 ) ); - } - - void createTempFile_002() - { - bOK = false; - nError1 = FileBase::createTempFile( pUStr_DirURL, pHandle, pUStr_FileURL ); - ::osl::File testFile( *pUStr_FileURL ); - nError2 = testFile.open( osl_File_OpenFlag_Create ); - - CPPUNIT_ASSERT_MESSAGE( "createTempFile function: create a temp file, but it does not exist", - ( osl::FileBase::E_None == nError1 ) && ( pHandle != NULL ) && - ( osl::FileBase::E_EXIST == nError2 ) ); - - //check file if have the write permission - if ( osl::FileBase::E_EXIST == nError2 ) { - bOK = ifFileCanWrite( *pUStr_FileURL ); - osl_closeFile( *pHandle ); - deleteTestFile( *pUStr_FileURL ); - } - - CPPUNIT_ASSERT_MESSAGE( "test for open and write access rights, in (W32), it did not have write access right, but it should be writtenable.", - bOK ); - } - - void createTempFile_003() - { - nError1 = FileBase::createTempFile( pUStr_DirURL, pHandle, 0 ); - //the temp file will be removed when return from createTempFile - bOK = (pHandle != NULL && nError1 == osl::FileBase::E_None); - if ( bOK ) - osl_closeFile( *pHandle ); - - 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 ); - } - void createTempFile_004() - { - nError1 = FileBase::createTempFile( pUStr_DirURL, 0, pUStr_FileURL ); - bOK = ( pUStr_FileURL != 0); - CPPUNIT_ASSERT(bOK); - ::osl::File testFile( *pUStr_FileURL ); - nError2 = testFile.open( osl_File_OpenFlag_Create ); - deleteTestFile( *pUStr_FileURL ); - 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 ); - - } - - CPPUNIT_TEST_SUITE( createTempFile ); - CPPUNIT_TEST( createTempFile_001 ); - CPPUNIT_TEST( createTempFile_002 ); - CPPUNIT_TEST( createTempFile_003 ); - CPPUNIT_TEST( createTempFile_004 ); - CPPUNIT_TEST_SUITE_END(); - };// class createTempFile - - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileBase::getAbsoluteFileURL, "osl_FileBase" ); - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileBase::SystemPath_FileURL, "osl_FileBase" ); - // CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileBase::getFileURLFromSystemPath, "osl_FileBase" ); - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileBase::searchFileURL, "osl_FileBase" ); - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileBase::getTempDirURL, "osl_FileBase" ); - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileBase::createTempFile, "osl_FileBase" ); -}// namespace osl_FileBase - -// Beginning of the test cases for VolumeInfo class - -namespace osl_VolumeInfo -{ - - // testing the method - // VolumeInfo( sal_uInt32 nMask ): _nMask( nMask ) - - class ctors : public CppUnit::TestFixture - { - ::rtl::OUString aUStr; - ::osl::FileBase::RC nError1, nError2; - - ::osl::VolumeDevice aVolumeDevice1; - - public: - ctors() :nError1(FileBase::E_None),nError2(FileBase::E_None) {} - // initialization - void setUp() SAL_OVERRIDE - { - } - - void tearDown() SAL_OVERRIDE - { - } - - // test code. - void ctors_001() - { - ::osl::VolumeInfo aVolumeInfo( 0 ); - nError1 = ::osl::Directory::getVolumeInfo( aRootURL, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - sal_uInt64 uiTotalSpace = aVolumeInfo.getTotalSpace(); - sal_uInt32 uiMaxPathLength = aVolumeInfo.getMaxPathLength(); - aUStr = aVolumeInfo.getFileSystemName(); - - CPPUNIT_ASSERT_MESSAGE( "test for ctors function: mask is empty", - ( 0 == uiTotalSpace ) && - ( 0 == uiMaxPathLength ) && - compareFileName( aUStr, aNullURL ) ); - } - -#if ( defined UNX ) - void ctors_002() - { - ::osl::VolumeInfo aVolumeInfo( osl_VolumeInfo_Mask_TotalSpace | - osl_VolumeInfo_Mask_UsedSpace | - osl_VolumeInfo_Mask_FileSystemName ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL4, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - //CPPUNIT_ASSERT( aVolumeInfo.isValid( mask ) ); - sal_uInt64 uiTotalSpace = aVolumeInfo.getTotalSpace(); - sal_uInt64 uiUsedSpace = aVolumeInfo.getUsedSpace(); - aUStr = aVolumeInfo.getFileSystemName(); - - CPPUNIT_ASSERT_MESSAGE( "test for ctors function: mask is specified as certain valid fields, and get the masked fields", - ( 0 != uiTotalSpace ) && - ( 0 != uiUsedSpace ) && - compareFileName( aUStr, "nfs" ) ); - } -#else /// Windows version,here we can not determine whichvolume in Windows is serve as an nfs volume. - void ctors_002() - { - CPPUNIT_ASSERT_MESSAGE( "test for ctors function: mask is specified as certain valid fields, and get the masked fields( Windows version )", - 1 == 1 ); - } -#endif - - void ctors_003() - { - - sal_Int32 mask1 = osl_VolumeInfo_Mask_FreeSpace; - ::osl::VolumeInfo aVolumeInfo1( mask1 ); - nError1 = ::osl::Directory::getVolumeInfo( aRootURL, aVolumeInfo1 ); - CPPUNIT_ASSERT( aVolumeInfo1.isValid( mask1 ) ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - - sal_uInt64 uiTotalSpace1 = aVolumeInfo1.getTotalSpace(); - aUStr = aVolumeInfo1.getFileSystemName(); - - sal_Int32 mask2 = osl_VolumeInfo_Mask_TotalSpace; - ::osl::VolumeInfo aVolumeInfo2( mask2 ); - nError2 = ::osl::Directory::getVolumeInfo( aRootURL, aVolumeInfo2 ); - CPPUNIT_ASSERT( aVolumeInfo2.isValid( mask2 ) ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError2 ); - - sal_uInt64 uiTotalSpace2 = aVolumeInfo2.getTotalSpace(); - - CPPUNIT_ASSERT_MESSAGE( "test for ctors function: mask is specified as certain valid fields, but get unmasked fields, use mask to FreeSpace, but I can get TotalSpace, did not pass in (UNX)(W32)", - ( 0 == uiTotalSpace1 ) && ( 0 != uiTotalSpace2 ) && - compareFileName( aUStr, aNullURL ) ); - } - - CPPUNIT_TEST_SUITE( ctors ); - CPPUNIT_TEST( ctors_001 ); - CPPUNIT_TEST( ctors_002 ); - CPPUNIT_TEST( ctors_003 ); - CPPUNIT_TEST_SUITE_END(); - };// class ctors - - // testing the method - // inline sal_Bool isValid( sal_uInt32 nMask ) const - - class isValid : public CppUnit::TestFixture - { - ::osl::VolumeDevice aVolumeDevice; - ::rtl::OUString aUStr; - ::osl::FileBase::RC nError1; - - public: - isValid() :nError1(FileBase::E_None) {} - // initialization - void setUp() SAL_OVERRIDE - { - } - - void tearDown() SAL_OVERRIDE - { - - } - - // test code. - void isValid_001() - { - sal_Int32 mask = 0; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL4, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - - CPPUNIT_ASSERT_MESSAGE( "test for isValid function: no fields specified.", - aVolumeInfo.isValid( mask ) ); - } - -#if ( defined UNX ) - void isValid_002() - { - sal_Int32 mask = osl_VolumeInfo_Mask_Attributes | osl_VolumeInfo_Mask_TotalSpace | osl_VolumeInfo_Mask_UsedSpace | - osl_VolumeInfo_Mask_FreeSpace | osl_VolumeInfo_Mask_MaxNameLength | - osl_VolumeInfo_Mask_MaxPathLength | osl_VolumeInfo_Mask_FileSystemName; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL4, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - - CPPUNIT_ASSERT_MESSAGE( "test for isValid function: all valid fields specified for a nfs volume.", - aVolumeInfo.isValid( mask ) ); - } -#else /// Windows version,here we can not determine whichvolume in Windows is serve as an nfs volume. - void isValid_002() - { - CPPUNIT_ASSERT_MESSAGE( "test for isValid function: all valid fields specified for a nfs volume.( Windows version )", - 1 == 1 ); - } -#endif - - void isValid_003() - { - ::osl::VolumeDevice aVolumeDevice1; - sal_Int32 mask = osl_VolumeInfo_Mask_Attributes; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - bool bOk1 = aVolumeInfo.isValid( mask ); - - nError1 = ::osl::Directory::getVolumeInfo( aVolURL2, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - bool bOk2 = aVolumeInfo.isValid( mask ); - - CPPUNIT_ASSERT_MESSAGE( "test for isValid function: osl_VolumeInfo_Mask_Attributes, it should be valid for some volume such as /, floppy, cdrom, etc. but it did not pass", - bOk1 && bOk2 ); - } - - CPPUNIT_TEST_SUITE( isValid ); - CPPUNIT_TEST( isValid_001 ); - CPPUNIT_TEST( isValid_002 ); - CPPUNIT_TEST( isValid_003 ); - CPPUNIT_TEST_SUITE_END(); - };// class isValid - - // testing the method - // inline sal_Bool getRemoteFlag() const - - class getRemoteFlag : public CppUnit::TestFixture - { - ::osl::VolumeDevice aVolumeDevice; - ::rtl::OUString aUStr; - ::osl::FileBase::RC nError1; - - public: - getRemoteFlag() :nError1(FileBase::E_None) {} - // test code. - void getRemoteFlag_001() - { - sal_Int32 mask = osl_VolumeInfo_Mask_Attributes; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - bool bOk = aVolumeInfo.getRemoteFlag(); - - CPPUNIT_ASSERT_MESSAGE( "test for getRemoteFlag function: get a volume device which is not remote.", - !bOk ); - } - - #if ( defined UNX ) //remote Volume is different in Solaris and Windows - void getRemoteFlag_002() - { - sal_Int32 mask = osl_VolumeInfo_Mask_Attributes; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL4, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - bool bOk = aVolumeInfo.getRemoteFlag(); - - CPPUNIT_ASSERT_MESSAGE( "test for getRemoteFlag function: get a volume device which is remote( Solaris version ).", - bOk ); - } -#else //Windows version - void getRemoteFlag_002() - { - CPPUNIT_ASSERT_MESSAGE( "test for getRemoteFlag function: get a volume device which is remote( Windows version )", - 1 == 1 ); - } -#endif - - CPPUNIT_TEST_SUITE( getRemoteFlag ); - CPPUNIT_TEST( getRemoteFlag_001 ); - CPPUNIT_TEST( getRemoteFlag_002 ); - CPPUNIT_TEST_SUITE_END(); - };// class getRemoteFlag - - // testing the method - // inline sal_Bool getRemoveableFlag() const - - class getRemoveableFlag : public CppUnit::TestFixture - { - ::osl::FileBase::RC nError1; - - public: - getRemoveableFlag() :nError1(FileBase::E_None) {} - // test code. - void getRemoveableFlag_001() - { - sal_Int32 mask = osl_VolumeInfo_Mask_Attributes; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - bool bOk = aVolumeInfo.getRemoveableFlag(); - - CPPUNIT_ASSERT_MESSAGE( "test for getRemoveableFlag function: get a volume device which is not removable.", - !bOk ); - } - - void getRemoveableFlag_002() - { - sal_Int32 mask = osl_VolumeInfo_Mask_Attributes; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL2, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - bool bOk = aVolumeInfo.getRemoveableFlag(); - - CPPUNIT_ASSERT_MESSAGE( "test for getRemoveableFlag function: get a volume device which is removable, not sure, here we use floppy disk, but it did not pass.", - bOk ); - } - CPPUNIT_TEST_SUITE( getRemoveableFlag ); - CPPUNIT_TEST( getRemoveableFlag_001 ); - CPPUNIT_TEST( getRemoveableFlag_002 ); - CPPUNIT_TEST_SUITE_END(); - };// class getRemoveableFlag - - // testing the method - // inline sal_Bool getCompactDiscFlag() const - - class getCompactDiscFlag : public CppUnit::TestFixture - { - ::osl::FileBase::RC nError1; - - public: - getCompactDiscFlag() :nError1(FileBase::E_None) {} - // test code. - void getCompactDiscFlag_001() - { - sal_Int32 mask = osl_VolumeInfo_Mask_Attributes; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - bool bOk = aVolumeInfo.getCompactDiscFlag(); - - CPPUNIT_ASSERT_MESSAGE( "test for getCompactDiscFlag function: get a volume device which is not a cdrom.", - !bOk ); - } - - void getCompactDiscFlag_002() - { - sal_Int32 mask = osl_VolumeInfo_Mask_Attributes; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL6, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - bool bOk = aVolumeInfo.getCompactDiscFlag(); - - CPPUNIT_ASSERT_MESSAGE( "test for getCompactDiscFlag function: get a cdrom volume device flag, it did not pass.", - bOk ); - } - CPPUNIT_TEST_SUITE( getCompactDiscFlag ); - CPPUNIT_TEST( getCompactDiscFlag_001 ); - CPPUNIT_TEST( getCompactDiscFlag_002 ); - CPPUNIT_TEST_SUITE_END(); - };// class getCompactDiscFlag - - // testing the method - // inline sal_Bool getFloppyDiskFlag() const - - class getFloppyDiskFlag : public CppUnit::TestFixture - { - ::osl::FileBase::RC nError1; - - public: - getFloppyDiskFlag() :nError1(FileBase::E_None) {} - // test code. - void getFloppyDiskFlag_001() - { - sal_Int32 mask = osl_VolumeInfo_Mask_Attributes; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - bool bOk = aVolumeInfo.getFloppyDiskFlag(); - - CPPUNIT_ASSERT_MESSAGE( "test for getFloppyDiskFlag function: get a volume device which is not a floppy disk.", - !bOk ); - } - - void getFloppyDiskFlag_002() - { - sal_Int32 mask = osl_VolumeInfo_Mask_Attributes; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL2, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - bool bOk = aVolumeInfo.getFloppyDiskFlag(); - - CPPUNIT_ASSERT_MESSAGE( "test for getFloppyDiskFlag function: get a floppy volume device flag, it did not pass.", - bOk ); - } - CPPUNIT_TEST_SUITE( getFloppyDiskFlag ); - CPPUNIT_TEST( getFloppyDiskFlag_001 ); - CPPUNIT_TEST( getFloppyDiskFlag_002 ); - CPPUNIT_TEST_SUITE_END(); - };// class getFloppyDiskFlag - - // testing the method - // inline sal_Bool getFixedDiskFlag() const - - class getFixedDiskFlag : public CppUnit::TestFixture - { - ::osl::FileBase::RC nError1; - - public: - getFixedDiskFlag() :nError1(FileBase::E_None) {} - // test code. - void getFixedDiskFlag_001() - { - sal_Int32 mask = osl_VolumeInfo_Mask_Attributes; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL2, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - bool bOk = aVolumeInfo.getFixedDiskFlag(); - - CPPUNIT_ASSERT_MESSAGE( "test for getFixedDiskFlag function: get a volume device which is not a fixed disk.", - !bOk ); - } - - void getFixedDiskFlag_002() - { - sal_Int32 mask = osl_VolumeInfo_Mask_Attributes; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - bool bOk = aVolumeInfo.getFixedDiskFlag(); - - CPPUNIT_ASSERT_MESSAGE( "test for getFixedDiskFlag function: get a fixed disk volume device flag, it did not pass.", - bOk ); - } - CPPUNIT_TEST_SUITE( getFixedDiskFlag ); - CPPUNIT_TEST( getFixedDiskFlag_001 ); - CPPUNIT_TEST( getFixedDiskFlag_002 ); - CPPUNIT_TEST_SUITE_END(); - };// class getFixedDiskFlag - - // testing the method - // inline sal_Bool getRAMDiskFlag() const - - class getRAMDiskFlag : public CppUnit::TestFixture - { - ::osl::FileBase::RC nError1; - - public: - getRAMDiskFlag() :nError1(FileBase::E_None) {} - // test code. - void getRAMDiskFlag_001() - { - sal_Int32 mask = osl_VolumeInfo_Mask_Attributes; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - bool bOk = aVolumeInfo.getRAMDiskFlag(); - - CPPUNIT_ASSERT_MESSAGE( "test for getRAMDiskFlag function: get a volume device which is not a RAM disk.", - !bOk ); - } - - void getRAMDiskFlag_002() - { - sal_Int32 mask = osl_VolumeInfo_Mask_Attributes; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - bool bOk = aVolumeInfo.getRAMDiskFlag(); - - CPPUNIT_ASSERT_MESSAGE( "test for getRAMDiskFlag function: FIX ME, don't know how to get a RAM disk flag, perhaps Windows 98 boot disk can create a RAM disk, it did not pass in (UNX)(W32).", - bOk ); - } - CPPUNIT_TEST_SUITE( getRAMDiskFlag ); - CPPUNIT_TEST( getRAMDiskFlag_001 ); - CPPUNIT_TEST( getRAMDiskFlag_002 ); - CPPUNIT_TEST_SUITE_END(); - };// class getRAMDiskFlag - - // testing the method - // inline sal_uInt64 getTotalSpace() const - - class getTotalSpace : public CppUnit::TestFixture - { - ::osl::FileBase::RC nError1; - - public: - getTotalSpace() :nError1(FileBase::E_None) {} - // test code. - void getTotalSpace_001() - { - sal_Int32 mask = osl_VolumeInfo_Mask_TotalSpace; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - CPPUNIT_ASSERT( aVolumeInfo.isValid( mask ) ); - sal_uInt64 uiTotalSpace = aVolumeInfo.getTotalSpace(); - - CPPUNIT_ASSERT_MESSAGE( "test for getTotalSpace function: get total space of Fixed disk volume mounted on /, it should not be 0", - 0 != uiTotalSpace ); - } - - #if defined( UNX ) - void getTotalSpace_002() - { - sal_Int32 mask = osl_VolumeInfo_Mask_TotalSpace; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL3, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - CPPUNIT_ASSERT( aVolumeInfo.isValid( mask ) ); - sal_uInt64 uiTotalSpace = aVolumeInfo.getTotalSpace(); - - CPPUNIT_ASSERT_MESSAGE( "test for getTotalSpace function: get total space of /proc, it should be 0", - 0 == uiTotalSpace ); - } -#else /// Windows version, in Windows, there is no /proc directory - void getTotalSpace_002() - { - CPPUNIT_ASSERT_MESSAGE( "test for getTotalSpace function:not applicable for /proc( Windows version )", - 1 == 1 ); - } -#endif - -#if defined(SOLARIS) - void getTotalSpace_003() - { - struct statvfs aStatFS; - static const sal_Char name[] = "/"; - - memset (&aStatFS, 0, sizeof(aStatFS)); - statvfs( name, &aStatFS); - sal_uInt64 TotalSpace = aStatFS.f_frsize * aStatFS.f_blocks ; - - sal_Int32 mask = osl_VolumeInfo_Mask_TotalSpace; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - CPPUNIT_ASSERT( sal_True == aVolumeInfo.isValid( mask ) ); - sal_uInt64 uiTotalSpace = aVolumeInfo.getTotalSpace(); - - CPPUNIT_ASSERT_MESSAGE( "test for getTotalSpace function: get total space by hand, then compare with getTotalSpace, it did not pass", - uiTotalSpace == TotalSpace ); - } -#else /// Windows version - void getTotalSpace_003() - { - CPPUNIT_ASSERT_MESSAGE( "test for getTotalSpace function:not implemented yet( Windows version )", - 1 == 1 ); - } -#endif - - CPPUNIT_TEST_SUITE( getTotalSpace ); - CPPUNIT_TEST( getTotalSpace_001 ); - CPPUNIT_TEST( getTotalSpace_002 ); - CPPUNIT_TEST( getTotalSpace_003 ); - CPPUNIT_TEST_SUITE_END(); - };// class getTotalSpace - - // testing the method - // inline sal_uInt64 getFreeSpace() const - - class getFreeSpace : public CppUnit::TestFixture - { - ::osl::FileBase::RC nError1; - - public: - getFreeSpace() :nError1(FileBase::E_None) {} - // test code. - void getFreeSpace_001() - { - sal_Int32 mask = osl_VolumeInfo_Mask_FreeSpace; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - CPPUNIT_ASSERT( aVolumeInfo.isValid( mask ) ); - sal_uInt64 uiFreeSpace = aVolumeInfo.getFreeSpace(); - - CPPUNIT_ASSERT_MESSAGE( "test for getFreeSpace function: get free space of Fixed disk volume mounted on /, it should not be 0, suggestion: returned value, -1 is better, since some times the free space may be 0", - 0 != uiFreeSpace ); - } - -#if defined( UNX ) - void getFreeSpace_002() - { - sal_Int32 mask = osl_VolumeInfo_Mask_FreeSpace; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL3, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - CPPUNIT_ASSERT( aVolumeInfo.isValid( mask ) ); - sal_uInt64 uiFreeSpace = aVolumeInfo.getFreeSpace(); - - CPPUNIT_ASSERT_MESSAGE( "test for getFreeSpace function: get free space of /proc, it should be 0", - 0 == uiFreeSpace ); - } -#else /// Windows version, in Windows, there is no /proc directory - void getFreeSpace_002() - { - CPPUNIT_ASSERT_MESSAGE( "test for getFreeSpace function: not applicable for /proc( Windows version )", - 1 == 1 ); - } -#endif - -#if defined(SOLARIS) - void getFreeSpace_003() - { - struct statvfs aStatFS; - static const sal_Char name[] = "/"; - - memset (&aStatFS, 0, sizeof(aStatFS)); - statvfs( name, &aStatFS); - sal_uInt64 FreeSpace = aStatFS.f_bfree * aStatFS.f_frsize ; - - sal_Int32 mask = osl_VolumeInfo_Mask_FreeSpace; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - CPPUNIT_ASSERT( sal_True == aVolumeInfo.isValid( mask ) ); - sal_uInt64 uiFreeSpace = aVolumeInfo.getFreeSpace(); - - CPPUNIT_ASSERT_MESSAGE( "test for getFreeSpace function: get free space by hand, then compare with getFreeSpace, it did not pass", - uiFreeSpace == FreeSpace ); - } -#else //Windows version - void getFreeSpace_003() - { - CPPUNIT_ASSERT_MESSAGE( "test for getFreeSpace function: not implemented yet( Windows version )", - 1 == 1 ); - } -#endif - - CPPUNIT_TEST_SUITE( getFreeSpace ); - CPPUNIT_TEST( getFreeSpace_001 ); - CPPUNIT_TEST( getFreeSpace_002 ); - CPPUNIT_TEST( getFreeSpace_003 ); - CPPUNIT_TEST_SUITE_END(); - };// class getFreeSpace - - // testing the method - // inline sal_uInt64 getUsedSpace() const - - class getUsedSpace : public CppUnit::TestFixture - { - ::osl::FileBase::RC nError1; + //::osl::FileBase aFileBase; + ::rtl::OUString aUStr; + ::osl::FileBase::RC nError1, nError2, nError3,nError4; public: - getUsedSpace() :nError1(FileBase::E_None) {} + + searchFileURL() + : nError1(FileBase::E_None) + , nError2(FileBase::E_None) + , nError3(FileBase::E_None) + , nError4(FileBase::E_None) {} // test code. - void getUsedSpace_001() + void searchFileURL_001() { - sal_Int32 mask = osl_VolumeInfo_Mask_UsedSpace; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - CPPUNIT_ASSERT( aVolumeInfo.isValid( mask ) ); - sal_uInt64 uiUsedSpace = aVolumeInfo.getUsedSpace(); + /* search file is passed by system filename */ + nError1 = ::osl::FileBase::searchFileURL( aTmpName1, aUserDirectorySys, aUStr ); + /* search file is passed by full qualified file URL */ + nError2 = ::osl::FileBase::searchFileURL( aCanURL1, aUserDirectorySys, aUStr ); + /* search file is passed by relative file path */ + nError3 = ::osl::FileBase::searchFileURL( aRelURL4, aUserDirectorySys, aUStr ); - CPPUNIT_ASSERT_MESSAGE( "test for getUsedSpace function: get used space of Fixed disk volume mounted on /, it should not be 0, suggestion: returned value, -1 is better, since some times the used space may be 0", - 0 != uiUsedSpace ); + 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 )); } -#if defined( UNX ) - void getUsedSpace_002() + void searchFileURL_002() { - sal_Int32 mask = osl_VolumeInfo_Mask_UsedSpace; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL3, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - CPPUNIT_ASSERT( aVolumeInfo.isValid( mask ) ); - sal_uInt64 uiUsedSpace = aVolumeInfo.getUsedSpace(); + /* search file is passed by system filename */ + nError1 = ::osl::FileBase::searchFileURL( aTempDirectorySys, aRootSys, aUStr ); + bool bOk1 = compareFileName( aUStr, aTempDirectoryURL ); + /* search file is passed by full qualified file URL */ + nError2 = ::osl::FileBase::searchFileURL( aTempDirectoryURL, aRootSys, aUStr ); + bool bOk2 = compareFileName( aUStr, aTempDirectoryURL ); + /* search file is passed by relative file path */ + nError3 = ::osl::FileBase::searchFileURL( aRelURL5, aRootSys, aUStr ); + bool bOk3 = compareFileName( aUStr, aTempDirectoryURL ); + /* search file is passed by an exist file */ + createTestFile( aCanURL1 ); + nError4 = ::osl::FileBase::searchFileURL( aCanURL4, aUserDirectorySys, aUStr ); + bool bOk4 = compareFileName( aUStr, aCanURL1 ); + deleteTestFile( aCanURL1 ); - CPPUNIT_ASSERT_MESSAGE( "test for getUsedSpace function: get used space of /proc, it should be 0", - 0 == uiUsedSpace ); + 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 ); } -#else /// Windows version, in Windows, there is no /proc directory - void getUsedSpace_002() + + void searchFileURL_003() { - CPPUNIT_ASSERT_MESSAGE( "test for getUsedSpace function: not applicable for /proc( Windows version )", - 1 == 1 ); + OSLTEST_DECLARE( SystemPathList, 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_MESSAGE( "test for searchFileURL function: search directory is a list of system paths", + ( osl::FileBase::E_None == nError1 ) && + bOk ); } -#endif -#if defined(SOLARIS) - void getUsedSpace_003() + void searchFileURL_004() { - struct statvfs aStatFS; - static const sal_Char name[] = "/"; - - memset (&aStatFS, 0, sizeof(aStatFS)); - statvfs( name, &aStatFS); - sal_uInt64 UsedSpace = ( aStatFS.f_blocks - aStatFS.f_bavail ) * aStatFS.f_frsize; - - sal_Int32 mask = osl_VolumeInfo_Mask_UsedSpace; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - CPPUNIT_ASSERT( sal_True == aVolumeInfo.isValid( mask ) ); - sal_uInt64 uiUsedSpace = aVolumeInfo.getUsedSpace(); - - CPPUNIT_ASSERT_MESSAGE( "test for getUsedSpace function: get used space by hand, then compare with getUsedSpace, it did not pass", - uiUsedSpace == UsedSpace ); + OSLTEST_DECLARE( SystemPathList, 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_MESSAGE( "test for searchFileURL function: search directory is a list of system paths", + ( osl::FileBase::E_None == nError1 ) && + bOk ); } -#else //Windows version - void getUsedSpace_003() + + void searchFileURL_005() { - CPPUNIT_ASSERT_MESSAGE( "test for getUsedSpace function: not implemented yet( Windows version )", - 1 == 1 ); + nError1 = ::osl::FileBase::searchFileURL( aUserDirectoryURL, aNullURL, aUStr ); + bool bOk = compareFileName( aUStr, aUserDirectoryURL ); + CPPUNIT_ASSERT_MESSAGE( "test for searchFileURL function: search directory is NULL", + ( osl::FileBase::E_None == nError1 ) && + bOk ); } -#endif - CPPUNIT_TEST_SUITE( getUsedSpace ); - CPPUNIT_TEST( getUsedSpace_001 ); - CPPUNIT_TEST( getUsedSpace_002 ); - CPPUNIT_TEST( getUsedSpace_003 ); - CPPUNIT_TEST_SUITE_END(); - };// class getUsedSpace + CPPUNIT_TEST_SUITE( searchFileURL ); + CPPUNIT_TEST( searchFileURL_001 ); + CPPUNIT_TEST( searchFileURL_002 ); + CPPUNIT_TEST( searchFileURL_003 ); + CPPUNIT_TEST( searchFileURL_004 ); + CPPUNIT_TEST( searchFileURL_005 ); + CPPUNIT_TEST_SUITE_END(); + };// class searchFileURL - // testing the method - // inline sal_uInt32 getMaxNameLength() const + // testing the method + // static inline RC getTempDirURL( ::rtl::OUString& ustrTempDirURL ) - class getMaxNameLength : public CppUnit::TestFixture + class getTempDirURL:public CppUnit::TestFixture { - ::osl::FileBase::RC nError1; + //::osl::FileBase aFileBase; + ::rtl::OUString aUStr; + ::osl::FileBase::RC nError; public: - getMaxNameLength() :nError1(FileBase::E_None) {} - // test code. - void getMaxNameLength_001() + getTempDirURL() :nError(FileBase::E_None) {} + // initialization + void setUp() SAL_OVERRIDE { - sal_Int32 mask = osl_VolumeInfo_Mask_MaxNameLength; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - CPPUNIT_ASSERT( aVolumeInfo.isValid( mask ) ); - sal_uInt32 uiMaxNameLength = aVolumeInfo.getMaxNameLength(); - - CPPUNIT_ASSERT_MESSAGE( "test for getMaxNameLength function: get max name length of Fixed disk volume mounted on /, it should not be 0", - 0 != uiMaxNameLength ); + nError = FileBase::getTempDirURL( aUStr ); } -#if defined(UNX) && !defined(ANDROID) - void getMaxNameLength_002() + void tearDown() SAL_OVERRIDE { - struct statvfs aStatFS; - static const sal_Char name[] = "/"; - - memset (&aStatFS, 0, sizeof(aStatFS)); - statvfs( name, &aStatFS); - sal_uInt64 MaxNameLength = aStatFS.f_namemax; + } - sal_Int32 mask = osl_VolumeInfo_Mask_MaxNameLength; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - CPPUNIT_ASSERT( aVolumeInfo.isValid( mask ) ); - sal_uInt64 uiMaxNameLength = aVolumeInfo.getMaxNameLength(); + // test code. + void getTempDirURL_001() + { - CPPUNIT_ASSERT_MESSAGE( "test for getMaxNameLength function: get max name length by hand, then compare with getMaxNameLength", - uiMaxNameLength == MaxNameLength ); + CPPUNIT_ASSERT_MESSAGE( "test for getTempDirURL function: excution", + ( osl::FileBase::E_None == nError ) ); } -#else //Windows version - void getMaxNameLength_002() + + void getTempDirURL_002() { - CPPUNIT_ASSERT_MESSAGE( "test for getMaxNameLength function: not implemented yet( Windows version )", - 1 == 1 ); + CPPUNIT_ASSERT_MESSAGE( "test for getTempDirURL function: test for open and write access rights", + checkDirectory( aUStr, osl_Check_Mode_OpenAccess ) && + checkDirectory( aUStr, osl_Check_Mode_ReadAccess ) && + checkDirectory( aUStr,osl_Check_Mode_WriteAccess ) ); } -#endif - CPPUNIT_TEST_SUITE( getMaxNameLength ); - CPPUNIT_TEST( getMaxNameLength_001 ); - CPPUNIT_TEST( getMaxNameLength_002 ); - CPPUNIT_TEST_SUITE_END(); - };// class getMaxNameLength + CPPUNIT_TEST_SUITE( getTempDirURL ); + CPPUNIT_TEST( getTempDirURL_001 ); + CPPUNIT_TEST( getTempDirURL_002 ); + CPPUNIT_TEST_SUITE_END(); + };// class getTempDirURL // testing the method - // inline sal_uInt32 getMaxPathLength() const + // static inline RC createTempFile( ::rtl::OUString* pustrDirectoryURL, + // oslFileHandle* pHandle, + // ::rtl::OUString* pustrTempFileURL) - class getMaxPathLength : public CppUnit::TestFixture + class createTempFile:public CppUnit::TestFixture { - ::osl::FileBase::RC nError1; + //::osl::FileBase aFileBase; + ::osl::FileBase::RC nError1, nError2; + bool bOK; - public: - getMaxPathLength() :nError1(FileBase::E_None) {} - // test code. - void getMaxPathLength_001() - { - sal_Int32 mask = osl_VolumeInfo_Mask_MaxPathLength; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - CPPUNIT_ASSERT( aVolumeInfo.isValid( mask ) ); - sal_uInt32 uiMaxPathLength = aVolumeInfo.getMaxPathLength(); + oslFileHandle *pHandle; + ::rtl::OUString *pUStr_DirURL; + ::rtl::OUString *pUStr_FileURL; - CPPUNIT_ASSERT_MESSAGE( "test for getMaxPathLength function: get max path length of Fixed disk volume mounted on /, it should not be 0", - 0 != uiMaxPathLength ); + public: + createTempFile() + : nError1(FileBase::E_None) + , nError2(FileBase::E_None) + , bOK(false) + , pHandle(NULL) + , pUStr_DirURL(NULL) + , pUStr_FileURL(NULL) + { } -#if ( defined UNX ) - void getMaxPathLength_002() + // initialization + void setUp() SAL_OVERRIDE { - sal_Int32 mask = osl_VolumeInfo_Mask_MaxPathLength; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - CPPUNIT_ASSERT( aVolumeInfo.isValid( mask ) ); - sal_uInt64 uiMaxPathLength = aVolumeInfo.getMaxPathLength(); - - CPPUNIT_ASSERT_MESSAGE( "test for getMaxPathLength function: get max path length by hand, then compare with getMaxPathLength", - uiMaxPathLength == PATH_MAX ); + pHandle = new oslFileHandle(); + pUStr_DirURL = new ::rtl::OUString( aUserDirectoryURL ); + pUStr_FileURL = new ::rtl::OUString(); + //*pUStr_DirURL = aUserDirectoryURL; /// create temp file in /tmp/PID or c:\temp\PID.*/ } -#else //Windows version - void getMaxPathLength_002() + + void tearDown() SAL_OVERRIDE { - CPPUNIT_ASSERT_MESSAGE( "test for getMaxPathLength function: not implemented yet( Windows version )", - 1 == 1 ); + delete pUStr_DirURL; + delete pUStr_FileURL; + delete pHandle; } -#endif - - CPPUNIT_TEST_SUITE( getMaxPathLength ); - CPPUNIT_TEST( getMaxPathLength_001 ); - CPPUNIT_TEST( getMaxPathLength_002 ); - CPPUNIT_TEST_SUITE_END(); - };// class getMaxPathLength - - // testing the method - // inline ::rtl::OUString getFileSystemName() const - - class getFileSystemName : public CppUnit::TestFixture - { - ::rtl::OUString aUStr; - ::osl::FileBase::RC nError1; - public: - getFileSystemName() :nError1(FileBase::E_None) {} // test code. - void getFileSystemName_001() + void createTempFile_001() { - sal_Int32 mask = osl_VolumeInfo_Mask_FileSystemName; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - CPPUNIT_ASSERT( aVolumeInfo.isValid( mask ) ); - aUStr = aVolumeInfo.getFileSystemName(); + nError1 = FileBase::createTempFile( pUStr_DirURL, pHandle, pUStr_FileURL ); + ::osl::File testFile( *pUStr_FileURL ); + nError2 = testFile.open( osl_File_OpenFlag_Create ); + if ( osl::FileBase::E_EXIST == nError2 ) { + osl_closeFile( *pHandle ); + deleteTestFile( *pUStr_FileURL ); + } - CPPUNIT_ASSERT_MESSAGE( "test for getFileSystemName function: get file system name of Fixed disk volume mounted on /, it should not be empty string", - !compareFileName( aNullURL, aUStr ) ); + CPPUNIT_ASSERT_MESSAGE( "test for createTempFile function: create temp file and test the existence", + ( osl::FileBase::E_None == nError1 ) && ( pHandle != NULL ) && ( osl::FileBase::E_EXIST== nError2 ) ); } -#if defined(SOLARIS) - void getFileSystemName_002() + void createTempFile_002() { - struct statvfs aStatFS; - static const sal_Char name[] = "/"; + bOK = false; + nError1 = FileBase::createTempFile( pUStr_DirURL, pHandle, pUStr_FileURL ); + ::osl::File testFile( *pUStr_FileURL ); + nError2 = testFile.open( osl_File_OpenFlag_Create ); - memset (&aStatFS, 0, sizeof(aStatFS)); - statvfs( name, &aStatFS); - sal_Char * astrFileSystemName = aStatFS.f_basetype; + CPPUNIT_ASSERT_MESSAGE( "createTempFile function: create a temp file, but it does not exist", + ( osl::FileBase::E_None == nError1 ) && ( pHandle != NULL ) && + ( osl::FileBase::E_EXIST == nError2 ) ); - sal_Int32 mask = osl_VolumeInfo_Mask_FileSystemName; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - CPPUNIT_ASSERT( sal_True == aVolumeInfo.isValid( mask ) ); - aUStr = aVolumeInfo.getFileSystemName(); + //check file if have the write permission + if ( osl::FileBase::E_EXIST == nError2 ) { + bOK = ifFileCanWrite( *pUStr_FileURL ); + osl_closeFile( *pHandle ); + deleteTestFile( *pUStr_FileURL ); + } - CPPUNIT_ASSERT_MESSAGE( "test for getFileSystemName function: get file system name by hand, then compare with getFileSystemName", - sal_True == compareFileName( aUStr, astrFileSystemName ) ); - } -#else //Windows version - void getFileSystemName_002() - { - CPPUNIT_ASSERT_MESSAGE( "test for getFileSystemName function: not implemented yet( Windows version )", - 1 == 1 ); + CPPUNIT_ASSERT_MESSAGE( "test for open and write access rights, in (W32), it did not have write access right, but it should be writtenable.", + bOK ); } -#endif - - CPPUNIT_TEST_SUITE( getFileSystemName ); - CPPUNIT_TEST( getFileSystemName_001 ); - CPPUNIT_TEST( getFileSystemName_002 ); - CPPUNIT_TEST_SUITE_END(); - };// class getFileSystemName - - // testing the method - // inline VolumeDevice getDeviceHandle() const - - class getDeviceHandle : public CppUnit::TestFixture - { - ::rtl::OUString aUStr; - ::osl::FileBase::RC nError1; - public: - getDeviceHandle() :nError1(FileBase::E_None) {} - // test code. - void getDeviceHandle_001() + void createTempFile_003() { - ::osl::VolumeInfo aVolumeInfo( osl_VolumeInfo_Mask_Attributes ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); + nError1 = FileBase::createTempFile( pUStr_DirURL, pHandle, 0 ); + //the temp file will be removed when return from createTempFile + bOK = (pHandle != NULL && nError1 == osl::FileBase::E_None); + if ( bOK ) + osl_closeFile( *pHandle ); - ::osl::VolumeDevice aVolumeDevice1( aVolumeInfo.getDeviceHandle() ); - bool bOk = compareFileName( aNullURL, aVolumeDevice1.getMountPath() ); + 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 ); + } + void createTempFile_004() + { + nError1 = FileBase::createTempFile( pUStr_DirURL, 0, pUStr_FileURL ); + bOK = ( pUStr_FileURL != 0); + CPPUNIT_ASSERT(bOK); + ::osl::File testFile( *pUStr_FileURL ); + nError2 = testFile.open( osl_File_OpenFlag_Create ); + deleteTestFile( *pUStr_FileURL ); + 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 ); - CPPUNIT_ASSERT_MESSAGE( "test for getDeviceHandle function: get device handle of Fixed disk volume mounted on /, it should not be NULL, it did not pass in (W32) (UNX).", - !bOk ); } - CPPUNIT_TEST_SUITE( getDeviceHandle ); - CPPUNIT_TEST( getDeviceHandle_001 ); + CPPUNIT_TEST_SUITE( createTempFile ); + CPPUNIT_TEST( createTempFile_001 ); + CPPUNIT_TEST( createTempFile_002 ); + CPPUNIT_TEST( createTempFile_003 ); + CPPUNIT_TEST( createTempFile_004 ); CPPUNIT_TEST_SUITE_END(); - };// class getDeviceHandle - - /*CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::ctors, "osl_VolumeInfo" ); - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::isValid, "osl_VolumeInfo" ); - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getRemoteFlag, "osl_VolumeInfo" ); - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getRemoveableFlag, "osl_VolumeInfo" ); - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getCompactDiscFlag, "osl_VolumeInfo" ); - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getFloppyDiskFlag, "osl_VolumeInfo" ); - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getFixedDiskFlag, "osl_VolumeInfo" ); - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getRAMDiskFlag, "osl_VolumeInfo" ); - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getTotalSpace, "osl_VolumeInfo" ); - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getFreeSpace, "osl_VolumeInfo" ); - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getUsedSpace, "osl_VolumeInfo" ); - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getMaxNameLength, "osl_VolumeInfo" ); - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getMaxPathLength, "osl_VolumeInfo" ); - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getFileSystemName, "osl_VolumeInfo" ); - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getDeviceHandle, "osl_VolumeInfo" );*/ -}// namespace osl_VolumeInfo - -// Beginning of the test cases for VolumeDevice class + };// class createTempFile + + CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileBase::getAbsoluteFileURL, "osl_FileBase" ); + CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileBase::SystemPath_FileURL, "osl_FileBase" ); + // CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileBase::getFileURLFromSystemPath, "osl_FileBase" ); + CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileBase::searchFileURL, "osl_FileBase" ); + CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileBase::getTempDirURL, "osl_FileBase" ); + CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileBase::createTempFile, "osl_FileBase" ); +}// namespace osl_FileBase namespace osl_FileStatus { @@ -4161,15 +3085,6 @@ namespace osl_File deleteTestFile( aTmpName6 ); CPPUNIT_ASSERT_MESSAGE( "test for copy function: the dest file exist", nFilePointer == 200 ); - } - //copyLink has not been impletmented yet - void copy_007() - { -#if ( defined UNX ) - - CPPUNIT_ASSERT_MESSAGE( "test for copy function: source file is link file", - ::osl::FileBase::E_INVAL == nError1 ); -#endif } CPPUNIT_TEST_SUITE( copy ); @@ -4305,30 +3220,7 @@ namespace osl_File (::osl::FileBase::E_None == nError1 ) && (::osl::FileBase::E_EXIST == nError2 ) ); } - // oldpath and newpath are not on the same filesystem.EXDEV,no such error no on Solaris, only on linux - void move_008() - { - CPPUNIT_ASSERT_MESSAGE( "oldpath and newpath are not on the same filesystem, should error returns", - ::osl::FileBase::E_None == nError1 ); - } //bugid# 115420, after the bug fix, add the case - void move_009() - { - //create directory $TEMP/tmpname. - createTestDirectory( aTmpName6 ); - //create directory $TEMP/tmpname/tmpdir - createTestDirectory( aTmpName8 ); - //move directory $TEMP/tmpname to $TEMP/tmpname/tmpdir/tmpname - rtl::OUString newName = aTmpName8 + "/tmpname"; - nError1 = ::osl::File::move( aTmpName3, newName ); - //deleteTestDirectory( newName + "/tmpname" ); - //deleteTestDirectory( newName ); - deleteTestDirectory( aTmpName8 ); - deleteTestDirectory( aTmpName6 ); - CPPUNIT_ASSERT_MESSAGE( "test for move function: move a directory to it's subdirectory", - ::osl::FileBase::E_None != nError1 ); - } - CPPUNIT_TEST_SUITE( move ); CPPUNIT_TEST( move_001 ); CPPUNIT_TEST( move_002 ); @@ -4337,8 +3229,6 @@ namespace osl_File CPPUNIT_TEST( move_005 ); CPPUNIT_TEST( move_006 ); CPPUNIT_TEST( move_007 ); - // CPPUNIT_TEST( move_008 ); - //CPPUNIT_TEST( move_009 ); CPPUNIT_TEST_SUITE_END(); };// class move diff --git a/sal/qa/osl/module/osl_Module.cxx b/sal/qa/osl/module/osl_Module.cxx index 43387045af37..1612662cbeee 100644 --- a/sal/qa/osl/module/osl_Module.cxx +++ b/sal/qa/osl/module/osl_Module.cxx @@ -27,27 +27,6 @@ using ::rtl::OUString; using ::rtl::OUStringToOString; using ::rtl::OString; -// helper functions and classes - -/** print Boolean value. -*/ -inline void printBool( bool bOk ) -{ - printf("#printBool# " ); - bOk ? printf( "TRUE!\n" ) : printf( "FALSE!\n" ); -} - -/** print a UNI_CODE String. -*/ -inline void printUString( const ::rtl::OUString & str ) -{ - rtl::OString aString; - - printf("#printUString_u# " ); - aString = ::rtl::OUStringToOString( str, RTL_TEXTENCODING_ASCII_US ); - printf("%s\n", aString.getStr( ) ); -} - /** get dll file URL. */ inline ::rtl::OUString getDllURL( void ) @@ -66,81 +45,6 @@ inline ::rtl::OUString getDllURL( void ) return dllPath; } -inline bool isURL( const ::rtl::OUString& pathname ) -{ - return pathname.startsWith( "file:///" ); -} - -/** create a temp test directory using OUString name of full qualified URL or system path. -*/ -inline void createTestDirectory( const ::rtl::OUString& dirname ) -{ - ::rtl::OUString aPathURL = dirname.copy( 0 ); - ::osl::FileBase::RC nError; - - if ( !isURL( dirname ) ) - ::osl::FileBase::getFileURLFromSystemPath( dirname, aPathURL ); //convert if not full qualified URL - nError = ::osl::Directory::create( aPathURL ); - CPPUNIT_ASSERT_MESSAGE( "In createTestDirectory Function: creation: ", ( ::osl::FileBase::E_None == nError ) || ( nError == ::osl::FileBase::E_EXIST ) ); -} - -/** delete a temp test directory using OUString name of full qualified URL or system path. -*/ -inline void deleteTestDirectory( const ::rtl::OUString& dirname ) -{ - ::rtl::OUString aPathURL = dirname.copy( 0 ); - ::osl::FileBase::RC nError; - if ( !isURL( dirname ) ) - ::osl::FileBase::getFileURLFromSystemPath( dirname, aPathURL ); //convert if not full qualified URL - - ::osl::Directory testDir( aPathURL ); - if ( testDir.isOpen( ) ) - { - testDir.close( ); //close if still open. - } - - nError = ::osl::Directory::remove( aPathURL ); - CPPUNIT_ASSERT_MESSAGE( "In deleteTestDirectory function: remove ", ( ::osl::FileBase::E_None == nError ) || ( nError == ::osl::FileBase::E_NOENT ) ); -} - -//check if the file exist -inline bool ifFileExist( const ::rtl::OUString & str ) -{ - ::rtl::OUString aUStr; - if ( isURL( str ) ) - ::osl::FileBase::getSystemPathFromFileURL( str, aUStr ); - else - return false; - - ::osl::File strFile( aUStr ); - ::osl::FileBase::RC nError = strFile.open( osl_File_OpenFlag_Read ); - if ( ::File::E_NOENT == nError ) - return false; - else{ - strFile.close( ); - return true; - } -} - -/** detete a temp test file using OUString name. -*/ -inline void deleteTestFile( const ::rtl::OUString& filename ) -{ - ::rtl::OUString aPathURL = filename.copy( 0 ); - ::osl::FileBase::RC nError; - - if ( !isURL( filename ) ) - ::osl::FileBase::getFileURLFromSystemPath( filename, aPathURL ); //convert if not full qualified URL - - nError = ::osl::File::setAttributes( aPathURL, osl_File_Attribute_GrpWrite| osl_File_Attribute_OwnWrite| osl_File_Attribute_OthWrite ); // if readonly, make writtenable. - CPPUNIT_ASSERT_MESSAGE( "In deleteTestFile Function: set writtenable ", ( ::osl::FileBase::E_None == nError ) || ( ::osl::FileBase::E_NOENT == nError ) ); - - nError = ::osl::File::remove( aPathURL ); - CPPUNIT_ASSERT_MESSAGE( "In deleteTestFile Function: remove ", ( ::osl::FileBase::E_None == nError ) || ( nError == ::osl::FileBase::E_NOENT ) ); -} - -// test code start here - namespace osl_Module { diff --git a/sal/qa/osl/mutex/osl_Mutex.cxx b/sal/qa/osl/mutex/osl_Mutex.cxx index e06acee5e542..e0747f337bf6 100644 --- a/sal/qa/osl/mutex/osl_Mutex.cxx +++ b/sal/qa/osl/mutex/osl_Mutex.cxx @@ -29,27 +29,6 @@ using namespace osl; using namespace rtl; -// helper functions - -/** print a UNI_CODE String. -*/ -inline void printUString( const ::rtl::OUString & str ) -{ - rtl::OString aString; - - printf("#printUString_u# " ); - aString = ::rtl::OUStringToOString( str, RTL_TEXTENCODING_ASCII_US ); - printf("%s\n", aString.getStr( ) ); -} - -/** print Boolean value. -*/ -inline void printBool( bool bOk ) -{ - printf("#printBool# " ); - bOk ? printf("YES!\n" ): printf("NO!\n" ); -} - /** pause nSec seconds helper function. */ namespace ThreadHelper @@ -848,6 +827,7 @@ namespace osl_ResettableGuard bRes && bRes1 ); } +#ifdef LINUX void reset_002( ) { Mutex aMutex; @@ -864,6 +844,7 @@ namespace osl_ResettableGuard 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 ); } +#endif CPPUNIT_TEST_SUITE(reset); CPPUNIT_TEST(reset_001); diff --git a/sal/qa/osl/process/osl_Thread.cxx b/sal/qa/osl/process/osl_Thread.cxx index 4778ea1989ca..f5f43140e2eb 100644 --- a/sal/qa/osl/process/osl_Thread.cxx +++ b/sal/qa/osl/process/osl_Thread.cxx @@ -326,53 +326,6 @@ public: }; -/** call suspend in the run method -*/ -class OSuspendThread : public Thread -{ - ThreadSafeValue m_aFlag; -public: - OSuspendThread(){ m_bSuspend = false; } - sal_Int32 getValue() { return m_aFlag.getValue(); } - void setSuspend() - { - m_bSuspend = true; - } - virtual void SAL_CALL suspend() SAL_OVERRIDE - { - m_aFlag.acquire(); - ::osl::Thread::suspend(); - m_aFlag.release(); - } -protected: - bool m_bSuspend; - void SAL_CALL run() SAL_OVERRIDE - { - //if the thread should terminate, schedule return false - while (schedule()) - { - m_aFlag.addValue(1); - - ThreadHelper::thread_sleep_tenth_sec(1); - if (m_bSuspend) - { - suspend(); - m_bSuspend = false; - } - } - } -public: - - virtual ~OSuspendThread() - { - if (isRunning()) - { - t_print("error: not terminated.\n"); - } - } - -}; - /** no call schedule in the run method */ class ONoScheduleThread : public Thread @@ -686,46 +639,6 @@ namespace osl_Thread ); } - /** suspend a thread in it's worker-function, the ALGORITHM is same as suspend_001 - reason of deadlocked I think: no schedule can schedule other threads to go on excuting - */ - void suspend_002() - { - OSuspendThread* aThread = new OSuspendThread(); - bool bRes = aThread->create(); - CPPUNIT_ASSERT_MESSAGE ( "Can't start thread!", bRes ); - // first the thread run for some seconds, but not terminate - sal_Int32 nValue = 0; - //while (1) - //{ - ThreadHelper::thread_sleep_tenth_sec(3); - nValue = aThread->getValue(); // (1) - t_print(" getValue is %d !", (int) nValue ); - if (nValue >= 2) - { - aThread->setSuspend(); - //break; - } - //} - t_print(" after while!"); - // the value just after calling suspend - nValue = aThread->getValue(); // (2) - - ThreadHelper::thread_sleep_tenth_sec(3); - t_print(" after sleep!"); - // the value after waiting 3 seconds - sal_Int32 nLaterValue = aThread->getValue(); // (3) - - //resumeAndWaitThread(aThread); - aThread->resume(); - termAndJoinThread(aThread); - delete aThread; - - CPPUNIT_ASSERT_MESSAGE( - "Suspend the thread", - bRes && nValue == nLaterValue - ); - } CPPUNIT_TEST_SUITE(suspend); CPPUNIT_TEST(suspend_001); @@ -1632,13 +1545,8 @@ namespace osl_Thread } - void getCurrentIdentifier_002() - { - } - CPPUNIT_TEST_SUITE(getCurrentIdentifier); CPPUNIT_TEST(getCurrentIdentifier_001); - //CPPUNIT_TEST(getCurrentIdentifier_002); CPPUNIT_TEST_SUITE_END(); }; // class getCurrentIdentifier diff --git a/sal/qa/osl/process/osl_process.cxx b/sal/qa/osl/process/osl_process.cxx index db6d19c382ff..79e728324019 100644 --- a/sal/qa/osl/process/osl_process.cxx +++ b/sal/qa/osl/process/osl_process.cxx @@ -26,8 +26,6 @@ #include #include -#define t_print printf - #include #include #include @@ -76,17 +74,6 @@ using ::rtl::OUString; using ::rtl::OUStringToOString; using ::rtl::OString; -/** print a UNI_CODE String. -*/ -inline void printUString( const ::rtl::OUString & str ) -{ - rtl::OString aString; - - t_print("#printUString_u# " ); - aString = ::rtl::OUStringToOString( str, RTL_TEXTENCODING_ASCII_US ); - t_print("%s\n", aString.getStr( ) ); -} - /** get binary Path. */ inline ::rtl::OUString getExecutablePath( void ) @@ -101,211 +88,6 @@ inline ::rtl::OUString getExecutablePath( void ) //rtl::OUString CWD = getExecutablePath(); -class Test_osl_joinProcess : public CppUnit::TestFixture -{ - const OUString join_param_; - const OUString wait_time_; - OUString suCWD; - OUString suExecutableFileURL; - - rtl_uString* parameters_[2]; - int parameters_count_; - -public: - - Test_osl_joinProcess() : - join_param_(OUString("-join")), - wait_time_(OUString("1")), - parameters_count_(2) - { - parameters_[0] = join_param_.pData; - parameters_[1] = wait_time_.pData; - suCWD = getExecutablePath(); - suExecutableFileURL = suCWD; - suExecutableFileURL += rtl::OUString("/"); - suExecutableFileURL += EXECUTABLE_NAME; - } - - /*------------------------------------- - Start a process and join with this - process specify a timeout so that - osl_joinProcessWithTimeout returns - osl_Process_E_TimedOut - -------------------------------------*/ - - void osl_joinProcessWithTimeout_timeout_failure() - { - oslProcess process; - oslSecurity security = osl_getCurrentSecurity(); - oslProcessError osl_error = osl_executeProcess( - suExecutableFileURL.pData, - parameters_, - parameters_count_, - osl_Process_NORMAL, - security, - suCWD.pData, - NULL, - 0, - &process); - osl_freeSecurityHandle(security); - - CPPUNIT_ASSERT_EQUAL_MESSAGE - ( - "osl_createProcess failed", - osl_Process_E_None, osl_error - ); - - TimeValue timeout; - timeout.Seconds = 1; - timeout.Nanosec = 0; - - osl_error = osl_joinProcessWithTimeout(process, &timeout); - - CPPUNIT_ASSERT_EQUAL_MESSAGE - ( - "osl_joinProcessWithTimeout returned without timeout failure", - osl_Process_E_TimedOut, osl_error - ); - - osl_error = osl_terminateProcess(process); - - CPPUNIT_ASSERT_EQUAL_MESSAGE - ( - "osl_terminateProcess failed", - osl_Process_E_None, osl_error - ); - - osl_freeProcessHandle(process); - } - - /*------------------------------------- - Start a process and join with this - process specify a timeout so that - osl_joinProcessWithTimeout returns - osl_Process_E_None - -------------------------------------*/ - - void osl_joinProcessWithTimeout_without_timeout_failure() - { - oslProcess process; - oslSecurity security = osl_getCurrentSecurity (); - oslProcessError osl_error = osl_executeProcess( - suExecutableFileURL.pData, - parameters_, - parameters_count_, - osl_Process_NORMAL, - security, - suCWD.pData, - NULL, - 0, - &process); - osl_freeSecurityHandle(security); - - CPPUNIT_ASSERT_EQUAL_MESSAGE - ( - "osl_createProcess failed", - osl_Process_E_None, osl_error - ); - - TimeValue timeout; - timeout.Seconds = 10; - timeout.Nanosec = 0; - - osl_error = osl_joinProcessWithTimeout(process, &timeout); - - CPPUNIT_ASSERT_EQUAL_MESSAGE - ( - "osl_joinProcessWithTimeout returned with failure", - osl_Process_E_None, osl_error - ); - - osl_freeProcessHandle(process); - } - - /*------------------------------------- - Start a process and join with this - process specify an infinite timeout - -------------------------------------*/ - - void osl_joinProcessWithTimeout_infinite() - { - oslProcess process; - oslSecurity security = osl_getCurrentSecurity (); - oslProcessError osl_error = osl_executeProcess( - suExecutableFileURL.pData, - parameters_, - parameters_count_, - osl_Process_NORMAL, - security, - suCWD.pData, - NULL, - 0, - &process); - osl_freeSecurityHandle(security); - - CPPUNIT_ASSERT_EQUAL_MESSAGE - ( - "osl_createProcess failed", - osl_Process_E_None, osl_error - ); - - osl_error = osl_joinProcessWithTimeout(process, NULL); - - CPPUNIT_ASSERT_EQUAL_MESSAGE - ( - "osl_joinProcessWithTimeout returned with failure", - osl_Process_E_None, osl_error - ); - - osl_freeProcessHandle(process); - } - - /*------------------------------------- - Start a process and join with this - process using osl_joinProcess - -------------------------------------*/ - - void osl_joinProcess() - { - oslProcess process; - oslSecurity security = osl_getCurrentSecurity (); - oslProcessError osl_error = osl_executeProcess( - suExecutableFileURL.pData, - parameters_, - parameters_count_, - osl_Process_NORMAL, - security, - suCWD.pData, - NULL, - 0, - &process); - osl_freeSecurityHandle(security); - - CPPUNIT_ASSERT_EQUAL_MESSAGE - ( - "osl_createProcess failed", - osl_Process_E_None, osl_error - ); - - osl_error = ::osl_joinProcess(process); - - CPPUNIT_ASSERT_EQUAL_MESSAGE - ( - "osl_joinProcess returned with failure", - osl_Process_E_None, osl_error - ); - - osl_freeProcessHandle(process); - } - - CPPUNIT_TEST_SUITE(Test_osl_joinProcess); - CPPUNIT_TEST(osl_joinProcessWithTimeout_timeout_failure); - CPPUNIT_TEST(osl_joinProcessWithTimeout_without_timeout_failure); - CPPUNIT_TEST(osl_joinProcessWithTimeout_infinite); - CPPUNIT_TEST(osl_joinProcess); - CPPUNIT_TEST_SUITE_END(); -}; - typedef std::vector > string_container_t; typedef string_container_t::const_iterator string_container_const_iter_t; typedef string_container_t::iterator string_container_iter_t; @@ -684,42 +466,6 @@ public: osl_freeProcessHandle(process); } - void osl_execProc_exe_name_in_argument_list() - { - rtl_uString* params[3]; - - params[0] = suExecutableFileURL.pData; - params[1] = env_param_.pData; - params[2] = temp_file_path_.pData; - oslProcess process; - oslProcessError osl_error = osl_executeProcess( - NULL, - params, - 3, - osl_Process_NORMAL, - NULL, - suCWD.pData, - NULL, - 0, - &process); - - CPPUNIT_ASSERT_EQUAL_MESSAGE - ( - "osl_createProcess failed", - osl_Process_E_None, osl_error - ); - - osl_error = ::osl_joinProcess(process); - - CPPUNIT_ASSERT_EQUAL_MESSAGE - ( - "osl_joinProcess returned with failure", - osl_Process_E_None, osl_error - ); - - osl_freeProcessHandle(process); - } - CPPUNIT_TEST_SUITE(Test_osl_executeProcess); //TODO: Repair these under windows. #ifndef WNT @@ -728,12 +474,9 @@ public: #endif CPPUNIT_TEST(osl_execProc_test_batch); ///TODO: Repair test (or tested function ;-) - test fails. - // CPPUNIT_TEST(osl_execProc_exe_name_in_argument_list); CPPUNIT_TEST_SUITE_END(); }; -// register test suites -//CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(Test_osl_joinProcess, "Test_osl_joinProcess"); CPPUNIT_TEST_SUITE_REGISTRATION(Test_osl_executeProcess); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sal/qa/osl/security/osl_Security.cxx b/sal/qa/osl/security/osl_Security.cxx index 14e339e027ef..15089c3c5a6b 100644 --- a/sal/qa/osl/security/osl_Security.cxx +++ b/sal/qa/osl/security/osl_Security.cxx @@ -31,16 +31,6 @@ using namespace osl; using namespace rtl; -// helper functions and classes - -/** print Boolean value. -*/ -inline void printBool( bool bOk ) -{ - //t_print("#printBool# " ); - bOk ? t_print("TRUE!\n" ): t_print("FALSE!\n" ); -} - /** print a UNI_CODE String. */ inline void printUString( const ::rtl::OUString & str ) diff --git a/sal/qa/rtl/oustring/rtl_OUString2.cxx b/sal/qa/rtl/oustring/rtl_OUString2.cxx index 0628d504d9c7..849c5215dd16 100644 --- a/sal/qa/rtl/oustring/rtl_OUString2.cxx +++ b/sal/qa/rtl/oustring/rtl_OUString2.cxx @@ -31,48 +31,9 @@ #include "stringhelper.hxx" #include "valueequal.hxx" -inline void printOUString( ::rtl::OUString const & _suStr ) -{ - rtl::OString aString; - - printf( "OUString: " ); - aString = ::rtl::OUStringToOString( _suStr, RTL_TEXTENCODING_ASCII_US ); - printf( "'%s'\n", aString.getStr( ) ); -} - namespace rtl_OUString { - class ctors_rtl_uString : public CppUnit::TestFixture - { - - public: - /// test of OUString(rtl_uString*) - void ctors_001() - { - rtl::OUString *pStr = new rtl::OUString( "a String" ); - - rtl::OUString aStrToTest(pStr->pData); - delete pStr; - - // maybe here should we do something with current memory - char* pBuffer = (char*) malloc(2 * 8); - memset(pBuffer, 0, 2 * 8); - free(pBuffer); - - bool bResult = aStrToTest == "a String"; - CPPUNIT_ASSERT_MESSAGE("String must not be empty", bResult); - } - - // Change the following lines only, if you add, remove or rename - // member functions of the current class, - // because these macros are need by auto register mechanism. - - CPPUNIT_TEST_SUITE(ctors_rtl_uString); - CPPUNIT_TEST(ctors_001); - CPPUNIT_TEST_SUITE_END(); - }; - class number : public CppUnit::TestFixture { void number_float_test_impl(float _nValue) @@ -306,25 +267,6 @@ sal_Int16 SAL_CALL checkPrecisionSize() return i; } - class testPrecision - { - public: - testPrecision() - { - sal_Int16 nPrecision; - nPrecision = checkPrecisionSize(); - printf("precision of float: %d sizeof()=%" SAL_PRI_SIZET "d\n", nPrecision, sizeof(float)); - - nPrecision = checkPrecisionSize(); - printf("precision of double: %d sizeof()=%" SAL_PRI_SIZET "d\n", nPrecision, sizeof(double)); - - nPrecision = checkPrecisionSize(); - printf("precision of long double: %d sizeof()=%" SAL_PRI_SIZET "d\n", nPrecision, sizeof(long double)); - - } - - }; - class toInt: public CppUnit::TestFixture { public: void test() { @@ -1191,7 +1133,7 @@ class convertFromString: public CppUnit::TestFixture { public: void test(); - CPPUNIT_TEST_SUITE(createFromCodePoints); + CPPUNIT_TEST_SUITE(convertFromString); CPPUNIT_TEST(test); CPPUNIT_TEST_SUITE_END(); }; diff --git a/sal/qa/rtl/uri/rtl_Uri.cxx b/sal/qa/rtl/uri/rtl_Uri.cxx index 7465215a1d7b..016bb2ca4620 100644 --- a/sal/qa/rtl/uri/rtl_Uri.cxx +++ b/sal/qa/rtl/uri/rtl_Uri.cxx @@ -34,12 +34,6 @@ namespace Stringtest { rtl::OUString m_aStr; public: - rtl::OUString fromUTF8(rtl::OString const& _suStr) - { - rtl::OUString suStr = rtl::OStringToOUString(_suStr, RTL_TEXTENCODING_UTF8); - return suStr; - } - rtl::OString convertToOString(rtl::OUString const& _suStr) { return rtl::OUStringToOString(_suStr, osl_getThreadTextEncoding()/*RTL_TEXTENCODING_ASCII_US*/); @@ -51,40 +45,6 @@ namespace Stringtest printf("%s\n", sStr.getStr()); } - void toUTF8_mech(rtl::OUString const& _suStr, rtl_UriEncodeMechanism _eMechanism) - { - rtl::OUString suStr; - suStr = rtl::Uri::encode(_suStr, rtl_UriCharClassNone, _eMechanism, RTL_TEXTENCODING_UTF8); - showContent(suStr); - suStr = rtl::Uri::encode(_suStr, rtl_UriCharClassUric, _eMechanism, RTL_TEXTENCODING_UTF8); - showContent(suStr); - suStr = rtl::Uri::encode(_suStr, rtl_UriCharClassUricNoSlash, _eMechanism, RTL_TEXTENCODING_UTF8); - showContent(suStr); - suStr = rtl::Uri::encode(_suStr, rtl_UriCharClassRelSegment, _eMechanism, RTL_TEXTENCODING_UTF8); - showContent(suStr); - suStr = rtl::Uri::encode(_suStr, rtl_UriCharClassRegName, _eMechanism, RTL_TEXTENCODING_UTF8); - showContent(suStr); - suStr = rtl::Uri::encode(_suStr, rtl_UriCharClassUserinfo, _eMechanism, RTL_TEXTENCODING_UTF8); - showContent(suStr); - suStr = rtl::Uri::encode(_suStr, rtl_UriCharClassPchar, _eMechanism, RTL_TEXTENCODING_UTF8); - showContent(suStr); - suStr = rtl::Uri::encode(_suStr, rtl_UriCharClassUnoParamValue, _eMechanism, RTL_TEXTENCODING_UTF8); - showContent(suStr); - } - - void toUTF8(rtl::OUString const& _suStr) - { - printf("rtl_UriEncodeIgnoreEscapes \n"); - toUTF8_mech(_suStr, rtl_UriEncodeIgnoreEscapes); - printf("\n"); - printf("# rtl_UriEncodeKeepEscapes\n"); - toUTF8_mech(_suStr, rtl_UriEncodeKeepEscapes); - printf("\n"); - printf("# rtl_UriEncodeCheckEscapes\n"); - toUTF8_mech(_suStr, rtl_UriEncodeCheckEscapes); - printf("\n"); - } - void test_FromUTF8_001() { // string --> ustring @@ -109,127 +69,8 @@ namespace Stringtest // suStr should be equal to suStr2 } - // "%C3%84qypten"; - // testshl2 ../../../unxlngi4.pro/lib/libConvert.so "-onlyerrors" - // # Type: 'Directory' file name '%E6%89%8B%E6%9C%BA%E5%8F%B7%E7%A0%81' - // # Type: 'Directory' file name '%E6%9C%AA%E5%91%BD%E5%90%8Dzhgb18030' - // # Type: 'Regular file' file name '%E5%B7%A5%E4%BD%9C' - // # Type: 'Regular file' file name '%E4%BA%8C%E6%89%8B%E6%88%BF%E4%B9%B0%E5%8D%96%E5%90%88%E5%90%8C%E8%8D%89%E7%A8%BF.doc' - // ls - rtl::OString getFileTypeName(osl::FileStatus const& _aStatus) - { - rtl::OString sType; - if (_aStatus.isValid(osl_FileStatus_Mask_Type)) - { - osl::FileStatus::Type aType = _aStatus.getFileType(); - if (aType == osl::FileStatus::Directory) - { - sType = "Directory"; - } - else if (aType == osl::FileStatus::Regular) - { - sType = "Regular file"; - } - else if (aType == osl::FileStatus::Volume) - { - sType = "Volume"; - } - else if (aType == osl::FileStatus::Fifo) - { - sType = "Fifo"; - } - else if (aType == osl::FileStatus::Socket) - { - sType = "Socket"; - } - else if (aType == osl::FileStatus::Link) - { - sType = "Link"; - } - else if (aType == osl::FileStatus::Special) - { - sType = "Special"; - } - else if (aType == osl::FileStatus::Unknown) - { - sType = "Unknown"; - } - else - { - sType = "Not handled yet"; - } - } - else - { - sType = "ERROR: osl_FileStatus_Mask_Type not set for FileStatus!"; - } - return sType; - } - - void test_UTF8_files() - { -#ifdef UNX - rtl::OUString suDirURL(rtl::OUString("file:///tmp/atestdir")); -#else /* Windows */ - rtl::OUString suDirURL(rtl::OUString("file:///c:/temp/atestdir")); -#endif - osl::Directory aDir(suDirURL); - aDir.open(); - if (aDir.isOpen()) - { - osl::DirectoryItem aItem; - osl::FileStatus aStatus(osl_FileStatus_Mask_FileName | osl_FileStatus_Mask_Attributes | osl_FileStatus_Mask_Type); - while (aDir.getNextItem(aItem) == ::osl::FileBase::E_None) - { - if (osl::FileBase::E_None == aItem.getFileStatus(aStatus) && - aStatus.isValid(osl_FileStatus_Mask_FileName | osl_FileStatus_Mask_Attributes)) - { - rtl::OString sType = getFileTypeName(aStatus); - - rtl::OUString suFilename = aStatus.getFileName(); - // rtl::OUString suFullFileURL; - - rtl::OUString suStrUTF8 = rtl::Uri::encode(suFilename, rtl_UriCharClassUnoParamValue, rtl_UriEncodeKeepEscapes, RTL_TEXTENCODING_UTF8); - rtl::OString sStrUTF8 = convertToOString(suStrUTF8); - printf("Type: '%s' file name '%s'\n", sType.getStr(), sStrUTF8.getStr()); - } - } - aDir.close(); - } - else - { - rtl::OString sStr; - sStr = rtl::OUStringToOString(suDirURL, osl_getThreadTextEncoding()); - printf("can't open dir:'%s'\n", sStr.getStr()); - } - } - - void test_FromUTF8() - { - rtl::OString sStr("h%C3%A4llo"); - rtl::OUString suStr = rtl::OStringToOUString(sStr, osl_getThreadTextEncoding()); - -// rtl_UriEncodeIgnoreEscapes, -// rtl_UriEncodeKeepEscapes, -// rtl_UriEncodeCheckEscapes, -// rtl::OUString suStr2 = rtl::Uri::encode(suStr, rtl_UriCharClassRegName, rtl_UriEncodeCheckEscapes, RTL_TEXTENCODING_UTF8); - rtl::OUString suStr_UriDecodeNone = rtl::Uri::decode(suStr, rtl_UriDecodeNone, RTL_TEXTENCODING_UTF8); - showContent(suStr_UriDecodeNone); - toUTF8(suStr_UriDecodeNone); - - rtl::OUString suStr_UriDecodeToIuri = rtl::Uri::decode(suStr, rtl_UriDecodeToIuri, RTL_TEXTENCODING_UTF8); - showContent(suStr_UriDecodeToIuri); - toUTF8(suStr_UriDecodeToIuri); - - rtl::OUString suStr_UriDecodeWithCharset = rtl::Uri::decode(suStr, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8); - showContent(suStr_UriDecodeWithCharset); - toUTF8(suStr_UriDecodeWithCharset); - } - CPPUNIT_TEST_SUITE( Convert ); CPPUNIT_TEST( test_FromUTF8_001 ); -// CPPUNIT_TEST( test_UTF8_files ); -// CPPUNIT_TEST( test_FromUTF8 ); CPPUNIT_TEST_SUITE_END( ); }; diff --git a/sal/qa/rtl/uuid/rtl_Uuid.cxx b/sal/qa/rtl/uuid/rtl_Uuid.cxx index 56c3e41e8f4c..d20c38a67ad9 100644 --- a/sal/qa/rtl/uuid/rtl_Uuid.cxx +++ b/sal/qa/rtl/uuid/rtl_Uuid.cxx @@ -35,40 +35,9 @@ #include #endif -#define t_print printf - using ::rtl::OUString; using ::rtl::OUStringToOString; using ::rtl::OString; -/** print a UNI_CODE String. And also print some comments of the string. -*/ -inline void printUString( const ::rtl::OUString & str, const sal_Char * msg = "" ) -{ - t_print("#%s #printUString_u# ", msg ); - rtl::OString aString; - aString = ::rtl::OUStringToOString( str, RTL_TEXTENCODING_ASCII_US ); - t_print("%s\n", (char *)aString.getStr( ) ); -} - -/************************************************************************ - * For diagnostics( from sal/test/testuuid.cxx ) - ************************************************************************/ - -void printUuid( sal_uInt8 *pNode ) -{ - for( sal_Int32 i1 = 0 ; i1 < 4 ; i1++ ) - { - for( sal_Int32 i2 = 0 ; i2 < 4 ; i2++ ) - { - printf( "%02x" , pNode[i1*4 +i2] ); - } - if( i1 == 3 ) - break; - printf( "-" ); - } - - printf( "\n# " ); -} namespace rtl_Uuid { -- cgit v1.2.3