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