summaryrefslogtreecommitdiff
path: root/src/tests/xb_test_filter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/xb_test_filter.cpp')
-rwxr-xr-xsrc/tests/xb_test_filter.cpp100
1 files changed, 55 insertions, 45 deletions
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 );