summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests')
-rwxr-xr-xsrc/tests/tstfuncs.cpp18
-rwxr-xr-xsrc/tests/xb_test_dbf_v3_memos.cpp34
-rwxr-xr-xsrc/tests/xb_test_dbf_v3_nomemos.cpp4
-rwxr-xr-xsrc/tests/xb_test_dbf_v4_memos.cpp26
-rwxr-xr-xsrc/tests/xb_test_dbf_v4_nomemos.cpp8
-rwxr-xr-xsrc/tests/xb_test_expression.cpp14
-rwxr-xr-xsrc/tests/xb_test_file.cpp24
-rwxr-xr-xsrc/tests/xb_test_filter.cpp100
-rwxr-xr-xsrc/tests/xb_test_funcs.cpp4
-rwxr-xr-xsrc/tests/xb_test_mdx.cpp17
-rwxr-xr-xsrc/tests/xb_test_ndx.cpp92
-rwxr-xr-xsrc/tests/xb_test_ndx2.cpp145
-rwxr-xr-xsrc/tests/xb_test_sql.cpp95
-rwxr-xr-xsrc/tests/xb_test_string.cpp15
-rwxr-xr-xsrc/tests/xb_test_tblmgr.cpp14
-rwxr-xr-xsrc/tests/xb_test_xbase.cpp14
16 files changed, 367 insertions, 257 deletions
diff --git a/src/tests/tstfuncs.cpp b/src/tests/tstfuncs.cpp
index c499d3f..d9b108d 100755
--- a/src/tests/tstfuncs.cpp
+++ b/src/tests/tstfuncs.cpp
@@ -29,7 +29,7 @@ xbInt16 TestMethod( xbInt16 PrintOption, const char * title, xbDouble result, xb
xbInt16 TestMethod( xbInt16 PrintOption, const char * title, xbDouble result, xbDouble expectedResult, xbDouble dEpsilon );
-xbInt16 FileCompare( xbXBase &x, xbInt16 iPo, const xbString &sFile1, const xbString &sFile2, const xbString &sSkipBytes );
+// xbInt16 FileCompare( xbXBase &x, xbInt16 iPo, const xbString &sFile1, const xbString &sFile2, const xbString &sSkipBytes );
#ifdef XB_LOCKING_SUPORT
@@ -458,15 +458,15 @@ xbDouble ChronTime(){
}
-
+/*
xbInt16 FileCompare( xbXBase &x, xbInt16 iPo, const xbString &sFile1, const xbString &sFile2, const xbString &sSkipBytes ){
-/*
- iPo print option
- sFile1 - File 1
- sFile2 - File 2
- sSkipBytes - comma separated list of bytes to skip the compare on
-*/
+
+// iPo print option
+// sFile1 - File 1
+// sFile2 - File 2
+// sSkipBytes - comma separated list of bytes to skip the compare on
+
xbInt16 iRc = 0;
xbInt16 iErrorStop = 0;
@@ -577,5 +577,7 @@ xbInt16 FileCompare( xbXBase &x, xbInt16 iPo, const xbString &sFile1, const xbSt
return iRc;
}
+*/
+
diff --git a/src/tests/xb_test_dbf_v3_memos.cpp b/src/tests/xb_test_dbf_v3_memos.cpp
index e364741..ad3e8e0 100755
--- a/src/tests/xb_test_dbf_v3_memos.cpp
+++ b/src/tests/xb_test_dbf_v3_memos.cpp
@@ -54,8 +54,7 @@ int main( int argCnt, char **av )
xbXBase x;
-#ifdef XB_LOGGING_SUPPORT
-
+ #ifdef XB_LOGGING_SUPPORT
x.EnableMsgLogging();
if( po ){
std::cout << "Logfile is [" << x.GetLogFqFileName().Str() << "]" << std::endl;
@@ -63,12 +62,15 @@ int main( int argCnt, char **av )
xbString sMsg;
sMsg.Sprintf( "Program [%s] initializing...", av[0] );
x.WriteLogMessage( sMsg );
-
-#endif
+ #endif
x.SetDataDirectory( PROJECT_DATA_DIR );
x.EnableMsgLogging();
+
+ #ifdef XB_LOCKING_SUPPORT
x.DisableDefaultAutoLock();
+ #endif // XB_LOCKING_SUPPORT
+
InitTime();
if( po > 0 )
@@ -218,9 +220,33 @@ int main( int argCnt, char **av )
rc += TestMethod( po, "GetRecord()", V3Dbf.GetRecord( 7 ), XB_NO_ERROR );
rc += TestMethod( po, "DeleteRecord()", V3Dbf.DeleteRecord(), XB_NO_ERROR );
rc += TestMethod( po, "Pack()", V3Dbf.Pack(), XB_NO_ERROR );
+
+ xbString sDir;
+ V3Dbf.GetFileDirPart( sDir );
+ xbString sDbfName;
+ xbString sDbtName;
+ sDbfName.Sprintf( "%snewV3nm.DBF", sDir.Str());
+ sDbtName.Sprintf( "%snewV3nm.DBT", sDir.Str());
+
+ std::cout << "remove [" << sDbfName.Str() << "\n";
+ std::cout << "remove [" << sDbtName.Str() << "\n";
+
+ V3Dbf.xbRemove( sDbfName );
+ V3Dbf.xbRemove( sDbtName );
+
+ x.DisplayTableList();
+
+ rc += TestMethod( po, "Rename()", V3Dbf.Rename( "newV3nm.DBF" ), XB_NO_ERROR );
+ x.DisplayTableList();
+
+
rc += TestMethod( po, "Close()", V3Dbf.Close(), XB_NO_ERROR );
+
+
}
+
+
if( po > 0 || rc < 0 )
fprintf( stdout, "Total Errors = %d\n", rc * -1 );
diff --git a/src/tests/xb_test_dbf_v3_nomemos.cpp b/src/tests/xb_test_dbf_v3_nomemos.cpp
index aab118f..e5adc48 100755
--- a/src/tests/xb_test_dbf_v3_nomemos.cpp
+++ b/src/tests/xb_test_dbf_v3_nomemos.cpp
@@ -71,7 +71,11 @@ int main( int argCnt, char **av )
x.SetDataDirectory( PROJECT_DATA_DIR );
x.EnableMsgLogging();
+
+ #ifdef XB_LOCKING_SUPPORT
x.DisableDefaultAutoLock();
+ #endif // XB_LOCKING_SUPPORT
+
InitTime();
if( po > 0 )
diff --git a/src/tests/xb_test_dbf_v4_memos.cpp b/src/tests/xb_test_dbf_v4_memos.cpp
index e92b5b2..2b0e09c 100755
--- a/src/tests/xb_test_dbf_v4_memos.cpp
+++ b/src/tests/xb_test_dbf_v4_memos.cpp
@@ -61,7 +61,11 @@ int main( int argCnt, char **av )
x.SetDataDirectory( PROJECT_DATA_DIR );
x.EnableMsgLogging();
+
+ #ifdef XB_LOCKING_SUPPORT
x.DisableDefaultAutoLock();
+ #endif // XB_LOCKING_SUPPORT
+
InitTime();
@@ -318,8 +322,28 @@ int main( int argCnt, char **av )
rc += TestMethod( po, "GetRecord()", V4Dbf.GetRecord( 7 ), XB_NO_ERROR );
rc += TestMethod( po, "DeleteRecord()", V4Dbf.DeleteRecord(), XB_NO_ERROR );
-
rc += TestMethod( po, "Pack()", V4Dbf.Pack(), XB_NO_ERROR );
+
+ xbString sDir;
+ V4Dbf.GetFileDirPart( sDir );
+ xbString sDbfName;
+ xbString sDbtName;
+ sDbfName.Sprintf( "%snew4name.DBF", sDir.Str());
+ sDbtName.Sprintf( "%snew4name.DBT", sDir.Str());
+
+// std::cout << "remove [" << sDbfName.Str() << "\n";
+// std::cout << "remove [" << sDbtName.Str() << "\n";
+
+ V4Dbf.xbRemove( sDbfName );
+ V4Dbf.xbRemove( sDbtName );
+
+ x.DisplayTableList();
+
+ rc += TestMethod( po, "Rename()", V4Dbf.Rename( "new4name.DBF" ), XB_NO_ERROR );
+
+ x.DisplayTableList();
+
+
rc += TestMethod( po, "Close()", V4Dbf.Close(), XB_NO_ERROR );
}
diff --git a/src/tests/xb_test_dbf_v4_nomemos.cpp b/src/tests/xb_test_dbf_v4_nomemos.cpp
index 68ecda0..4036588 100755
--- a/src/tests/xb_test_dbf_v4_nomemos.cpp
+++ b/src/tests/xb_test_dbf_v4_nomemos.cpp
@@ -58,7 +58,7 @@ int main( int argCnt, char **av )
xbXBase x;
-#ifdef XB_LOGGING_SUPPORT
+ #ifdef XB_LOGGING_SUPPORT
x.EnableMsgLogging();
if( po ){
std::cout << "Logfile is [" << x.GetLogFqFileName().Str() << "]" << std::endl;
@@ -66,11 +66,15 @@ int main( int argCnt, char **av )
xbString sMsg;
sMsg.Sprintf( "Program [%s] initializing...", av[0] );
x.WriteLogMessage( sMsg );
-#endif
+ #endif
x.SetDataDirectory( PROJECT_DATA_DIR );
x.EnableMsgLogging();
+
+ #ifdef XB_LOCKING_SUPPORT
x.DisableDefaultAutoLock();
+ #endif // XB_LOCKING_SUPPORT
+
InitTime();
if( po > 0 )
diff --git a/src/tests/xb_test_expression.cpp b/src/tests/xb_test_expression.cpp
index e3b47cc..75ed3e5 100755
--- a/src/tests/xb_test_expression.cpp
+++ b/src/tests/xb_test_expression.cpp
@@ -65,7 +65,9 @@ xbInt16 DevTester( xbXBase * xb, xbDbf * dbf, const char * sExpIn ){
std::cout << "dump nodes\n";
n = exp.GetNextNodeTest( NULL );
if( iRc == XB_NO_ERROR ){
+ #ifdef XB_DEBUG_SUPPORT
exp.DumpTree( xbTrue );
+ #endif // XB_DEBUG_SUPPORT
std::cout << "dump nodes\n";
n = exp.GetNextNodeTest( NULL );
if( !n ){
@@ -203,13 +205,17 @@ xbInt16 TestMethod( xbXBase *xb, xbDbf *d, xbInt16 PrintOption, const char * tit
if( sResult != sExpectedResult ){
std::cout << std::endl << "[FAIL 5] " << title << std::endl;
std::cout << " Expected Result = [" << sExpectedResult << "] Actual Result =[" << sResult.Str() << "]" << std::endl;
+ #ifdef XB_DEBUG_SUPPORT
exp.DumpTree( 1 );
+ #endif // XB_DEBUG_SUPPORT
return -1;
}
if( exp.GetResultLen() != iExpectedResultLen ){
std::cout << std::endl << "[FAIL 6] " << title << std::endl;
std::cout << " Expected Result Len = [" << iExpectedResultLen << "] Actual Result =[" << exp.GetResultLen() << "]" << std::endl;
+ #ifdef XB_DEBUG_SUPPORT
exp.DumpTree( 1 );
+ #endif // XB_DEBUG_SUPPORT
return -1;
}
if( PrintOption == 2 )
@@ -255,7 +261,9 @@ xbInt16 TestMethod( xbXBase * xb, xbDbf * d, xbInt16 PrintOption, const char * t
std::cout << std::endl << "[FAIL 5] " << title << std::endl;
std::cout << " Expected Result = [" << dExpectedResult << "] Actual Result =[" << dResult << "]" << std::endl;
// dump out the tree
+ #ifdef XB_DEBUG_SUPPORT
exp.DumpTree( 1 );
+ #endif // XB_DEBUG_SUPPORT
return -1;
}
if( PrintOption == 2 )
@@ -297,7 +305,9 @@ xbInt16 TestMethod( xbXBase * xb, xbDbf * d, xbInt16 PrintOption, const char * t
std::cout << std::endl << "[FAIL 5] " << title << std::endl;
std::cout << " Expected Result = [" << dtExpectedResult.Str() << "] Actual Result =[" << dtResult.Str() << "]" << std::endl;
// dump out the tree
+ #ifdef XB_DEBUG_SUPPORT
exp.DumpTree( 1 );
+ #endif // XB_DEBUG_SUPPORT
return -1;
}
if( PrintOption == 2 )
@@ -341,7 +351,9 @@ xbInt16 TestMethod( xbXBase * xb, xbDbf * d, xbInt16 PrintOption, const char * t
std::cout << std::endl << "[FAIL 5] " << title << std::endl;
std::cout << " Expected Result = [" << bExpectedResult << "] Actual Result =[" << bResult << "]" << std::endl;
// dump out the tree
+ #ifdef XB_DEBUG_SUPPORT
exp.DumpTree( 1 );
+ #endif //XB_DEBUG_SUPPORT
return -1;
}
if( PrintOption == 2 )
@@ -634,7 +646,9 @@ int main( int argCnt, char **av )
iRc += TestMethod( &x, MyFile, po, "DateTest5", "DATE2 - DATE1", (xbDouble) 8528 );
dtTest1.Set( "20120705" );
+
iRc += TestMethod( &x, MyFile, po, "DateTest6", "DATE2 - 3", dtTest1 );
+
iRc += TestMethod( &x, MyFile, po, "DateTest7", "DATE2 -= 3", dtTest1 );
dtTest1.Set( "20120718" );
diff --git a/src/tests/xb_test_file.cpp b/src/tests/xb_test_file.cpp
index ca32693..4614805 100755
--- a/src/tests/xb_test_file.cpp
+++ b/src/tests/xb_test_file.cpp
@@ -39,9 +39,9 @@ int main( int argCnt, char **av )
else if( av[1][0] == 'V' )
po = 2;
}
-
-#ifdef XB_LOGGING_SUPPORT
xbXBase x;
+
+ #ifdef XB_LOGGING_SUPPORT
x.EnableMsgLogging();
if( po ){
std::cout << "Logfile is [" << x.GetLogFqFileName().Str() << "]" << std::endl;
@@ -49,7 +49,7 @@ int main( int argCnt, char **av )
xbString sMsg;
sMsg.Sprintf( "Program [%s] initializing...", av[0] );
x.WriteLogMessage( sMsg );
-#endif
+ #endif
InitTime();
xbFile f( &x );
@@ -57,13 +57,13 @@ int main( int argCnt, char **av )
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" );
@@ -85,14 +85,13 @@ int main( int argCnt, char **av )
sWrkStr += "TestFile.txt";
rc += TestMethod( po, "GetFqFileName()", f.GetFqFileName(), sWrkStr, 26 );
-#ifdef WIN32
+ #ifdef WIN32
sWrkStr = "\\some\\directory\\myfile.dat";
sWrkStr2 = "\\some\\directory\\";
-#else
+ #else
sWrkStr = "/some/directory/myfile.dat";
sWrkStr2 = "/some/directory/";
-#endif
-
+ #endif
f.SetFqFileName( sWrkStr );
rc += TestMethod( po, "GetDirectory()", f.GetDirectory(), sWrkStr2, 16 );
@@ -107,7 +106,6 @@ int main( int argCnt, char **av )
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 );
@@ -161,12 +159,10 @@ int main( int argCnt, char **av )
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 );
@@ -202,10 +198,10 @@ int main( int argCnt, char **av )
if( po > 0 || rc < 0 )
fprintf( stdout, "Total Errors = %d\n", rc * -1 );
-#ifdef XB_LOGGING_SUPPORT
+ #ifdef XB_LOGGING_SUPPORT
sMsg.Sprintf( "Program [%s] terminating with [%d] errors...", av[0], rc * -1 );
x.WriteLogMessage( sMsg );
-#endif
+ #endif
return rc;
}
diff --git a/src/tests/xb_test_filter.cpp b/src/tests/xb_test_filter.cpp
index 2aeade3..ac4b896 100755
--- a/src/tests/xb_test_filter.cpp
+++ b/src/tests/xb_test_filter.cpp
@@ -52,7 +52,7 @@ int main( int argCnt, char **av )
xbXBase x;
-#ifdef XB_LOGGING_SUPPORT
+ #ifdef XB_LOGGING_SUPPORT
x.EnableMsgLogging();
if( iPo ){
std::cout << "Logfile is [" << x.GetLogFqFileName().Str() << "]" << std::endl;
@@ -61,7 +61,7 @@ int main( int argCnt, char **av )
sMsg.Sprintf( "Program [%s] initializing...", av[0] );
x.WriteLogMessage( sMsg );
x.SetLogSize( 1000000 );
-#endif
+ #endif
x.SetDataDirectory( PROJECT_DATA_DIR );
x.EnableMsgLogging();
@@ -74,16 +74,20 @@ int main( int argCnt, char **av )
if( iPo > 0 )
std::cout << "Default Data Directory is [" << x.GetDataDirectory().Str() << "]" << std::endl;
- xbDbf *V4Dbf = new xbDbf4( &x );
+ #ifdef XB_DBF4_SUPPORT
+ xbDbf *MyFile = new xbDbf4( &x );
+ #else
+ xbDbf *MyFile = new xbDbf3( &x );
+ #endif
- iRc2 = V4Dbf->CreateTable( "TestFilt.DBF", "TestFilter", MyV4Record, XB_OVERLAY, XB_MULTI_USER );
+ iRc2 = MyFile->CreateTable( "TestFilt.DBF", "TestFilter", MyV4Record, XB_OVERLAY, XB_MULTI_USER );
iRc += TestMethod( iPo, "CreateTable()", (xbInt32) iRc2, XB_NO_ERROR );
#ifdef XB_NDX_SUPPORT
xbIx *ixPtr;
void *ndx;
- iRc2 = V4Dbf->CreateTag( "NDX", "TestFilt.NDX", "CFLD", "", 0, 0, XB_OVERLAY, &ixPtr, &ndx );
+ iRc2 = MyFile->CreateTag( "NDX", "TestFilt.NDX", "CFLD", "", 0, 0, XB_OVERLAY, &ixPtr, &ndx );
iRc += TestMethod( iPo, "CreateTag()", (xbInt32) iRc2, XB_NO_ERROR );
if( iRc2 )
x.DisplayError( iRc2 );
@@ -99,79 +103,85 @@ int main( int argCnt, char **av )
c = j + 65;
s = c;
s.PadRight( c, (xbUInt32) i + 1 );
- V4Dbf->BlankRecord();
- V4Dbf->PutField( "CFLD", s );
- V4Dbf->PutLongField( "NFLD", ++lRecCnt );
- iRc = V4Dbf->AppendRecord();
+ MyFile->BlankRecord();
+ MyFile->PutField( "CFLD", s );
+ MyFile->PutLongField( "NFLD", ++lRecCnt );
+ iRc = MyFile->AppendRecord();
}
}
- iRc += TestMethod( iPo, "SetCurTag()", V4Dbf->SetCurTag( "" ), XB_NO_ERROR );
- xbFilter f1( &x, V4Dbf );
+ #ifdef XB_INDEX_SUPPORT
+ iRc += TestMethod( iPo, "SetCurTag()", MyFile->SetCurTag( "" ), XB_NO_ERROR );
+ #endif // XB_INDEX_SUPPORT
+
+ xbFilter f1( &x, MyFile );
xbString sMyFilterExpression = "LEFT( CFLD, 2 ) = 'YY'";
iRc += TestMethod( iPo, "Set()", f1.Set( sMyFilterExpression ), XB_NO_ERROR );
- iRc += TestMethod( iPo, "SetCurTag()", V4Dbf->SetCurTag( "" ), XB_NO_ERROR );
+ #ifdef XB_INDEX_SUPPORT
+ iRc += TestMethod( iPo, "SetCurTag()", MyFile->SetCurTag( "" ), XB_NO_ERROR );
+ #endif // XB_INDEX_SUPPORT
+
iRc += TestMethod( iPo, "Set()", f1.Set( sMyFilterExpression ), XB_NO_ERROR );
iRc += TestMethod( iPo, "GetFirstRecord()", f1.GetFirstRecord(), XB_NO_ERROR );
- iRc += TestMethod( iPo, "GetCurRecNo()", (xbInt32) V4Dbf->GetCurRecNo(), 28 );
+ iRc += TestMethod( iPo, "GetCurRecNo()", (xbInt32) MyFile->GetCurRecNo(), 28 );
iRc += TestMethod( iPo, "GetNextRecord()", f1.GetNextRecord(), XB_NO_ERROR );
- iRc += TestMethod( iPo, "GetCurRecNo()", (xbInt32) V4Dbf->GetCurRecNo(), 54 );
+ iRc += TestMethod( iPo, "GetCurRecNo()", (xbInt32) MyFile->GetCurRecNo(), 54 );
iRc += TestMethod( iPo, "GetNextRecord()", f1.GetNextRecord(), XB_NO_ERROR );
- iRc += TestMethod( iPo, "GetCurRecNo()", (xbInt32) V4Dbf->GetCurRecNo(), 80 );
+ iRc += TestMethod( iPo, "GetCurRecNo()", (xbInt32) MyFile->GetCurRecNo(), 80 );
iRc += TestMethod( iPo, "GetLast()", f1.GetLastRecord(), XB_NO_ERROR );
- iRc += TestMethod( iPo, "GetCurRecNo()", (xbInt32) V4Dbf->GetCurRecNo(), 106 );
+ iRc += TestMethod( iPo, "GetCurRecNo()", (xbInt32) MyFile->GetCurRecNo(), 106 );
iRc += TestMethod( iPo, "GetPrev()", f1.GetPrevRecord(), XB_NO_ERROR );
- iRc += TestMethod( iPo, "GetCurRecNo()", (xbInt32) V4Dbf->GetCurRecNo(), 80 );
+ iRc += TestMethod( iPo, "GetCurRecNo()", (xbInt32) MyFile->GetCurRecNo(), 80 );
sMyFilterExpression = "LEFT( CFLD, 2 ) = 'CC'";
iRc += TestMethod( iPo, "Set()", f1.Set( sMyFilterExpression ), XB_NO_ERROR );
iRc += TestMethod( iPo, "GetFirstRecord()", f1.GetFirstRecord(), XB_NO_ERROR );
- iRc += TestMethod( iPo, "GetCurRecNo()", (xbInt32) V4Dbf->GetCurRecNo(), 50 );
+ iRc += TestMethod( iPo, "GetCurRecNo()", (xbInt32) MyFile->GetCurRecNo(), 50 );
iRc += TestMethod( iPo, "GetNextRecord()", f1.GetNextRecord(), XB_NO_ERROR );
- iRc += TestMethod( iPo, "GetCurRecNo()", (xbInt32) V4Dbf->GetCurRecNo(), 76 );
+ iRc += TestMethod( iPo, "GetCurRecNo()", (xbInt32) MyFile->GetCurRecNo(), 76 );
iRc += TestMethod( iPo, "GetNextRecord()", f1.GetNextRecord(), XB_NO_ERROR );
- iRc += TestMethod( iPo, "GetCurRecNo()", (xbInt32) V4Dbf->GetCurRecNo(), 102 );
+ iRc += TestMethod( iPo, "GetCurRecNo()", (xbInt32) MyFile->GetCurRecNo(), 102 );
iRc += TestMethod( iPo, "GetLast()", f1.GetLastRecord(), XB_NO_ERROR );
- iRc += TestMethod( iPo, "GetCurRecNo()", (xbInt32) V4Dbf->GetCurRecNo(), 128 );
+ iRc += TestMethod( iPo, "GetCurRecNo()", (xbInt32) MyFile->GetCurRecNo(), 128 );
iRc += TestMethod( iPo, "GetPrev()", f1.GetPrevRecord(), XB_NO_ERROR );
- iRc += TestMethod( iPo, "GetCurRecNo()", (xbInt32) V4Dbf->GetCurRecNo(), 102 );
+ iRc += TestMethod( iPo, "GetCurRecNo()", (xbInt32) MyFile->GetCurRecNo(), 102 );
#ifdef XB_NDX_SUPPORT
f1.SetLimit( 0 );
// change things up a bit
- iRc += TestMethod( iPo, "GetRecord()", V4Dbf->GetRecord( 32 ), XB_NO_ERROR );
- iRc += TestMethod( iPo, "PutField()", V4Dbf->PutField( "ZFLD", "Z" ), XB_NO_ERROR );
- iRc += TestMethod( iPo, "GetRecord()", V4Dbf->GetRecord( 52 ), XB_NO_ERROR );
- iRc += TestMethod( iPo, "PutField()", V4Dbf->PutField( "ZFLD", "Z" ), XB_NO_ERROR );
- iRc += TestMethod( iPo, "GetRecord()", V4Dbf->GetRecord( 76 ), XB_NO_ERROR );
- iRc += TestMethod( iPo, "PutField()", V4Dbf->PutField( "ZFLD", "Z" ), XB_NO_ERROR );
- iRc += TestMethod( iPo, "GetRecord()", V4Dbf->GetRecord( 103 ), XB_NO_ERROR );
- iRc += TestMethod( iPo, "PutField()", V4Dbf->PutField( "ZFLD", "Z" ), XB_NO_ERROR );
- iRc += TestMethod( iPo, "Commit()", V4Dbf->Commit(), XB_NO_ERROR );
-
- iRc += TestMethod( iPo, "SetCurTag()", V4Dbf->SetCurTag( "TestFilt" ), XB_NO_ERROR );
+ iRc += TestMethod( iPo, "GetRecord()", MyFile->GetRecord( 32 ), XB_NO_ERROR );
+ iRc += TestMethod( iPo, "PutField()", MyFile->PutField( "ZFLD", "Z" ), XB_NO_ERROR );
+ iRc += TestMethod( iPo, "GetRecord()", MyFile->GetRecord( 52 ), XB_NO_ERROR );
+ iRc += TestMethod( iPo, "PutField()", MyFile->PutField( "ZFLD", "Z" ), XB_NO_ERROR );
+ iRc += TestMethod( iPo, "GetRecord()", MyFile->GetRecord( 76 ), XB_NO_ERROR );
+ iRc += TestMethod( iPo, "PutField()", MyFile->PutField( "ZFLD", "Z" ), XB_NO_ERROR );
+ iRc += TestMethod( iPo, "GetRecord()", MyFile->GetRecord( 103 ), XB_NO_ERROR );
+ iRc += TestMethod( iPo, "PutField()", MyFile->PutField( "ZFLD", "Z" ), XB_NO_ERROR );
+ iRc += TestMethod( iPo, "Commit()", MyFile->Commit(), XB_NO_ERROR );
+
+ iRc += TestMethod( iPo, "SetCurTag()", MyFile->SetCurTag( "TestFilt" ), XB_NO_ERROR );
sMyFilterExpression = "ZFLD = 'Z'";
iRc += TestMethod( iPo, "Set()", f1.Set( sMyFilterExpression ), XB_NO_ERROR );
- iRc += TestMethod( iPo, "GetFirstRecord()", f1.GetFirstRecord(), XB_NO_ERROR );
- iRc += TestMethod( iPo, "GetCurRecNo()", (xbInt32) V4Dbf->GetCurRecNo(), 52 );
- iRc += TestMethod( iPo, "GetNextRecord()", f1.GetNextRecord(), XB_NO_ERROR );
- iRc += TestMethod( iPo, "GetCurRecNo()", (xbInt32) V4Dbf->GetCurRecNo(), 103 );
- iRc += TestMethod( iPo, "GetNextRecord()", f1.GetNextRecord(), XB_NO_ERROR );
- iRc += TestMethod( iPo, "GetCurRecNo()", (xbInt32) V4Dbf->GetCurRecNo(), 76 );
- iRc += TestMethod( iPo, "GetLast()", f1.GetLastRecord(), XB_NO_ERROR );
- iRc += TestMethod( iPo, "GetCurRecNo()", (xbInt32) V4Dbf->GetCurRecNo(), 32 );
- iRc += TestMethod( iPo, "GetPrev()", f1.GetPrevRecord(), XB_NO_ERROR );
- iRc += TestMethod( iPo, "GetCurRecNo()", (xbInt32) V4Dbf->GetCurRecNo(), 76 );
+ iRc += TestMethod( iPo, "GetFirstRecordIx()", f1.GetFirstRecordIx(), XB_NO_ERROR );
+ iRc += TestMethod( iPo, "GetCurRecNo()", (xbInt32) MyFile->GetCurRecNo(), 52 );
+ iRc += TestMethod( iPo, "GetNextRecordIx()", f1.GetNextRecordIx(), XB_NO_ERROR );
+ iRc += TestMethod( iPo, "GetCurRecNo()", (xbInt32) MyFile->GetCurRecNo(), 103 );
+ iRc += TestMethod( iPo, "GetNextRecordIx()", f1.GetNextRecordIx(), XB_NO_ERROR );
+ iRc += TestMethod( iPo, "GetCurRecNo()", (xbInt32) MyFile->GetCurRecNo(), 76 );
+ iRc += TestMethod( iPo, "GetLastRecordIx()", f1.GetLastRecordIx(), XB_NO_ERROR );
+ iRc += TestMethod( iPo, "GetCurRecNo()", (xbInt32) MyFile->GetCurRecNo(), 32 );
+ iRc += TestMethod( iPo, "GetPrevRecordIx()", f1.GetPrevRecordIx(), XB_NO_ERROR );
+ iRc += TestMethod( iPo, "GetCurRecNo()", (xbInt32) MyFile->GetCurRecNo(), 76 );
#endif // XB_NDX_SUPPORT
- iRc += TestMethod( iPo, "Close()", V4Dbf->Close(), XB_NO_ERROR );
- delete V4Dbf;
+ iRc += TestMethod( iPo, "Close()", MyFile->Close(), XB_NO_ERROR );
+ delete MyFile;
if( iPo > 0 || iRc < 0 )
fprintf( stdout, "Total Errors = %d\n", iRc * -1 );
diff --git a/src/tests/xb_test_funcs.cpp b/src/tests/xb_test_funcs.cpp
index 07e2c17..e8b73b0 100755
--- a/src/tests/xb_test_funcs.cpp
+++ b/src/tests/xb_test_funcs.cpp
@@ -92,7 +92,11 @@ int main( int argCnt, char **av )
iRc += TestMethod( po, "PutField()", MyFile->PutField( "DATE1", "19890303" ), XB_NO_ERROR );
iRc += TestMethod( po, "PutField()", MyFile->PutField ( "DATE2", "20120708" ), XB_NO_ERROR );
+ #ifdef XB_LOCKING_SUPPORT
MyFile->SetAutoLock( xbFalse );
+ #endif // XB_LOCKING_SUPPORT
+
+
iRc += TestMethod( po, "AppendRecord()", MyFile->AppendRecord(), XB_NO_ERROR );
iRc += TestMethod( po, "ABS( -222, dResult )", x.ABS( -222, dResult ), XB_NO_ERROR );
diff --git a/src/tests/xb_test_mdx.cpp b/src/tests/xb_test_mdx.cpp
index 9351e4d..af191ad 100755
--- a/src/tests/xb_test_mdx.cpp
+++ b/src/tests/xb_test_mdx.cpp
@@ -227,11 +227,22 @@ int main( int argCnt, char **av )
iRc += TestMethod( iPo, "GetFirstKey()", V4DbfX1->GetFirstKey(), XB_NO_ERROR );
iRc += TestMethod( iPo, "GetCurRecNo()", (xbInt32) V4DbfX1->GetCurRecNo(), (xbInt32) 1 );
+ xbString sDir;
+ V4DbfX1->GetFileDirPart( sDir );
+ xbString sDbfName;
+ xbString sMdxName;
+ sDbfName.Sprintf( "%sTestMdxR.DBF", sDir.Str());
+ sMdxName.Sprintf( "%sTestMdxR.MDX", sDir.Str());
+ V4DbfX1->xbRemove( sDbfName );
+ V4DbfX1->xbRemove( sMdxName );
- x.CloseAllTables();
- delete V4DbfX1;
+ iRc += TestMethod( iPo, "Rename()", V4DbfX1->Rename( "TestMdxR.DBF" ), XB_NO_ERROR );
- if( iPo > 0 || iRc < 0 )
+
+ x.CloseAllTables();
+ delete V4DbfX1;
+
+ if( iPo > 0 || iRc < 0 )
fprintf( stdout, "Total Errors = %d\n", iRc * -1 );
#ifdef XB_LOGGING_SUPPORT
diff --git a/src/tests/xb_test_ndx.cpp b/src/tests/xb_test_ndx.cpp
index 31306c0..b8b97f6 100755
--- a/src/tests/xb_test_ndx.cpp
+++ b/src/tests/xb_test_ndx.cpp
@@ -53,22 +53,26 @@ int main( int argCnt, char **av )
{ "",0,0,0 }
};
-
xbXBase x;
-#ifdef XB_LOGGING_SUPPORT
+ xbString sMsg;
+
+ #ifdef XB_LOGGING_SUPPORT
x.EnableMsgLogging();
if( iPo ){
std::cout << "Logfile is [" << x.GetLogFqFileName().Str() << "]" << std::endl;
}
- xbString sMsg;
sMsg.Sprintf( "Program [%s] initializing...", av[0] );
x.WriteLogMessage( sMsg );
x.SetLogSize( 1000000 );
-#endif
+ #endif
x.SetDataDirectory( PROJECT_DATA_DIR );
x.EnableMsgLogging();
-// x.DisableDefaultAutoLock();
+
+ #ifdef XB_LOCKING_SUPPORT
+ x.DisableDefaultAutoLock();
+ #endif
+
InitTime();
char c;
@@ -116,6 +120,9 @@ int main( int argCnt, char **av )
iRc2 = V3Dbf->AssociateIndex( "NDX", "TestNdxN.NDX", 0 );
iRc += TestMethod( iPo, "Associate()", (xbInt32) iRc2, XB_NO_ERROR );
+ #ifdef XB_LOCKING_SUPPORT
+ iRc += TestMethod( iPo, "LockTable()", V3Dbf->LockTable( XB_LOCK ), XB_NO_ERROR );
+ #endif
iRc += TestMethod( iPo, "GetCurTagName()", V3Dbf->GetCurTagName().Str(), "TestNdxC", 8 );
iRc += TestMethod( iPo, "SetCurTag()", V3Dbf->SetCurTag( "TestNdxN" ), XB_NO_ERROR );
@@ -177,7 +184,6 @@ int main( int argCnt, char **av )
iRc += TestMethod( iPo, "SetCurTag()", V3Dbf->SetCurTag( "TestNdxD" ), XB_NO_ERROR );
iRc += TestMethod( iPo, "GetCurTagName()", V3Dbf->GetCurTagName().Str(), "TestNdxD", 8 );
- std::cout << d.Str() << "\n";
iRc += TestMethod( iPo, "Find( '19890420' )", V3Dbf->Find( d ), XB_NOT_FOUND );
V3Dbf->GetRecord( 26 );
@@ -315,16 +321,84 @@ int main( int argCnt, char **av )
}
}
- iRc += TestMethod( iPo, "Close()", V3Dbf->Close(), XB_NO_ERROR );
+ #ifdef XB_LOCKING_SUPPORT
+ iRc += TestMethod( iPo, "LockTable()", V3Dbf->LockTable( XB_UNLOCK ), XB_NO_ERROR );
+ #endif
+
+ xbString sDir;
+ V3Dbf->GetFileDirPart( sDir );
+ xbString sDbfName;
+ xbString sInfName;
+ sDbfName.Sprintf( "%sTestNdxR.DBF", sDir.Str());
+ sInfName.Sprintf( "%sTestNdxR.INF", sDir.Str());
+
+ V3Dbf->xbRemove( sDbfName );
+ V3Dbf->xbRemove( sInfName );
+
+ iRc += TestMethod( iPo, "Rename()", V3Dbf->Rename( "TestNdxR.DBF" ), XB_NO_ERROR );
+
+ iRc += TestMethod( iPo, "DeleteTable()", V3Dbf->DeleteTable(), XB_NO_ERROR );
+ // iRc += TestMethod( iPo, "Close()", V3Dbf->Close(), XB_NO_ERROR ); // did a delete instead of close
+
delete V3Dbf;
+ x.SetUniqueKeyOpt( XB_EMULATE_DBASE );
+ V3Dbf = new xbDbf3( &x );
+
+ iRc2 = V3Dbf->CreateTable( "TestNdx.DBF", "TestNdx", MyV3Record, XB_OVERLAY, XB_MULTI_USER );
+ iRc += TestMethod( iPo, "CreateTable()", (xbInt32) iRc2, XB_NO_ERROR );
+
+ if( iRc2 )
+ x.DisplayError( iRc2 );
+
+ iRc2 = V3Dbf->CreateTag( "NDX", "TestNdxC.NDX", "CFLD", "", 0, xbTrue, XB_OVERLAY, &ixPtr, &ndx );
+ iRc += TestMethod( iPo, "CreateTag()", (xbInt32) iRc2, XB_NO_ERROR );
+ if( iRc2 )
+ x.DisplayError( iRc2 );
+
+ iRc2 = V3Dbf->AssociateIndex( "NDX", "TestNdxC.NDX", 0 );
+ iRc += TestMethod( iPo, "Associate()", (xbInt32) iRc2, XB_NO_ERROR );
+
+
+ iRc += TestMethod( iPo, "BlankRecord()", V3Dbf->BlankRecord(), XB_NO_ERROR );
+ iRc += TestMethod( iPo, "Putfield()", V3Dbf->PutField( "CFLD", "AAA" ), XB_NO_ERROR );
+ iRc += TestMethod( iPo, "Putfield()", V3Dbf->PutField( "DFLD", "19611109" ), XB_NO_ERROR );
+ iRc += TestMethod( iPo, "PutfieldDouble()", V3Dbf->PutDoubleField( "NFLD", 50 ), XB_NO_ERROR );
+ iRc += TestMethod( iPo, "AppendRecord()", V3Dbf->AppendRecord(), XB_NO_ERROR );
+
+ iRc += TestMethod( iPo, "BlankRecord()", V3Dbf->BlankRecord(), XB_NO_ERROR );
+ iRc += TestMethod( iPo, "Putfield()", V3Dbf->PutField( "CFLD", "BBB" ), XB_NO_ERROR );
+ iRc += TestMethod( iPo, "Putfield()", V3Dbf->PutField( "DFLD", "19611109" ), XB_NO_ERROR );
+ iRc += TestMethod( iPo, "PutfieldDouble()", V3Dbf->PutDoubleField( "NFLD", 50 ), XB_NO_ERROR );
+ iRc += TestMethod( iPo, "AppendRecord()", V3Dbf->AppendRecord(), XB_NO_ERROR );
+
+ iRc += TestMethod( iPo, "BlankRecord()", V3Dbf->BlankRecord(), XB_NO_ERROR );
+ iRc += TestMethod( iPo, "Putfield()", V3Dbf->PutField( "CFLD", "BBB" ), XB_NO_ERROR );
+ iRc += TestMethod( iPo, "Putfield()", V3Dbf->PutField( "DFLD", "19611109" ), XB_NO_ERROR );
+ iRc += TestMethod( iPo, "PutfieldDouble()", V3Dbf->PutDoubleField( "NFLD", 50 ), XB_NO_ERROR );
+ iRc += TestMethod( iPo, "AppendRecord()", V3Dbf->AppendRecord(), XB_NO_ERROR );
+
+
+ ixl = V3Dbf->GetIxList();
+ while( ixl ){
+ if( *ixl->sFmt == "NDX" ){
+ ix = (xbIxNdx *) ixl->ix;
+ //ix->GetTagName( 0, sTagName );
+ sMsg.Sprintf( "CheckTagIntegrity() - [%s]", ix->GetTagName(ix->GetCurTag()).Str());
+ iRc += TestMethod( iPo, sMsg, ix->CheckTagIntegrity( ix->GetCurTag(), 2 ), XB_NO_ERROR );
+ ixl = ixl->next;
+ }
+ }
+
+ iRc += TestMethod( iPo, "DeleteTable()", V3Dbf->DeleteTable(), XB_NO_ERROR );
+
if( iPo > 0 || iRc < 0 )
fprintf( stdout, "Total Errors = %d\n", iRc * -1 );
-#ifdef XB_LOGGING_SUPPORT
+ #ifdef XB_LOGGING_SUPPORT
sMsg.Sprintf( "Program [%s] terminating with [%d] errors...", av[0], iRc * -1 );
x.WriteLogMessage( sMsg, 2 );
-#endif
+ #endif
return iRc;
}
diff --git a/src/tests/xb_test_ndx2.cpp b/src/tests/xb_test_ndx2.cpp
deleted file mode 100755
index f406b05..0000000
--- a/src/tests/xb_test_ndx2.cpp
+++ /dev/null
@@ -1,145 +0,0 @@
-/* xb_test_ndx2.cpp
-
-XBase64 Software Library
-
-Copyright (c) 1997,2003,2014, 2022 Gary A Kunkel
-
-The xb64 software library is covered under the terms of the GPL Version 3, 2007 license.
-
-Email Contact:
-
- xb64-devel@lists.sourceforge.net
- xb64-users@lists.sourceforge.net
-
-*/
-
-// This program tests the class xbIxNdx
-
-// usage: xb_test_ndx QUITE|NORMAL|VERBOSE
-
-
-
-// fix me - this program needs to test GetUnique
-
-#include "xbase.h"
-
-using namespace xb;
-
-#include "tstfuncs.cpp"
-
-
-int main( int argCnt, char **av )
-{
- int iRc = 0;
- int iRc2 = 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;
- }
-
-
- xbSchema MyV3Record[] =
- {
- { "CFLD", XB_CHAR_FLD, 30, 0 },
- { "DFLD", XB_DATE_FLD, 8, 0 },
- { "NFLD", XB_NUMERIC_FLD, 12, 0 },
- { "",0,0,0 }
- };
-
-
- xbXBase x;
-#ifdef XB_LOGGING_SUPPORT
- 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 );
- x.SetLogSize( 1000000 );
-#endif
-
- x.SetDataDirectory( PROJECT_DATA_DIR );
- x.EnableMsgLogging();
-// x.DisableDefaultAutoLock();
-
- x.SetUniqueKeyOpt( XB_EMULATE_DBASE );
- InitTime();
- xbString s;
- iRc = 0;
-
- if( po > 0 )
- std::cout << "Default Data Directory is [" << x.GetDataDirectory().Str() << "]" << std::endl;
-
- xbDbf *V3Dbf = new xbDbf3( &x );
- xbIx *ixPtr;
- void *ndx;
-
- iRc2 = V3Dbf->CreateTable( "TestNdx.DBF", "TestNdx", MyV3Record, XB_OVERLAY, XB_MULTI_USER );
- iRc += TestMethod( po, "CreateTable()", (xbInt32) iRc2, XB_NO_ERROR );
-
- if( iRc2 )
- x.DisplayError( iRc2 );
-
- iRc2 = V3Dbf->CreateTag( "NDX", "TestNdxC.NDX", "CFLD", "", 0, xbTrue, XB_OVERLAY, &ixPtr, &ndx );
- iRc += TestMethod( po, "CreateTag()", (xbInt32) iRc2, XB_NO_ERROR );
- if( iRc2 )
- x.DisplayError( iRc2 );
-
- iRc2 = V3Dbf->AssociateIndex( "NDX", "TestNdxC.NDX", 0 );
- iRc += TestMethod( po, "Associate()", (xbInt32) iRc2, XB_NO_ERROR );
-
-
- iRc += TestMethod( po, "BlankRecord()", V3Dbf->BlankRecord(), XB_NO_ERROR );
- iRc += TestMethod( po, "Putfield()", V3Dbf->PutField( "CFLD", "AAA" ), XB_NO_ERROR );
- iRc += TestMethod( po, "Putfield()", V3Dbf->PutField( "DFLD", "19611109" ), XB_NO_ERROR );
- iRc += TestMethod( po, "PutfieldDouble()", V3Dbf->PutDoubleField( "NFLD", 50 ), XB_NO_ERROR );
- iRc += TestMethod( po, "AppendRecord()", V3Dbf->AppendRecord(), XB_NO_ERROR );
-
-
- iRc += TestMethod( po, "BlankRecord()", V3Dbf->BlankRecord(), XB_NO_ERROR );
- iRc += TestMethod( po, "Putfield()", V3Dbf->PutField( "CFLD", "BBB" ), XB_NO_ERROR );
- iRc += TestMethod( po, "Putfield()", V3Dbf->PutField( "DFLD", "19611109" ), XB_NO_ERROR );
- iRc += TestMethod( po, "PutfieldDouble()", V3Dbf->PutDoubleField( "NFLD", 50 ), XB_NO_ERROR );
- iRc += TestMethod( po, "AppendRecord()", V3Dbf->AppendRecord(), XB_NO_ERROR );
-
- iRc += TestMethod( po, "BlankRecord()", V3Dbf->BlankRecord(), XB_NO_ERROR );
- iRc += TestMethod( po, "Putfield()", V3Dbf->PutField( "CFLD", "BBB" ), XB_NO_ERROR );
- iRc += TestMethod( po, "Putfield()", V3Dbf->PutField( "DFLD", "19611109" ), XB_NO_ERROR );
- iRc += TestMethod( po, "PutfieldDouble()", V3Dbf->PutDoubleField( "NFLD", 50 ), XB_NO_ERROR );
- iRc += TestMethod( po, "AppendRecord()", V3Dbf->AppendRecord(), XB_NO_ERROR );
-
-
- xbIxList *ixl = V3Dbf->GetIxList();
- xbIxNdx *ix;
- xbString sTagName;
- while( ixl ){
- if( *ixl->sFmt == "NDX" ){
- ix = (xbIxNdx *) ixl->ix;
- //ix->GetTagName( 0, sTagName );
- sMsg.Sprintf( "CheckTagIntegrity() - [%s]", ix->GetTagName(ix->GetCurTag()).Str());
- iRc += TestMethod( po, sMsg, ix->CheckTagIntegrity( ix->GetCurTag(), 2 ), XB_NO_ERROR );
- ixl = ixl->next;
- }
- }
-
- iRc += TestMethod( po, "Close()", V3Dbf->Close(), XB_NO_ERROR );
- delete V3Dbf;
-
- if( po > 0 || iRc < 0 )
- fprintf( stdout, "Total Errors = %d\n", iRc * -1 );
-
-#ifdef XB_LOGGING_SUPPORT
- sMsg.Sprintf( "Program [%s] terminating with [%d] errors...", av[0], iRc * -1 );
- x.WriteLogMessage( sMsg, 2 );
-#endif
-
- return iRc;
-}
diff --git a/src/tests/xb_test_sql.cpp b/src/tests/xb_test_sql.cpp
index 630cc89..20c8514 100755
--- a/src/tests/xb_test_sql.cpp
+++ b/src/tests/xb_test_sql.cpp
@@ -35,6 +35,8 @@ int main( int argCnt, char **av )
/* 1 - NORMAL */
/* 2 - VERBOSE */
+ xbString sSql;
+
if( argCnt > 1 ) {
if( av[1][0] == 'Q' )
po = 0;
@@ -56,7 +58,7 @@ int main( int argCnt, char **av )
xbXBase x;
-#ifdef XB_LOGGING_SUPPORT
+ #ifdef XB_LOGGING_SUPPORT
x.EnableMsgLogging();
if( po ){
std::cout << "Logfile is [" << x.GetLogFqFileName().Str() << "]" << std::endl;
@@ -64,7 +66,7 @@ int main( int argCnt, char **av )
xbString sMsg;
sMsg.Sprintf( "Program [%s] initializing...", av[0] );
x.WriteLogMessage( sMsg );
-#endif
+ #endif
@@ -77,26 +79,108 @@ int main( int argCnt, char **av )
if( po > 0 )
std::cout << "Default Data Directory is [" << x.GetDataDirectory().Str() << "]" << std::endl;
+
xbDbf4 SqlDbf( &x ); // version 4 dbf file
+
+
+ // clean up any things possibly needing cleaned up
+ xbString sDir;
+ SqlDbf.GetFileDirPart( sDir );
+ xbString sDbfName;
+ xbString sDbtName;
+ xbString sMdxName;
+ sDbfName.Sprintf( "%sTestSQL.DBF", sDir.Str());
+ sDbtName.Sprintf( "%sTestSQL.DBR", sDir.Str());
+ sMdxName.Sprintf( "%sTestSQL.MDX", sDir.Str());
+ SqlDbf.xbRemove( sDbfName );
+ SqlDbf.xbRemove( sDbtName );
+ SqlDbf.xbRemove( sMdxName );
+ sDbfName.Sprintf( "%sTestSqlR.DBF", sDir.Str());
+ sDbtName.Sprintf( "%sTestSqlR.DBT", sDir.Str());
+ sMdxName.Sprintf( "%sTestSqlR.MDX", sDir.Str());
+ SqlDbf.xbRemove( sDbfName );
+ SqlDbf.xbRemove( sDbtName );
+ SqlDbf.xbRemove( sMdxName );
+
+
iRc2 = SqlDbf.CreateTable( "TestSQL.DBF", "TestSQL", MySqlRecord, XB_OVERLAY, XB_MULTI_USER );
iRc += TestMethod( po, "CreateTable()", (xbInt32) iRc2, XB_NO_ERROR );
if( iRc2 )
x.DisplayError( iRc2 );
+ #ifdef XB_MDX_SUPPORT
+ sSql = "CREATE INDEX tag1 ON TestSQL.DBF( CITY, STATE, DTOS( LASTUPDATE )) FILTER .NOT. DELETED()";
+ // xbString sSql = "CREATE INDEX tag1 ON TestSQL.DBF( CITY, STATE )";
- xbString sSql = "INSERT INTO TestSQL (CITY, STATE, ZIPCODE, NOTES, LASTUPDATE, ACTIVE ) VALUES ( 'San Diego', 'CA', 92007, 'San Diego is a cool place', '1989-02-09', 'Y')";
+ iRc2 = sql.ExecuteNonQuery( sSql );
+ iRc += TestMethod( po, "SqL CreateIndex()", (xbInt32) iRc2, XB_NO_ERROR );
+ if( iRc2 )
+ x.DisplayError( iRc2 );
+ #endif // XB_MDX_SUPPORT
+ sSql = "INSERT INTO TestSQL (CITY, STATE, ZIPCODE, NOTES, LASTUPDATE, ACTIVE ) VALUES ( 'San Diego', 'CA', 92007, 'San Diego is a cool place', '1989-02-09', 'Y')";
iRc2 = sql.ExecuteNonQuery( sSql );
- iRc += TestMethod( po, "Insert()", (xbInt32) iRc2, XB_NO_ERROR );
+ iRc += TestMethod( po, "SqlInsert()", (xbInt32) iRc2, XB_NO_ERROR );
if( iRc2 )
x.DisplayError( iRc2 );
+ sSql = "INSERT INTO TestSQL (CITY, STATE, ZIPCODE, NOTES, LASTUPDATE, ACTIVE ) VALUES ( 'Dallas', 'TX', 76248, 'Dallas is hot in the summer', '1989-02-09', 'N')";
+ iRc2 = sql.ExecuteNonQuery( sSql );
+ iRc += TestMethod( po, "SqlInsert()", (xbInt32) iRc2, XB_NO_ERROR );
+ if( iRc2 )
+ x.DisplayError( iRc2 );
+
+ sSql = "ALTER TABLE TestSQL.DBF RENAME TO TestSqlR.DBF";
+
+ iRc2 = sql.ExecuteNonQuery( sSql );
+ iRc += TestMethod( po, "SqlAlterTable()", (xbInt32) iRc2, XB_NO_ERROR );
+ if( iRc2 )
+ x.DisplayError( iRc2 );
+
+ x.DisplayTableList();
+
+
+ sSql = "DELETE FROM TestSqlR.DBF WHERE CITY='San Diego'";
+ iRc2 = sql.ExecuteNonQuery( sSql );
+ iRc += TestMethod( po, "SqlDelete()", (xbInt32) iRc2, XB_NO_ERROR );
+ if( iRc2 )
+ x.DisplayError( iRc2 );
+
+ sSql = "UNDELETE FROM TestSqlR.DBF WHERE CITY='San Diego'";
+ iRc2 = sql.ExecuteNonQuery( sSql );
+ iRc += TestMethod( po, "SqlUndelete()", (xbInt32) iRc2, XB_NO_ERROR );
+ if( iRc2 )
+ x.DisplayError( iRc2 );
+
+ sSql = "DELETE FROM TestSqlR.DBF";
+ iRc2 = sql.ExecuteNonQuery( sSql );
+ iRc += TestMethod( po, "SqlDelete()", (xbInt32) iRc2, XB_NO_ERROR );
+ if( iRc2 )
+ x.DisplayError( iRc2 );
+
+ sSql = "UNDELETE FROM TestSqlR.DBF";
+ iRc2 = sql.ExecuteNonQuery( sSql );
+ iRc += TestMethod( po, "SqlDelete()", (xbInt32) iRc2, XB_NO_ERROR );
+ if( iRc2 )
+ x.DisplayError( iRc2 );
+
+
+ sSql = "DELETE FROM TestSqlR.DBF WHERE BAD='EXPRESSION'";
+ iRc2 = sql.ExecuteNonQuery( sSql );
+ iRc += TestMethod( po, "SqlDelete()", (xbInt32) iRc2, XB_INVALID_FIELD_NAME );
+// if( iRc2 )
+// x.DisplayError( iRc2 );
+
+
+// sSql = "SELECT CITY, STATE ZIPCODE FROM TestSQL.DBF WHERE CITY IS NOT NULL";
+// iRc += TestMethod( po, "Select()", SqlDbf.Select( sSql ), XB_NO_ERROR );
+
+
iRc += TestMethod( po, "Close()", SqlDbf.Close(), XB_NO_ERROR );
if( po > 0 || iRc < 0 )
fprintf( stdout, "Total Errors = %d\n", iRc * -1 );
-
#ifdef XB_LOGGING_SUPPORT
sMsg.Sprintf( "Program [%s] terminating with [%d] errors...", av[0], iRc * -1 );
x.WriteLogMessage( sMsg );
@@ -105,3 +189,4 @@ int main( int argCnt, char **av )
return iRc;
}
+ \ No newline at end of file
diff --git a/src/tests/xb_test_string.cpp b/src/tests/xb_test_string.cpp
index f39c101..9d730db 100755
--- a/src/tests/xb_test_string.cpp
+++ b/src/tests/xb_test_string.cpp
@@ -43,13 +43,13 @@ int main( int argCnt, char **av = NULL )
}
xbXBase x;
+ xbString sMsg;
#ifdef XB_LOGGING_SUPPORT
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
@@ -305,7 +305,6 @@ int main( int argCnt, char **av = NULL )
s1.Left( 0 );
rc += TestMethod( po, "Left(0) ", s1, "", 0 );
-
char buf[5];
buf[0] = 'W';
buf[1] = 'X';
@@ -362,7 +361,6 @@ int main( int argCnt, char **av = NULL )
free( p );
rc += TestMethod( po, "Set", s1, "1234", 4 );
-
xbDouble d = 12345678.876543;
xbString sD( d );
rc += TestMethod( po, "xbDouble Constructor", sD, "12345678.876543", 15 );
@@ -380,6 +378,13 @@ int main( int argCnt, char **av = NULL )
s3.Sprintf( "%s and %s", s1.Str(), s2.Str());
rc += TestMethod( po, "Sprintf", s3, "string 1 and string 2.0", 23 );
+ s1.Set( "abcdef.dbf" );
+ s1.Replace( "def", "DEF" );
+ rc += TestMethod( po, "Replace", s1, "abcDEF.dbf", 10 );
+ s1.Replace( ".dbf", ".DBF" );
+ rc += TestMethod( po, "Replace", s1, "abcDEF.DBF", 10 );
+
+
xbInt16 iErrorStop = 10;
xbInt16 iRc = -100;
sMsg.Sprintf( "class::method() Exception Caught. Error Stop = [%d] iRc = [%d] Expression = [%s]", iErrorStop, iRc, s3.Str() );
@@ -387,10 +392,10 @@ int main( int argCnt, char **av = NULL )
if( po > 0 || rc < 0 )
fprintf( stdout, "Total Errors = %d\n", rc * -1 );
-#ifdef XB_LOGGING_SUPPORT
+ #ifdef XB_LOGGING_SUPPORT
sMsg.Sprintf( "Program [%s] terminating with [%d] errors...", av[0], rc * -1 );
x.WriteLogMessage( sMsg );
-#endif
+ #endif
return rc;
}
diff --git a/src/tests/xb_test_tblmgr.cpp b/src/tests/xb_test_tblmgr.cpp
index 26ec96a..451432c 100755
--- a/src/tests/xb_test_tblmgr.cpp
+++ b/src/tests/xb_test_tblmgr.cpp
@@ -54,11 +54,11 @@ int main( int argCnt, char **av )
if( po == 2 ){
std::cout << "DisplayError Test ==> ";
x.DisplayError( 0 );
- #ifdef WIN32
- std::cout << "WIN32 environment" << std::endl;
- #else
- std::cout << "Not WIN32 environment" << std::endl;
- #endif
+ #ifdef WIN32
+ std::cout << "WIN32 environment" << std::endl;
+ #else
+ std::cout << "Not WIN32 environment" << std::endl;
+ #endif
}
xbDbf * d1;
@@ -77,8 +77,8 @@ int main( int argCnt, char **av )
rc += TestMethod( po, "AddTblToTblLst()", x.AddTblToTblList( d1, "TestTableA" ), 0 );
rc += TestMethod( po, "AddTblToTblLst()", x.AddTblToTblList( d1, "TestTableB" ), 0 );
rc += TestMethod( po, "AddTblToTblLst()", x.AddTblToTblList( d1, "TestTableD" ), 0 );
-
-
+
+
// Next line should generate an exception
rc += TestMethod( po, "AddTblToTblLst()", x.AddTblToTblList( d1, "TestTableC" ), XB_DUP_TABLE_OR_ALIAS );
diff --git a/src/tests/xb_test_xbase.cpp b/src/tests/xb_test_xbase.cpp
index 6dad3f7..9d523c5 100755
--- a/src/tests/xb_test_xbase.cpp
+++ b/src/tests/xb_test_xbase.cpp
@@ -39,25 +39,22 @@ int main( int argCnt, char **av )
po = 2;
}
-
xbXBase x;
+ xbString sMsg;
-
-#ifdef XB_LOGGING_SUPPORT
+ #ifdef XB_LOGGING_SUPPORT
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
+ #endif
InitTime();
x.SetDefaultDateFormat( "YY-MM-DD" );
iRc += TestMethod( po, "SetDefaultDateFormat", x.GetDefaultDateFormat(), "YY-MM-DD", 8 );
-
if( po == 2 ){
if( x.GetEndianType() == 'L' )
std::cout << "Little Endian Architecture" << std::endl;
@@ -70,7 +67,7 @@ int main( int argCnt, char **av )
iRc += TestMethod( po, "GetErrorMessage", x.GetErrorMessage( XB_DBF_FILE_NOT_OPEN ), "DBF File Not Open", 17 );
-#ifdef XB_LOGGING_SUPPORT
+ #ifdef XB_LOGGING_SUPPORT
xbString sLogDir = PROJECT_LOG_DIR;
iRc += TestMethod( po, "GetDefaultLogDirectory()", x.GetDefaultLogDirectory(), sLogDir, sLogDir.Len());
@@ -81,11 +78,10 @@ int main( int argCnt, char **av )
iRc += TestMethod( po, "GetDefaultLogFileName()", x.GetDefaultLogFileName(), sLogName, sLogName.Len());
x.WriteLogMessage( "test" );
-#endif
+ #endif
x.xbSleep( 250 );
-
if( po == 2 ){
std::cout << "DisplayError Test ==> ";