summaryrefslogtreecommitdiff
path: root/sal/workben/testfile.cxx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2010-11-23 16:30:46 +0000
committerCaolán McNamara <caolanm@redhat.com>2010-11-23 16:33:02 +0000
commit924908a09bfc917a6d8d1117b757c0b262f0d1cb (patch)
tree850fd74f7380976588cfaae104c520c234431a03 /sal/workben/testfile.cxx
parenta8a1b8d0fc1bb172d8dd9d7de2bec013fa24fc76 (diff)
make more of the workbens build, and add performance test
Diffstat (limited to 'sal/workben/testfile.cxx')
-rw-r--r--sal/workben/testfile.cxx83
1 files changed, 49 insertions, 34 deletions
diff --git a/sal/workben/testfile.cxx b/sal/workben/testfile.cxx
index 10c48b4f0994..d92522fa07ca 100644
--- a/sal/workben/testfile.cxx
+++ b/sal/workben/testfile.cxx
@@ -72,17 +72,17 @@ rtl::OUString file_not_exist;
-void print_error(::rtl::OString& str, FileBase::RC rc);
+void print_error(const ::rtl::OString& str, FileBase::RC rc);
void PressKey()
{
printf("\nPress Return !\n");
- int i=getchar();
+ getchar();
}
-void printFileName(::rtl::OUString& str)
+void printFileName(const ::rtl::OUString& str)
{
- rtl::OString aString;
+ rtl::OString aString;
aString = rtl::OUStringToOString( str, RTL_TEXTENCODING_ASCII_US );
@@ -208,13 +208,13 @@ sal_Bool Initialize( void )
for ( int i=0 ; i<12 ; i++ )
{
sal_uInt32 cLineBrake=0;
- while ( (pCount-pBuffer < uBytesRead) && *pCount!='=')
+ while ( (static_cast<sal_uInt64>(pCount-pBuffer) < uBytesRead) && *pCount!='=')
pCount++;
pCount++;
pBegin=pCount;
- while ( (pCount-pBuffer < uBytesRead) && !testLineBreak(pCount,uBytesRead-(pCount-pBuffer), &cLineBrake))
+ while ( (static_cast<sal_uInt64>(pCount-pBuffer) < uBytesRead) && !testLineBreak(pCount,uBytesRead-(pCount-pBuffer), &cLineBrake))
pCount++;
dir[i]=rtl::OUString(pBegin, pCount-pBegin, RTL_TEXTENCODING_ASCII_US);
@@ -460,7 +460,6 @@ TimeValue getSystemTime()
void DirectoryOpenAndCloseTest( void )
{
FileBase::RC rc;
- int i=0;
Directory *pDir;
printf( "--------------------------------------------\n");
@@ -585,7 +584,6 @@ void DirectoryOpenAndCloseTest( void )
void DirectoryCreateAndRemoveTest( void )
{
FileBase::RC rc,rc1;
- int i=0;
Directory *pDir;
printf( "--------------------------------------------\n" );
@@ -673,7 +671,6 @@ void DirectoryCreateAndRemoveTest( void )
static void FileOpenAndCloseTest( void )
{
FileBase::RC rc;
- int i=0;
printf( "--------------------------------------------\n" );
printf( "File-Open-And-Close-Test\n" );
@@ -806,7 +803,7 @@ void FileWriteAndReadTest( void )
sal_uInt64 uWritten;
sal_uInt64 uRead;
- sal_Char *pWriteBuffer="Hier kommt der Osterhase !";
+ const sal_Char *pWriteBuffer="Hier kommt der Osterhase !";
sal_uInt64 nLen=strlen( pWriteBuffer );
sal_Char *pReadBuffer;
@@ -947,7 +944,9 @@ void FileCopyAndMoveTest( void )
destPath+=file3;
printf( "Copy a file to a not existing directory \n");
- printf( "Copy the file %s to %s\n", file1.getStr(), destPath.getStr() );
+ printf( "Copy the file %s to %s\n",
+ rtl::OUStringToOString( file1, RTL_TEXTENCODING_ASCII_US ).getStr(),
+ rtl::OUStringToOString( destPath, RTL_TEXTENCODING_ASCII_US ).getStr() );
rc=File::copy( file1, destPath );
print_error( rtl::OString( "FileCopy" ), rc );
@@ -1120,9 +1119,9 @@ void FileSizeTest( void )
filesize=rStatus.getFileSize();
if ( filesize == 5000 )
- printf( "\nOK : FileSize: %i\n", filesize );
+ printf( "\nOK : FileSize: %" SAL_PRIuUINT64 "\n", filesize );
else
- printf( "\nError : FileSize: %i\n", filesize );
+ printf( "\nError : FileSize: %" SAL_PRIuUINT64 "\n", filesize );
}
}
@@ -1186,7 +1185,7 @@ void FilePointerTest( void )
rc =rFile.getPos( filepointer );
print_error( rtl::OString( "GetPos" ), rc );
- printf( "Position of the FilePointer: %i\n", filepointer );
+ printf( "Position of the FilePointer: %" SAL_PRIuUINT64 "\n", filepointer );
printf( "\n" );
@@ -1207,13 +1206,13 @@ void FilePointerTest( void )
{
print_error( rtl::OString( "GetPos" ), rc );
printf( "\nVerify: OK !\n" );
- printf( "Filepointer-Position: %llu\n",filepointer );
+ printf( "Filepointer-Position: %" SAL_PRIuUINT64 "\n",filepointer );
}
else
{
print_error( rtl::OString( "GetPos" ), rc );
printf( "\nFilePointer-Test: Error\n" );
- printf( "Filepointer-Position: %i != 5000 \n",filepointer );
+ printf( "Filepointer-Position: %" SAL_PRIuUINT64 " != 5000 \n",filepointer );
}
printf( "\n" );
@@ -1432,9 +1431,29 @@ void FileTimeTest( void )
DirectoryItem aItem;
- struct tm sSysCreationTime = { 0, 20, 12, 4, 9, 100 };
- struct tm sSysAccessTime = { 0, 40, 1, 6, 5, 98 };
- struct tm sSysModifyTime = { 0, 1, 24, 13, 11, 95 };
+ struct tm sSysCreationTime;
+ sSysCreationTime.tm_sec = 0;
+ sSysCreationTime.tm_min = 20;
+ sSysCreationTime.tm_hour = 12;
+ sSysCreationTime.tm_mday = 4;
+ sSysCreationTime.tm_mon = 9;
+ sSysCreationTime.tm_year = 99;
+
+ struct tm sSysAccessTime;
+ sSysAccessTime.tm_sec = 0;
+ sSysAccessTime.tm_min = 40;
+ sSysAccessTime.tm_hour = 1;
+ sSysAccessTime.tm_mday = 6;
+ sSysAccessTime.tm_mon = 5;
+ sSysAccessTime.tm_year = 98;
+
+ struct tm sSysModifyTime;
+ sSysModifyTime.tm_sec = 0;
+ sSysModifyTime.tm_min = 1;
+ sSysModifyTime.tm_hour = 24;
+ sSysModifyTime.tm_mday = 13;
+ sSysModifyTime.tm_mon = 11;
+ sSysModifyTime.tm_year = 95;
time_t aSysCreationTime = mktime( &sSysCreationTime );
time_t aSysAccessTime = mktime( &sSysAccessTime );
@@ -1660,7 +1679,7 @@ void DirectoryItemTest( void )
printFileName( file1 );
printf( "\n" );
- rc=DirectoryItem::get( *pFile , aItem );
+ rc=DirectoryItem::get( file1 , aItem );
print_error( rtl::OString( "GetDirectoryItem" ), rc );
pStatus=new FileStatus( FileStatusMask_All );
@@ -1683,17 +1702,13 @@ void DirectoryItemTest( void )
printf( "\n" );
//---------------------------------------------------
- // get DirectoryItem from an empty file-handle
+ // get DirectoryItem
//--------------------------------------------------
- pFile=new File( file1 );
-
printf( "Get DirectoryItem from an empty File-Handle\n" );
- rc=DirectoryItem::get( *pFile , aItem );
+ rc=DirectoryItem::get( file1 , aItem );
print_error( rtl::OString( "GetDirectoryItem" ), rc );
- delete pFile;
-
printf( "\n" );
//--------------------------------------------------
@@ -1861,7 +1876,7 @@ void FileStatusTest( FileStatus *pStatus )
printf( "\ngetFileSize:\n" );
FileSize=pStatus->getFileSize();
- printf( "FileSize: %i\n", FileSize);
+ printf( "FileSize: %" SAL_PRIuUINT64 "\n", FileSize);
//--------------------------------------------------
// GetFileName
@@ -2070,7 +2085,7 @@ void VolumeInfoTest( void )
sal_uInt64 TotalSpace;
TotalSpace=rInfo.getTotalSpace();
- printf( "Total Space: %i\n",TotalSpace );
+ printf( "Total Space: %" SAL_PRIuUINT64 "\n",TotalSpace );
//--------------------------------------------------
// getFreeSpace
@@ -2078,7 +2093,7 @@ void VolumeInfoTest( void )
sal_uInt64 FreeSpace;
FreeSpace=rInfo.getFreeSpace();
- printf( "Free Space: %i\n",FreeSpace );
+ printf( "Free Space: %" SAL_PRIuUINT64 "\n",FreeSpace );
//--------------------------------------------------
// getUsedSpace
@@ -2086,7 +2101,7 @@ void VolumeInfoTest( void )
sal_uInt64 UsedSpace;
UsedSpace=rInfo.getUsedSpace();
- printf( "Used Space: %i\n",UsedSpace );
+ printf( "Used Space: %" SAL_PRIuUINT64 "\n",UsedSpace );
//--------------------------------------------------
// getMaxNameLength
@@ -2094,7 +2109,7 @@ void VolumeInfoTest( void )
sal_uInt32 MaxNameLength;
MaxNameLength=rInfo.getMaxNameLength();
- printf( "MaxNameLength: %i\n",MaxNameLength );
+ printf( "MaxNameLength: %" SAL_PRIuUINT32 "\n",MaxNameLength );
//--------------------------------------------------
// getMaxPathLength
@@ -2102,7 +2117,7 @@ void VolumeInfoTest( void )
sal_uInt32 MaxPathLength;
MaxPathLength=rInfo.getMaxPathLength();
- printf( "MaxPathLength: %i\n",MaxPathLength );
+ printf( "MaxPathLength: %" SAL_PRIuUINT32 "\n",MaxPathLength );
//--------------------------------------------------
// getFileSystemName
@@ -2533,10 +2548,10 @@ void CanonicalNameTest(void)
// print_error
//--------------------------------------------------
-void print_error( ::rtl::OString& str, FileBase::RC rc )
+void print_error( const ::rtl::OString& str, FileBase::RC rc )
{
- printf( "%s : ",str.getStr() );
+ printf( "%s : ", str.getStr() );
switch(rc)
{
case FileBase::E_None: