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.cpp55
1 files changed, 51 insertions, 4 deletions
diff --git a/src/tests/xb_test_ndx.cpp b/src/tests/xb_test_ndx.cpp
index 34496b6..320a1c9 100755
--- a/src/tests/xb_test_ndx.cpp
+++ b/src/tests/xb_test_ndx.cpp
@@ -117,6 +117,14 @@ int main( int argCnt, char **av )
iRc2 = V3Dbf->AssociateIndex( "NDX", "TestNdxN.NDX", 0 );
iRc += TestMethod( iPo, "Associate()", (xbInt32) iRc2, XB_NO_ERROR );
+ xbInt16 iTagCnt = ixPtr->GetTagCount();
+ iRc += TestMethod( iPo, "GetTagCount()", (xbInt32) iTagCnt, 1 );
+
+ xbString sTagName;
+ sTagName = ixPtr->GetTagName( &ndx );
+ iRc += TestMethod( iPo, "GetTagName()", sTagName.Str(), "TestNdxN", 8 );
+
+
#ifdef XB_LOCKING_SUPPORT
iRc += TestMethod( iPo, "LockTable()", V3Dbf->LockTable( XB_LOCK ), XB_NO_ERROR );
#endif
@@ -307,13 +315,12 @@ int main( int argCnt, char **av )
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( iPo, sMsg, ix->CheckTagIntegrity( ix->GetCurTag(), 2 ), XB_NO_ERROR );
+ iRc += TestMethod( iPo, sMsg, ix->CheckTagIntegrity( ix->GetCurTag(), 0 ), XB_NO_ERROR );
ixl = ixl->next;
}
}
@@ -382,14 +389,54 @@ int main( int argCnt, char **av )
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 );
+ iRc += TestMethod( iPo, sMsg, ix->CheckTagIntegrity( ix->GetCurTag(), 0 ), XB_NO_ERROR );
}
ixl = ixl->next;
}
-// iRc += TestMethod( iPo, "DeleteTable()", V3Dbf->DeleteTable(), XB_NO_ERROR );
+ iRc2 = V3Dbf->Reindex( 1 ); // reindex all tags
+ iRc += TestMethod( iPo, "Reindex()", (xbInt32) iRc2, XB_NO_ERROR );
+
+ iRc += TestMethod( iPo, "DeleteTable()", V3Dbf->DeleteTable(), XB_NO_ERROR );
+
+
+
+ // test tag delete on unsuccessful reindex
+
+ iRc2 = V3Dbf->CreateTable( "TestNdx.DBF", "TestNdx", MyV3Record, XB_OVERLAY, XB_MULTI_USER );
+ iRc += TestMethod( iPo, "CreateTable()", (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 );
+
+ iRc2 = V3Dbf->Reindex( 1 ); // verify reindex works with no tags
+ iRc += TestMethod( iPo, "Reindex()", (xbInt32) iRc2, XB_NO_ERROR );
+
+
+ x.SetUniqueKeyOpt( XB_HALT_ON_DUPKEY );
+ iRc2 = V3Dbf->CreateTag( "NDX", "TestNdxX.NDX", "CFLD", "", 0, 1, XB_OVERLAY, &ixPtr, &ndx );
+ iRc += TestMethod( iPo, "CreateTag()", (xbInt32) iRc2, XB_NO_ERROR );
+
+ iRc2 = V3Dbf->Reindex( 1 ); // verify reindex fails with dup key
+ iRc += TestMethod( iPo, "Reindex()", (xbInt32) iRc2, XB_KEY_NOT_UNIQUE );
x.CloseAllTables();
+// delete V3Dbf;
if( iPo > 0 || iRc < 0 )
fprintf( stdout, "Total Errors = %d\n", iRc * -1 );