From bfa452a375ea0a0a3f95304a69186936567e5263 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Mon, 14 Aug 2023 19:45:36 +0200 Subject: New upstream version 4.1.4 --- src/tests/xb_test_file.cpp | 209 --------------------------------------------- 1 file changed, 209 deletions(-) delete mode 100755 src/tests/xb_test_file.cpp (limited to 'src/tests/xb_test_file.cpp') diff --git a/src/tests/xb_test_file.cpp b/src/tests/xb_test_file.cpp deleted file mode 100755 index cf835c2..0000000 --- a/src/tests/xb_test_file.cpp +++ /dev/null @@ -1,209 +0,0 @@ -/* xb_test_file.cpp - -Copyright (c) 1997,2003,2014,2022,2023 Gary A Kunkel - -The xb64 software library is covered under the terms of the GPL Version 3, 2007 license. - -Email Contact: - - XDB-devel@lists.sourceforge.net - XDB-users@lists.sourceforge.net - -*/ - -// This program tests the file functions - -// usage: xb_test_file QUITE|NORMAL|VERBOSE - - -#include "xbase.h" - - -using namespace xb; - - -#include "tstfuncs.cpp" - - -int main( int argCnt, char **av ) -{ - int rc = 0; - int po = 1; /* print option */ - /* 0 - QUIET */ - /* 1 - NORMAL */ - /* 2 - VERBOSE */ - - if( argCnt > 1 ) { - if( av[1][0] == 'Q' ) - po = 0; - else if( av[1][0] == 'V' ) - po = 2; - } - xbXBase x; - - #ifdef XB_LOGGING_SUPPORT - x.SetLogDirectory( PROJECT_LOG_DIR ); - x.EnableMsgLogging(); - if( po ){ - std::cout << "Logfile is [" << x.GetLogFqFileName().Str() << "]" << std::endl; - } - xbString sMsg; - sMsg.Sprintf( "Program [%s] initializing...", av[0] ); - x.WriteLogMessage( sMsg ); - #endif - - InitTime(); - xbFile f( &x ); - xbString sWrkStr; - xbString sWrkStr2; - sWrkStr = PROJECT_DATA_DIR; - f.SetDataDirectory( PROJECT_DATA_DIR ); - - #ifdef WIN32 - sWrkStr.SwapChars( '/', '\\' ); - #else - sWrkStr.SwapChars( '\\', '/' ); - #endif - - rc += TestMethod( po, "Set/GetDataDirectory()", f.GetDataDirectory(), sWrkStr, sWrkStr.Len()); - - f.SetFileName( "TestFile.txt" ); - sWrkStr = "TestFile.txt"; - rc += TestMethod( po, "Set/GetFileName()", f.GetFileName(), sWrkStr, sWrkStr.Len()); - - f.GetFileType( sWrkStr ); - rc += TestMethod( po, "GetFileType()", sWrkStr, "TXT", 3 ); - - #ifdef WIN32 - sWrkStr = "\\my\\directory\\"; - #else - sWrkStr = "/my/directory/"; - #endif - - f.SetDirectory( sWrkStr ); - rc += TestMethod( po, "Set/GetDirectory()", f.GetDirectory(), sWrkStr, sWrkStr.Len()); - - sWrkStr += "TestFile.txt"; - rc += TestMethod( po, "GetFqFileName()", f.GetFqFileName(), sWrkStr, 26 ); - - #ifdef WIN32 - sWrkStr = "\\some\\directory\\myfile.dat"; - sWrkStr2 = "\\some\\directory\\"; - #else - sWrkStr = "/some/directory/myfile.dat"; - sWrkStr2 = "/some/directory/"; - #endif - - f.SetFqFileName( sWrkStr ); - rc += TestMethod( po, "GetDirectory()", f.GetDirectory(), sWrkStr2, 16 ); - rc += TestMethod( po, "GetFileName()", f.GetFileName(), "myfile.dat", 10 ); - - rc += TestMethod( po, "NameSuffixMissing()", f.NameSuffixMissing( "myfile.dbf", 1 ), 0 ); - rc += TestMethod( po, "NameSuffixMissing()", f.NameSuffixMissing( "myfile", 1 ), 1 ); - rc += TestMethod( po, "NameSuffixMissing()", f.NameSuffixMissing( "MYFILE", 1 ), 2 ); - - f.SetDirectory( PROJECT_DATA_DIR ); - f.SetFileName( "xbfile.txt" ); - - rc += TestMethod( po, "xbFopen()", f.xbFopen( "w+b", XB_MULTI_USER ), XB_NO_ERROR ); - - xbString sTest; - sTest = "Test Data"; - rc += TestMethod( po, "xbWrite()", f.xbFwrite( sTest.Str(), 9, 1 ), XB_NO_ERROR ); - rc += TestMethod( po, "xbFclose()", f.xbFclose(), XB_NO_ERROR ); - - rc += TestMethod( po, "xbFopen()", f.xbFopen( "r+b", XB_MULTI_USER ), XB_NO_ERROR ); - rc += TestMethod( po, "xbFseek()", f.xbFseek( 0, SEEK_SET ), XB_NO_ERROR ); - char buf[10]; - for( int i = 0; i < 10; i++ ) - buf[i] = 0x00; - rc += TestMethod( po, "xbFread()", f.xbFread( buf, 5, 1 ), XB_NO_ERROR ); - rc += TestMethod( po, "xbFread()", buf, "Test ", 5 ); - - rc += TestMethod( po, "xbFclose()", f.xbFclose(), XB_NO_ERROR ); - rc += TestMethod( po, "xbRemove()", f.xbRemove(), XB_NO_ERROR ); - xbInt16 iWork = 100; - char cBuf[9]; - char *p = cBuf; - f.ePutInt16( cBuf, iWork ); - rc += TestMethod( po, "Put/GetShort()", f.eGetInt16( p ), 100 ); - - xbInt32 lWork = 10101; - f.ePutInt32( p, lWork ); - rc += TestMethod( po, "Put/GetLong()", f.eGetInt32( p ), 10101 ); - - lWork = 2147483647; - f.ePutInt32( p, lWork ); - rc += TestMethod( po, "Put/GetLong()", f.eGetInt32( p ), 2147483647 ); - rc += TestMethod( po, "Put/GetLong()", (xbInt32) f.eGetUInt32( p ), 2147483647 ); - - xbDouble d = 123456.789; - f.ePutDouble( p, d ); - rc += TestMethod( po, "Put/GetDouble()", f.eGetDouble( p ), 123456.789 ); - - xbString sFqnS; - xbString sFqnT; - xbFile f2( &x ); - rc += TestMethod( po, "CreateUniqueFileName()", f2.CreateUniqueFileName( PROJECT_DATA_DIR, "dbf", sFqnS ), XB_NO_ERROR ); - - rc += TestMethod( po, "FileExists()", f2.FileExists( sFqnS ), xbFalse ); - rc += TestMethod( po, "xbFopen()", f2.xbFopen( "w+b", sFqnS, XB_SINGLE_USER ), XB_NO_ERROR ); - rc += TestMethod( po, "xbFclose()", f2.xbFclose(), XB_NO_ERROR ); - rc += TestMethod( po, "FileExists()", f2.FileExists( sFqnS ), xbTrue ); - - rc += TestMethod( po, "CreateUniqueFileName()", f2.CreateUniqueFileName( PROJECT_DATA_DIR, "dbf", sFqnT ), XB_NO_ERROR ); - rc += TestMethod( po, "xbRename()", f2.xbRename( sFqnS, sFqnT ), XB_NO_ERROR ); - rc += TestMethod( po, "xbRemove()", f.xbRemove( sFqnT ), XB_NO_ERROR ); - - xbString sFn; - rc += TestMethod( po, "GetFileNamePart()", f2.GetFileNamePart( sFqnS , sFn ), XB_NO_ERROR ); - rc += TestMethod( po, "GetFileExtPart()", f2.GetFileExtPart( sFqnS , sFn ), XB_NO_ERROR ); - rc += TestMethod( po, "GetFileExtPart()", f2.GetFileDirPart( sFqnS , sFn ), XB_NO_ERROR ); - - rc += TestMethod( po, "SetBlockSize()", f.SetBlockSize( 100 ), XB_INVALID_BLOCK_SIZE ); - rc += TestMethod( po, "SetBlockSize()", f.SetBlockSize( 512 ), XB_NO_ERROR ); - rc += TestMethod( po, "GetBlockSize()", (xbInt32) f.GetBlockSize(), 512 ); - - char BlockBuf[513]; - memset( BlockBuf, 0x00, 513 ); - rc += TestMethod( po, "xbFopen()", f.xbFopen( "w+b", XB_SINGLE_USER ), XB_NO_ERROR ); - - for( int i = 0; i < 512; i++ ) - BlockBuf[i] = 'A'; - rc += TestMethod( po, "WriteBlock()", f.WriteBlock( 0L, 512, BlockBuf ), XB_NO_ERROR ); - - for( int i = 0; i < 512; i++ ) - BlockBuf[i] = 'B'; - rc += TestMethod( po, "WriteBlock()", f.WriteBlock( 1L, 512, BlockBuf ), XB_NO_ERROR ); - - for( int i = 0; i < 512; i++ ) - BlockBuf[i] = 'C'; - rc += TestMethod( po, "WriteBlock()", f.WriteBlock( 2L, 512, BlockBuf ), XB_NO_ERROR ); - - char BlockBuf2[513]; - memset( BlockBuf2, 0x00, 513 ); - rc += TestMethod( po, "ReadBlock()", f.ReadBlock( 2L, 512, BlockBuf2 ), XB_NO_ERROR ); - - xbString s1 = BlockBuf; - xbString s2 = BlockBuf2; - - rc += TestMethod( po, "ReadBlock()", s1, s2, 512 ); - - rc += TestMethod( po, "xbTruncate()", f.xbTruncate( 1000 ), XB_NO_ERROR ); - - xbUInt64 ullFsize; - rc += TestMethod( po, "GetFileSize()", f.GetFileSize( ullFsize ), XB_NO_ERROR ); - rc += TestMethod( po, "xbGetFileSize()", (xbInt32) ullFsize, 1000 ); - rc += TestMethod( po, "xbFclose()", f.xbFclose(), XB_NO_ERROR ); - - if( po > 0 || rc < 0 ) - fprintf( stdout, "Total Errors = %d\n", rc * -1 ); - - #ifdef XB_LOGGING_SUPPORT - sMsg.Sprintf( "Program [%s] terminating with [%d] errors...", av[0], rc * -1 ); - x.WriteLogMessage( sMsg ); - #endif - - return rc; -} - -- cgit v1.2.3