diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2023-03-11 18:15:37 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2023-03-11 18:15:37 +0100 |
commit | dd70ff8bf32c2d7ed365004b1770058265db1978 (patch) | |
tree | 084788d142d86c4dc38f5c48606523b4040596e6 /src/tests | |
parent | 517ad9d4b6eae320b708d03a9340a22893b0cab7 (diff) |
New upstream version 4.1.0upstream/4.1.0
Diffstat (limited to 'src/tests')
-rwxr-xr-x | src/tests/xb_test_bcd.cpp | 5 | ||||
-rwxr-xr-x | src/tests/xb_test_blockread.cpp | 168 | ||||
-rwxr-xr-x | src/tests/xb_test_date.cpp | 7 | ||||
-rwxr-xr-x | src/tests/xb_test_dbf_v3_memos.cpp | 4 | ||||
-rwxr-xr-x | src/tests/xb_test_dbf_v3_nomemos.cpp | 10 | ||||
-rwxr-xr-x | src/tests/xb_test_dbf_v4_memos.cpp | 10 | ||||
-rwxr-xr-x | src/tests/xb_test_dbf_v4_nomemos.cpp | 29 | ||||
-rwxr-xr-x | src/tests/xb_test_expnode.cpp | 4 | ||||
-rwxr-xr-x | src/tests/xb_test_expression.cpp | 7 | ||||
-rwxr-xr-x | src/tests/xb_test_file.cpp | 3 | ||||
-rwxr-xr-x | src/tests/xb_test_filter.cpp | 8 | ||||
-rwxr-xr-x | src/tests/xb_test_funcs.cpp | 3 | ||||
-rwxr-xr-x | src/tests/xb_test_linklist.cpp | 8 | ||||
-rwxr-xr-x | src/tests/xb_test_lock.cpp | 4 | ||||
-rwxr-xr-x | src/tests/xb_test_lock2.cpp | 5 | ||||
-rwxr-xr-x | src/tests/xb_test_log.cpp | 15 | ||||
-rwxr-xr-x | src/tests/xb_test_mdx.cpp | 70 | ||||
-rwxr-xr-x | src/tests/xb_test_ndx.cpp | 15 | ||||
-rwxr-xr-x | src/tests/xb_test_sql.cpp | 151 | ||||
-rwxr-xr-x | src/tests/xb_test_string.cpp | 11 | ||||
-rwxr-xr-x | src/tests/xb_test_tblmgr.cpp | 81 | ||||
-rwxr-xr-x | src/tests/xb_test_uda.cpp | 9 | ||||
-rwxr-xr-x | src/tests/xb_test_xbase.cpp | 44 |
23 files changed, 481 insertions, 190 deletions
diff --git a/src/tests/xb_test_bcd.cpp b/src/tests/xb_test_bcd.cpp index 1eab20f..f735935 100755 --- a/src/tests/xb_test_bcd.cpp +++ b/src/tests/xb_test_bcd.cpp @@ -2,7 +2,7 @@ XBase64 Software Library -Copyright (c) 1997,2003,2014,2017,2022 Gary A Kunkel +Copyright (c) 1997,2003,2014,2017,2022,2023 Gary A Kunkel The xb64 software library is covered under the terms of the GPL Version 3, 2007 license. @@ -45,6 +45,7 @@ int main( int argCnt, char **av ) xbXBase x; #ifdef XB_LOGGING_SUPPORT + x.SetLogDirectory( PROJECT_LOG_DIR ); x.EnableMsgLogging(); if( iPo ){ std::cout << "Logfile is [" << x.GetLogFqFileName().Str() << "]" << std::endl; @@ -55,8 +56,6 @@ int main( int argCnt, char **av ) #endif x.SetDataDirectory( PROJECT_DATA_DIR ); - x.EnableMsgLogging(); - if( iPo > 0 ){ std::cout << "XBase bcd testing program.." << std::endl; diff --git a/src/tests/xb_test_blockread.cpp b/src/tests/xb_test_blockread.cpp new file mode 100755 index 0000000..ff55d23 --- /dev/null +++ b/src/tests/xb_test_blockread.cpp @@ -0,0 +1,168 @@ +/* xb_test_blockread.cpp + +XBase64 Software Library + +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 class xbBlockRead +// usage: xb_test_blockread QUITE|NORMAL|VERBOSE + + +#include "xbase.h" + +using namespace xb; + +#include "tstfuncs.cpp" + + xbSchema MyDbfRec[] = + { + { "NFLD", XB_NUMERIC_FLD, 10, 0 }, + { "CFLD", XB_CHAR_FLD, 89, 0 }, + { "",0,0,0 } + }; + + +int main( int argCnt, char **av ) +{ + xbInt16 iRc = 0; + xbInt16 iRc2 = 0; + int iPo = 1; /* print option */ + /* 0 - QUIET */ + /* 1 - NORMAL */ + /* 2 - VERBOSE */ + + if( argCnt > 1 ) { + if( av[1][0] == 'Q' ) + iPo = 0; + else if( av[1][0] == 'V' ) + iPo = 2; + } + + xbXBase x; + x.SetDataDirectory( PROJECT_DATA_DIR ); + + xbDbf4 dbf( &x ); + + #ifdef XB_LOGGING_SUPPORT + x.SetLogDirectory( PROJECT_LOG_DIR ); + 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 ); + #endif + + + InitTime(); + + + iRc2 = dbf.CreateTable( "BLOCKRD.DBF", "BlockRead", MyDbfRec, XB_OVERLAY, XB_MULTI_USER ); + iRc += TestMethod( iPo, "CreateTable()", (xbInt32) iRc2, XB_NO_ERROR ); + if( iRc2 ) + x.DisplayError( iRc2 ); + + + // fill the file with several blocks of data + for( xbInt32 i = 0; i < 50; i++ ){ + iRc2 = dbf.BlankRecord(); + if( iRc2 != XB_NO_ERROR ) + iRc += TestMethod( iPo, "BlankRecord()", (xbInt32) iRc2, XB_NO_ERROR ); + + iRc2 = dbf.PutLongField( 0, i+1 ); + if( iRc2 != XB_NO_ERROR ) + iRc += TestMethod( iPo, "PutLongField()", (xbInt32) iRc2, XB_NO_ERROR ); + + iRc2 = dbf.AppendRecord(); + if( iRc2 != XB_NO_ERROR ) + iRc += TestMethod( iPo, "AppendRecord()", (xbInt32) iRc2, XB_NO_ERROR ); + + iRc2 = dbf.Commit(); + if( iRc2 != XB_NO_ERROR ) + iRc += TestMethod( iPo, "Commit()", (xbInt32) iRc2, XB_NO_ERROR ); + } + + + dbf.SetDefaultBlockReadSize( 2000 ); + + // enable block read for this table + iRc += TestMethod( iPo, "EnableBlockReadProcessing()", dbf.EnableBlockReadProcessing(), XB_NO_ERROR ); + + xbUInt32 ulFld = 0; + xbUInt32 ulCtr = 1; + + iRc2 = XB_NO_ERROR; + while( iRc2 == XB_NO_ERROR ){ + // std::cout << ulCtr << "\n"; + iRc2 += dbf.GetRecord( ulCtr ); + if( iRc2 != XB_NO_ERROR && iRc != XB_INVALID_RECORD ) + TestMethod( iPo, "GetRecord()", iRc, XB_NO_ERROR ); + + if( iRc2 == XB_NO_ERROR ){ + dbf.GetULongField( "NFLD", ulFld ); + if( ulFld != ulCtr ){ + std::cout << "ulFld = " << ulFld << " ulCtr = " << ulCtr << "\n"; + iRc += TestMethod( iPo, "Field Compare", (xbDouble) ulFld, (xbDouble) ulCtr ); + } + } + ulCtr++; + } + + // std::cout << "**********Delete every other record\n"; + iRc2 = dbf.GetFirstRecord(); + while( iRc2 == XB_NO_ERROR ){ + if( (dbf.GetCurRecNo() % 2) != 0 ){ + dbf.DeleteRecord(); + dbf.Commit(); + } + iRc2 = dbf.GetNextRecord(); + } + + + // test filter for deleted records + #ifdef XB_FILTER_SUPPORT + xbFilter f( &dbf ); + xbString sFilt = ".NOT. DELETED()"; + f.Set( sFilt ); + iRc2 = f.GetFirstRecord(); + while( iRc2 == XB_NO_ERROR ){ + dbf.GetULongField( "NFLD", ulFld ); + if( (ulFld % 2) != 0 ){ + iRc += TestMethod( iPo, "Filter GetNextRecord()", ulFld % 2, 0 ); + } + iRc2 = f.GetNextRecord(); + } + #endif // XB_FILTER_SUPPORT + + + iRc += TestMethod( iPo, "DisableBlockReadProcessing()", dbf.DisableBlockReadProcessing(), XB_NO_ERROR ); + //iRc2 = dbf.DeleteTable(); + + iRc2 = dbf.Close(); + iRc += TestMethod( iPo, "Close()", (xbInt32) iRc2, XB_NO_ERROR ); + if( iRc2 ) + x.DisplayError( iRc2 ); + + + #ifdef XB_LOGGING_SUPPORT + sMsg.Sprintf( "Program [%s] terminating with [%d] errors...", av[0], iRc * -1 ); + x.WriteLogMessage( sMsg ); + #endif + + + if( iPo > 0 || iRc < 0 ) + fprintf( stdout, "Total Errors = %d\n", iRc * -1 ); + + return iRc; +} + diff --git a/src/tests/xb_test_date.cpp b/src/tests/xb_test_date.cpp index 1d9b523..7aee584 100755 --- a/src/tests/xb_test_date.cpp +++ b/src/tests/xb_test_date.cpp @@ -2,7 +2,7 @@ XBase64 Software Library -Copyright (c) 1997,2003,2014,2022 Gary A Kunkel +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. @@ -40,8 +40,9 @@ int main( int argCnt, char **av ) po = 2; } -#ifdef XB_LOGGING_SUPPORT xbXBase x; + #ifdef XB_LOGGING_SUPPORT + x.SetLogDirectory( PROJECT_LOG_DIR ); x.EnableMsgLogging(); if( po ){ std::cout << "Logfile is [" << x.GetLogFqFileName().Str() << "]" << std::endl; @@ -49,7 +50,7 @@ int main( int argCnt, char **av ) xbString sMsg; sMsg.Sprintf( "Program [%s] initializing...", av[0] ); x.WriteLogMessage( sMsg ); -#endif + #endif InitTime(); xbDate d1; diff --git a/src/tests/xb_test_dbf_v3_memos.cpp b/src/tests/xb_test_dbf_v3_memos.cpp index ad3e8e0..e42edb1 100755 --- a/src/tests/xb_test_dbf_v3_memos.cpp +++ b/src/tests/xb_test_dbf_v3_memos.cpp @@ -2,7 +2,7 @@ XBase64 Software Library -Copyright (c) 1997,2003,2014,2022 Gary A Kunkel +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. @@ -55,6 +55,7 @@ int main( int argCnt, char **av ) xbXBase x; #ifdef XB_LOGGING_SUPPORT + x.SetLogDirectory( PROJECT_LOG_DIR ); x.EnableMsgLogging(); if( po ){ std::cout << "Logfile is [" << x.GetLogFqFileName().Str() << "]" << std::endl; @@ -65,7 +66,6 @@ int main( int argCnt, char **av ) #endif x.SetDataDirectory( PROJECT_DATA_DIR ); - x.EnableMsgLogging(); #ifdef XB_LOCKING_SUPPORT x.DisableDefaultAutoLock(); diff --git a/src/tests/xb_test_dbf_v3_nomemos.cpp b/src/tests/xb_test_dbf_v3_nomemos.cpp index e5adc48..2dfeb7e 100755 --- a/src/tests/xb_test_dbf_v3_nomemos.cpp +++ b/src/tests/xb_test_dbf_v3_nomemos.cpp @@ -2,7 +2,7 @@ XBase64 Software Library -Copyright (c) 1997,2003,2014,2022 Gary A Kunkel +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. @@ -59,7 +59,8 @@ int main( int argCnt, char **av ) xbXBase x; -#ifdef XB_LOGGING_SUPPORT + #ifdef XB_LOGGING_SUPPORT + x.SetLogDirectory( PROJECT_LOG_DIR ); x.EnableMsgLogging(); if( po ){ std::cout << "Logfile is [" << x.GetLogFqFileName().Str() << "]" << std::endl; @@ -67,10 +68,9 @@ 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(); @@ -97,7 +97,7 @@ int main( int argCnt, char **av ) xbDbf3 V3Dbf2( &x ); // next occurrence should error as a dup - x.WriteLogMessage( "Second create attempt" ); + x.WriteLogMessage( "Second create attempt, should generate an error." ); iRc2 = V3Dbf2.CreateTable( "TestV3.DBF", "TestV3", MyV3Record, XB_DONTOVERLAY, XB_MULTI_USER ); iRc += TestMethod( po, "CreateTable()", iRc2, XB_FILE_EXISTS ); if( iRc2 != XB_FILE_EXISTS ){ diff --git a/src/tests/xb_test_dbf_v4_memos.cpp b/src/tests/xb_test_dbf_v4_memos.cpp index 2b0e09c..47a9053 100755 --- a/src/tests/xb_test_dbf_v4_memos.cpp +++ b/src/tests/xb_test_dbf_v4_memos.cpp @@ -2,7 +2,7 @@ XBase64 Software Library -Copyright (c) 1997,2003,2014,2022 Gary A Kunkel +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. @@ -47,8 +47,8 @@ int main( int argCnt, char **av ) xbXBase x; -#ifdef XB_LOGGING_SUPPORT - + #ifdef XB_LOGGING_SUPPORT + x.SetLogDirectory( PROJECT_LOG_DIR ); x.EnableMsgLogging(); if( po ){ std::cout << "Logfile is [" << x.GetLogFqFileName().Str() << "]" << std::endl; @@ -56,11 +56,9 @@ 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(); diff --git a/src/tests/xb_test_dbf_v4_nomemos.cpp b/src/tests/xb_test_dbf_v4_nomemos.cpp index 4036588..984eb63 100755 --- a/src/tests/xb_test_dbf_v4_nomemos.cpp +++ b/src/tests/xb_test_dbf_v4_nomemos.cpp @@ -2,7 +2,7 @@ XBase Software Library -Copyright (c) 1997,2003,2014,2022 Gary A Kunkel +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. @@ -56,9 +56,19 @@ int main( int argCnt, char **av ) { "",0,0,0 } }; + xbSchema MyV4ZipRecord[] = + { + { "ZIPCODE", XB_NUMERIC_FLD, 5, 0 }, + { "CITY", XB_CHAR_FLD, 30, 0 }, + { "STATE", XB_CHAR_FLD, 2, 0 }, + { "",0,0,0 } + }; + + xbXBase x; #ifdef XB_LOGGING_SUPPORT + x.SetLogDirectory( PROJECT_LOG_DIR ); x.EnableMsgLogging(); if( po ){ std::cout << "Logfile is [" << x.GetLogFqFileName().Str() << "]" << std::endl; @@ -69,7 +79,6 @@ int main( int argCnt, char **av ) #endif x.SetDataDirectory( PROJECT_DATA_DIR ); - x.EnableMsgLogging(); #ifdef XB_LOCKING_SUPPORT x.DisableDefaultAutoLock(); @@ -318,10 +327,26 @@ int main( int argCnt, char **av ) rc += TestMethod( po, "GetField()", V4Dbf.GetField( fldAMT, sf ), XB_NO_ERROR ); rc += TestMethod( po, "GetField()", sf, " 432.55", 9 ); + + xbDbf4 V4DbfZ( &x ); // version 4 dbf file + rc2 = V4DbfZ.CreateTable( "TestV4Zip.DBF", "TestV4Zip", MyV4ZipRecord, XB_OVERLAY, XB_MULTI_USER ); + rc += TestMethod( po, "CreateTable()", (xbInt32) rc2, XB_NO_ERROR ); + if( rc2 ) + x.DisplayError( rc2 ); + + + rc += TestMethod( po, "Close()", V4Dbf.Close(), XB_NO_ERROR ); if( po == 2 ) x.DisplayTableList(); + + rc += TestMethod( po, "Close()", V4DbfZ.Close(), XB_NO_ERROR ); + if( po == 2 ) + x.DisplayTableList(); + + + if( po > 0 || rc < 0 ) fprintf( stdout, "Total Errors = %d\n", rc * -1 ); diff --git a/src/tests/xb_test_expnode.cpp b/src/tests/xb_test_expnode.cpp index 3fb716d..cbd79c9 100755 --- a/src/tests/xb_test_expnode.cpp +++ b/src/tests/xb_test_expnode.cpp @@ -2,7 +2,7 @@ XBase Software Library -Copyright (c) 1997,2003,2014,2017,2022 Gary A Kunkel +Copyright (c) 1997,2003,2014,2017,2022,2023 Gary A Kunkel The xb64 software library is covered under the terms of the GPL Version 3, 2007 license. @@ -42,6 +42,7 @@ int main( int argCnt, char **av ) xbXBase x; #ifdef XB_LOGGING_SUPPORT + x.SetLogDirectory( PROJECT_LOG_DIR ); x.EnableMsgLogging(); if( po ){ std::cout << "Logfile is [" << x.GetLogFqFileName().Str() << "]" << std::endl; @@ -52,7 +53,6 @@ int main( int argCnt, char **av ) #endif x.SetDataDirectory( PROJECT_DATA_DIR ); - x.EnableMsgLogging(); InitTime(); if( po > 0 ){ diff --git a/src/tests/xb_test_expression.cpp b/src/tests/xb_test_expression.cpp index 75ed3e5..ac1cde7 100755 --- a/src/tests/xb_test_expression.cpp +++ b/src/tests/xb_test_expression.cpp @@ -2,7 +2,7 @@ XBase Software Library -Copyright (c) 1997,2003,2014,2022 Gary A Kunkel +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. @@ -67,7 +67,7 @@ xbInt16 DevTester( xbXBase * xb, xbDbf * dbf, const char * sExpIn ){ if( iRc == XB_NO_ERROR ){ #ifdef XB_DEBUG_SUPPORT exp.DumpTree( xbTrue ); - #endif // XB_DEBUG_SUPPORT + #endif // XB_DEBUG_SUPPORT std::cout << "dump nodes\n"; n = exp.GetNextNodeTest( NULL ); if( !n ){ @@ -86,7 +86,6 @@ xbInt16 DevTester( xbXBase * xb, xbDbf * dbf, const char * sExpIn ){ std::cout << "Parse Error [" << iRc << "]\n"; return -1; } - return 0; } /**************************************************************************/ @@ -394,6 +393,7 @@ int main( int argCnt, char **av ) xbDate d; #ifdef XB_LOGGING_SUPPORT + x.SetLogDirectory( PROJECT_LOG_DIR ); x.EnableMsgLogging(); if( po ){ std::cout << "Logfile is [" << x.GetLogFqFileName().Str() << "]" << std::endl; @@ -404,7 +404,6 @@ int main( int argCnt, char **av ) #endif x.SetDataDirectory( PROJECT_DATA_DIR ); - x.EnableMsgLogging(); InitTime(); if( po > 0 ){ diff --git a/src/tests/xb_test_file.cpp b/src/tests/xb_test_file.cpp index 4614805..cf835c2 100755 --- a/src/tests/xb_test_file.cpp +++ b/src/tests/xb_test_file.cpp @@ -1,6 +1,6 @@ /* xb_test_file.cpp -Copyright (c) 1997,2003,2014,2022 Gary A Kunkel +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. @@ -42,6 +42,7 @@ int main( int argCnt, char **av ) xbXBase x; #ifdef XB_LOGGING_SUPPORT + x.SetLogDirectory( PROJECT_LOG_DIR ); x.EnableMsgLogging(); if( po ){ std::cout << "Logfile is [" << x.GetLogFqFileName().Str() << "]" << std::endl; diff --git a/src/tests/xb_test_filter.cpp b/src/tests/xb_test_filter.cpp index ac4b896..000e196 100755 --- a/src/tests/xb_test_filter.cpp +++ b/src/tests/xb_test_filter.cpp @@ -2,7 +2,7 @@ XBase64 Software Library -Copyright (c) 1997,2003,2014,2020,2022 Gary A Kunkel +Copyright (c) 1997,2003,2014,2020,2022,2023 Gary A Kunkel The xb64 software library is covered under the terms of the GPL Version 3, 2007 license. @@ -41,7 +41,6 @@ int main( int argCnt, char **av ) iPo = 2; } - xbSchema MyV4Record[] = { { "CFLD", XB_CHAR_FLD, 6, 0 }, @@ -50,9 +49,9 @@ int main( int argCnt, char **av ) { "",0,0,0 } }; - xbXBase x; #ifdef XB_LOGGING_SUPPORT + x.SetLogDirectory( PROJECT_LOG_DIR ); x.EnableMsgLogging(); if( iPo ){ std::cout << "Logfile is [" << x.GetLogFqFileName().Str() << "]" << std::endl; @@ -64,7 +63,6 @@ int main( int argCnt, char **av ) #endif x.SetDataDirectory( PROJECT_DATA_DIR ); - x.EnableMsgLogging(); char c; xbString s; @@ -114,7 +112,7 @@ int main( int argCnt, char **av ) iRc += TestMethod( iPo, "SetCurTag()", MyFile->SetCurTag( "" ), XB_NO_ERROR ); #endif // XB_INDEX_SUPPORT - xbFilter f1( &x, MyFile ); + xbFilter f1( MyFile ); xbString sMyFilterExpression = "LEFT( CFLD, 2 ) = 'YY'"; iRc += TestMethod( iPo, "Set()", f1.Set( sMyFilterExpression ), XB_NO_ERROR ); diff --git a/src/tests/xb_test_funcs.cpp b/src/tests/xb_test_funcs.cpp index e8b73b0..c7bf0d3 100755 --- a/src/tests/xb_test_funcs.cpp +++ b/src/tests/xb_test_funcs.cpp @@ -2,7 +2,7 @@ XBase64 Software Library -Copyright (c) 1997,2003,2014,2022 Gary A Kunkel +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. @@ -61,6 +61,7 @@ int main( int argCnt, char **av ) #ifdef XB_LOGGING_SUPPORT + x.SetLogDirectory( PROJECT_LOG_DIR ); x.EnableMsgLogging(); if( po ){ std::cout << "Logfile is [" << x.GetLogFqFileName().Str() << "]" << std::endl; diff --git a/src/tests/xb_test_linklist.cpp b/src/tests/xb_test_linklist.cpp index dc253af..288ee99 100755 --- a/src/tests/xb_test_linklist.cpp +++ b/src/tests/xb_test_linklist.cpp @@ -2,7 +2,7 @@ XBase64 Software Library -Copyright (c) 1997,2003,2014,2022 Gary A Kunkel +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. @@ -42,7 +42,8 @@ int main( int argCnt, char **av ) } xbXBase x; -#ifdef XB_LOGGING_SUPPORT + #ifdef XB_LOGGING_SUPPORT + x.SetLogDirectory( PROJECT_LOG_DIR ); x.EnableMsgLogging(); if( po ){ std::cout << "Logfile is [" << x.GetLogFqFileName().Str() << "]" << std::endl; @@ -50,7 +51,8 @@ int main( int argCnt, char **av ) xbString sMsg; sMsg.Sprintf( "Program [%s] initializing...", av[0] ); x.WriteLogMessage( sMsg ); -#endif + #endif + InitTime(); xbLinkList<xbString> ll; diff --git a/src/tests/xb_test_lock.cpp b/src/tests/xb_test_lock.cpp index 7e9865b..39332ad 100755 --- a/src/tests/xb_test_lock.cpp +++ b/src/tests/xb_test_lock.cpp @@ -2,7 +2,7 @@ XBase64 Software Library -Copyright (c) 1997,2003,2014,2022 Gary A Kunkel +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. @@ -59,6 +59,7 @@ int main( int argCnt, char **av ) #ifdef XB_LOGGING_SUPPORT + x.SetLogDirectory( PROJECT_LOG_DIR ); x.EnableMsgLogging(); if( po > 0 ){ std::cout << "Logfile is [" << x.GetLogFqFileName().Str() << "]" << std::endl; @@ -69,7 +70,6 @@ int main( int argCnt, char **av ) #endif x.SetDataDirectory( PROJECT_DATA_DIR ); - x.EnableMsgLogging(); InitTime(); #ifdef XB_DBF4_SUPPORT MyFile = new xbDbf4( &x ); /* version 4 dbf file */ diff --git a/src/tests/xb_test_lock2.cpp b/src/tests/xb_test_lock2.cpp index 3dd4b57..d5534ec 100755 --- a/src/tests/xb_test_lock2.cpp +++ b/src/tests/xb_test_lock2.cpp @@ -2,7 +2,7 @@ XBase Software Library -Copyright (c) 1997,2003,2014,2022 Gary A Kunkel +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. @@ -57,8 +57,8 @@ int main( int argCnt, char **av ) } #ifdef XB_LOGGING_SUPPORT + x.SetLogDirectory( PROJECT_LOG_DIR ); xbString sLogFileName = x.GetLogFqFileName().Str(); - sLogFileName.Resize( sLogFileName.Len() - 3 ); sLogFileName += "_l2.txt"; x.SetLogFileName( sLogFileName ); @@ -72,7 +72,6 @@ int main( int argCnt, char **av ) #endif x.SetDataDirectory( PROJECT_DATA_DIR ); - x.EnableMsgLogging(); InitTime(); #ifdef XB_DBF4_SUPPORT diff --git a/src/tests/xb_test_log.cpp b/src/tests/xb_test_log.cpp index 613b7dd..28ae552 100755 --- a/src/tests/xb_test_log.cpp +++ b/src/tests/xb_test_log.cpp @@ -2,7 +2,7 @@ XBase64 Software Library -Copyright (c) 1997,2003,2014,2022 Gary A Kunkel +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. @@ -21,18 +21,13 @@ Email Contact: #include "xbase.h" using namespace xb; - #include "tstfuncs.cpp" - - int main( int argCnt, char **av ) { int rc = 0; -#ifdef XB_LOGGING_SUPPORT - - + #ifdef XB_LOGGING_SUPPORT int po = 1; /* print option */ /* 0 - QUIET */ /* 1 - NORMAL */ @@ -46,6 +41,7 @@ int main( int argCnt, char **av ) } xbXBase x; + x.SetLogDirectory( PROJECT_LOG_DIR ); x.EnableMsgLogging(); InitTime(); if( po ){ @@ -55,21 +51,18 @@ int main( int argCnt, char **av ) sMsg.Sprintf( "Program [%s] initializing...", av[0] ); x.WriteLogMessage( sMsg ); - xbString sNewLogFileName = "Logfile2.txt"; sMsg.Sprintf( "Switching to logfile [%s]", sNewLogFileName.Str() ); x.WriteLogMessage( sMsg ); - x.DisableMsgLogging(); rc += TestMethod( po, "Set/Get Log Status()", x.GetLogStatus(), xbFalse ); x.SetLogFileName( sNewLogFileName ); - x.EnableMsgLogging(); + x.EnableMsgLogging(); rc += TestMethod( po, "Set/Get Log Status()", x.GetLogStatus(), 1 ); rc += TestMethod( po,"WriteLogMessage()", x.WriteLogMessage( "Test log message........" ), XB_NO_ERROR ); - sMsg.Sprintf( "Program [%s] terminating with [%d] errors...", av[0], rc * -1 ); x.WriteLogMessage( sMsg ); diff --git a/src/tests/xb_test_mdx.cpp b/src/tests/xb_test_mdx.cpp index af191ad..2ef5ffb 100755 --- a/src/tests/xb_test_mdx.cpp +++ b/src/tests/xb_test_mdx.cpp @@ -2,7 +2,7 @@ XBase64 Software Library -Copyright (c) 1997,2003,2014,2022 Gary A Kunkel +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. @@ -55,20 +55,28 @@ int main( int argCnt, char **av ) }; + xbSchema MyV4Record2[] = + { + { "CHAR1", XB_CHAR_FLD, 1, 0 }, + { "CHAR27", XB_CHAR_FLD, 27, 0 }, + { "",0,0,0 } + }; + + xbXBase x; -#ifdef XB_LOGGING_SUPPORT + #ifdef XB_LOGGING_SUPPORT + x.SetLogDirectory( PROJECT_LOG_DIR ); x.EnableMsgLogging(); if( iPo ){ std::cout << "Logfile is [" << x.GetLogFqFileName().Str() << "]" << std::endl; } sMsg.Sprintf( "Program [%s] initializing...", av[0] ); x.WriteLogMessage( sMsg ); -#endif + #endif x.SetDataDirectory( PROJECT_DATA_DIR ); - x.EnableMsgLogging(); - x.SetMultiUser( false ); + x.SetMultiUser( xbFalse ); InitTime(); if( iPo > 0 ) @@ -92,6 +100,7 @@ int main( int argCnt, char **av ) xbInt16 iDescending, xbInt16 iUnique, xbInt16 iOverLay, xbIx **xbIxOut, void **vpTagOut ); */ + iRc2 = V4DbfX1->CreateTag( "MDX", "CITY_TAGA", "CITY", "", 0, 0, XB_OVERLAY, &pIx, &pTag ); iRc += TestMethod( iPo, "CreateTag(1)", iRc2, 0 ); @@ -109,8 +118,6 @@ int main( int argCnt, char **av ) // std::cout << iRc2 << "\n"; -// something in th following block of code causing issues - xbInt32 uZip = 10000; for( xbUInt16 i = 0; i < 35; i++ ){ for( xbUInt16 j = 0; j < 14; j++ ){ @@ -147,7 +154,7 @@ int main( int argCnt, char **av ) } - iRc += TestMethod( iPo, "CheckTagIntegrity()", V4DbfX1->CheckTagIntegrity( 1, 2 ), XB_NO_ERROR ); + iRc += TestMethod( iPo, "CheckTagIntegrity(1)", V4DbfX1->CheckTagIntegrity( 1, 2 ), XB_NO_ERROR ); // attempt to add a dup key, should fail with XB_KEY_NOT_UNIQUE iRc2 = V4DbfX1->BlankRecord(); @@ -177,7 +184,7 @@ int main( int argCnt, char **av ) iRc += TestMethod( iPo, "Abort()", iRc2, XB_NO_ERROR ); iRc += TestMethod( iPo, "DeleteTag()", V4DbfX1->DeleteTag( "MDX", "CITY_TAGA" ), XB_NO_ERROR ); - iRc += TestMethod( iPo, "CheckTagIntegrity()", V4DbfX1->CheckTagIntegrity( 1, 2 ), XB_NO_ERROR ); + iRc += TestMethod( iPo, "CheckTagIntegrity(2)", V4DbfX1->CheckTagIntegrity( 1, 2 ), XB_NO_ERROR ); iRc2 = V4DbfX1->CreateTag( "MDX", "CITY_TAGF", "CITY", ".NOT. DELETED()", 0, 0, XB_OVERLAY, &pIx, &pTag ); iRc += TestMethod( iPo, "CreateTag(4)", iRc2, 0 ); @@ -186,27 +193,29 @@ int main( int argCnt, char **av ) iRc += TestMethod( iPo, "SetCurTag()", iRc2, XB_NO_ERROR ); iRc += TestMethod( iPo, "GetCurTagName()", V4DbfX1->GetCurTagName().Str(), "CITY_TAGF", 9 ); - iRc += TestMethod( iPo, "CheckTagIntegrity()", V4DbfX1->CheckTagIntegrity( 1, 2 ), XB_INVALID_INDEX ); + // next check throws an error message on the display, that is what it is testing, don't need to debug it + iRc += TestMethod( iPo, "CheckTagIntegrity(3)", V4DbfX1->CheckTagIntegrity( 1, 2 ), XB_INVALID_INDEX ); + iRc2 = V4DbfX1->Reindex( 0 ); iRc += TestMethod( iPo, "Reindex( 0 )", iRc2, XB_NO_ERROR ); - iRc += TestMethod( iPo, "CheckTagIntegrity()", V4DbfX1->CheckTagIntegrity( 1, 2 ), XB_NO_ERROR ); + iRc += TestMethod( iPo, "CheckTagIntegrity(4)", V4DbfX1->CheckTagIntegrity( 1, 2 ), XB_NO_ERROR ); iRc += TestMethod( iPo, "GetCurTagName()", V4DbfX1->GetCurTagName().Str(), "CITY_TAGF", 9 ); iRc2 = V4DbfX1->Reindex( 1 ); iRc += TestMethod( iPo, "Reindex( 1 )", iRc2, XB_NO_ERROR ); - iRc += TestMethod( iPo, "CheckTagIntegrity()", V4DbfX1->CheckTagIntegrity( 1, 2 ), XB_NO_ERROR ); + iRc += TestMethod( iPo, "CheckTagIntegrity(5)", V4DbfX1->CheckTagIntegrity( 1, 2 ), XB_NO_ERROR ); // delete everything, all keys should be removed from the filtered index iRc += TestMethod( iPo, "DeleteAll(0)", V4DbfX1->DeleteAll( 0 ), XB_NO_ERROR ); iRc += TestMethod( iPo, "Commit()", V4DbfX1->Commit(), XB_NO_ERROR ); - iRc += TestMethod( iPo, "CheckTagIntegrity()", V4DbfX1->CheckTagIntegrity( 1, 2 ), XB_NO_ERROR ); + iRc += TestMethod( iPo, "CheckTagIntegrity(6)", V4DbfX1->CheckTagIntegrity( 1, 2 ), XB_NO_ERROR ); // undelete everything, all keys should be added back into the filtered index iRc += TestMethod( iPo, "DeleteAll(1)", V4DbfX1->DeleteAll( 1 ), XB_NO_ERROR ); iRc += TestMethod( iPo, "Commit()", V4DbfX1->Commit(), XB_NO_ERROR ); - iRc += TestMethod( iPo, "CheckTagIntegrity()", V4DbfX1->CheckTagIntegrity( 1, 2 ), XB_NO_ERROR ); + iRc += TestMethod( iPo, "CheckTagIntegrity(7)", V4DbfX1->CheckTagIntegrity( 1, 2 ), XB_NO_ERROR ); // std::cout << "Cur Tag Name = " << V4DbfX1->GetCurTagName().Str() << "\n"; sKey = "abc"; @@ -239,8 +248,41 @@ int main( int argCnt, char **av ) iRc += TestMethod( iPo, "Rename()", V4DbfX1->Rename( "TestMdxR.DBF" ), XB_NO_ERROR ); + xbDbf *V4DbfX2 = new xbDbf4( &x ); + iRc2 = V4DbfX2->CreateTable( "TMDXDB02.DBF", "TestMdxX4", MyV4Record2, XB_OVERLAY, XB_MULTI_USER ); + iRc += TestMethod( iPo, "CreateTable(2)", iRc2, 0 ); + + + iRc2 = V4DbfX2->CreateTag( "MDX", "TAG1", "CHAR27", ".NOT. DELETED()", 0, 0, XB_OVERLAY, &pIx, &pTag ); +// iRc2 = V4DbfX2->CreateTag( "MDX", "TAG2", "CHAR1", "CHAR1 = 'O' .AND. .NOT. DELETED()", 0, 0, XB_OVERLAY, &pIx, &pTag ); + iRc += TestMethod( iPo, "CreateTag(4)", iRc2, 0 ); + + + + for( xbUInt32 ul = 0; ul < 500 && iRc2 == XB_NO_ERROR; ul++ ){ + c = 'O'; + V4DbfX2->BlankRecord(); + iRc2 = V4DbfX2->PutField( 1, c ); + if( iRc2 != XB_NO_ERROR ){ + iRc += TestMethod( iPo, "PutField()", iRc2, XB_NO_ERROR ); + } else { + iRc2 = V4DbfX2->AppendRecord(); + if( iRc2 != XB_NO_ERROR ){ + iRc += TestMethod( iPo, "AppendRecord()", iRc2, XB_NO_ERROR ); + } else { + iRc2 = V4DbfX2->Commit(); + if( iRc2 != XB_NO_ERROR ){ + iRc += TestMethod( iPo, "Commit()", iRc2, XB_NO_ERROR ); + } + } + } + } + + iRc += TestMethod( iPo, "CheckTagIntegrity(7)", V4DbfX2->CheckTagIntegrity( 1, 2 ), XB_NO_ERROR ); + x.CloseAllTables(); delete V4DbfX1; + delete V4DbfX2; if( iPo > 0 || iRc < 0 ) fprintf( stdout, "Total Errors = %d\n", iRc * -1 ); diff --git a/src/tests/xb_test_ndx.cpp b/src/tests/xb_test_ndx.cpp index b8b97f6..34496b6 100755 --- a/src/tests/xb_test_ndx.cpp +++ b/src/tests/xb_test_ndx.cpp @@ -2,7 +2,7 @@ XBase64 Software Library -Copyright (c) 1997,2003,2014,2022 Gary A Kunkel +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. @@ -57,6 +57,7 @@ int main( int argCnt, char **av ) xbString sMsg; #ifdef XB_LOGGING_SUPPORT + x.SetLogDirectory( PROJECT_LOG_DIR ); x.EnableMsgLogging(); if( iPo ){ std::cout << "Logfile is [" << x.GetLogFqFileName().Str() << "]" << std::endl; @@ -67,11 +68,7 @@ int main( int argCnt, char **av ) #endif x.SetDataDirectory( PROJECT_DATA_DIR ); - x.EnableMsgLogging(); - - #ifdef XB_LOCKING_SUPPORT - x.DisableDefaultAutoLock(); - #endif + x.SetMultiUser( xbFalse ); InitTime(); @@ -386,11 +383,13 @@ int main( int argCnt, char **av ) //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; } + ixl = ixl->next; } - iRc += TestMethod( iPo, "DeleteTable()", V3Dbf->DeleteTable(), XB_NO_ERROR ); +// iRc += TestMethod( iPo, "DeleteTable()", V3Dbf->DeleteTable(), XB_NO_ERROR ); + + x.CloseAllTables(); if( iPo > 0 || iRc < 0 ) fprintf( stdout, "Total Errors = %d\n", iRc * -1 ); diff --git a/src/tests/xb_test_sql.cpp b/src/tests/xb_test_sql.cpp index 20c8514..99a4f0b 100755 --- a/src/tests/xb_test_sql.cpp +++ b/src/tests/xb_test_sql.cpp @@ -2,7 +2,7 @@ XBase64 Software Library -Copyright (c) 1997,2003,2014, 2022 Gary A Kunkel +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. @@ -44,9 +44,10 @@ int main( int argCnt, char **av ) po = 2; } - - xbSchema MySqlRecord[] = +/* + xbSchema MyAddressRecord[] = { + { "ADDRESS", XB_CHAR_FLD, 30, 0 }, { "CITY", XB_CHAR_FLD, 30, 0 }, { "STATE", XB_CHAR_FLD, 2, 0 }, { "ZIPCODE", XB_NUMERIC_FLD, 9, 0 }, @@ -56,9 +57,23 @@ int main( int argCnt, char **av ) { "",0,0,0 } }; + above structure below, depending on how table is created + + sSql = "CREATE TABLE Address.DBF ( ADDRESS CHAR(30), CITY CHAR(30), STATE CHAR(2), ZIPCODE NUMERIC(9,0), NOTES VARCHAR, LASTUPDATE DATE, ACTIVE LOGICAL )"; +*/ + + xbSchema MyZipRecord[] = + { + { "ZIPCODE", XB_NUMERIC_FLD, 9, 0 }, + { "CITY", XB_CHAR_FLD, 30, 0 }, + { "STATE", XB_CHAR_FLD, 2, 0 }, + { "",0,0,0 } + }; + xbXBase x; #ifdef XB_LOGGING_SUPPORT + x.SetLogDirectory( PROJECT_LOG_DIR ); x.EnableMsgLogging(); if( po ){ std::cout << "Logfile is [" << x.GetLogFqFileName().Str() << "]" << std::endl; @@ -69,9 +84,7 @@ int main( int argCnt, char **av ) #endif - x.SetDataDirectory( PROJECT_DATA_DIR ); - x.EnableMsgLogging(); InitTime(); xbSql sql( &x ); @@ -81,36 +94,48 @@ int main( int argCnt, char **av ) xbDbf4 SqlDbf( &x ); // version 4 dbf file + xbDbf4 SqlDbfZ( &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 ); + + + sSql = "DROP TABLE IF EXISTS AddressR.DBF"; + iRc2 = sql.ExecuteNonQuery( sSql ); + iRc += TestMethod( po, "DropTable()", (xbInt32) iRc2, XB_NO_ERROR ); + if( iRc2 ) + x.DisplayError( iRc2 ); + + + + sSql = "DROP TABLE IF EXISTS Address.DBF"; + iRc2 = sql.ExecuteNonQuery( sSql ); + iRc += TestMethod( po, "DropTable()", (xbInt32) iRc2, XB_NO_ERROR ); + if( iRc2 ) + x.DisplayError( iRc2 ); + + + + sSql = "CREATE TABLE Address.DBF ( ADDRESS CHAR(30), CITY CHAR(30), STATE CHAR(2), ZIPCODE NUMERIC(9,0), NOTES VARCHAR, LASTUPDATE DATE, ACTIVE LOGICAL )"; + + iRc2 = sql.ExecuteNonQuery( sSql ); + iRc += TestMethod( po, "CreateTable()", (xbInt32) iRc2, XB_NO_ERROR ); + if( iRc2 ) + x.DisplayError( iRc2 ); + +/* + non sql way to create a table + iRc2 = SqlDbf.CreateTable( "Address.DBF", "Address", MyAddressRecord, XB_OVERLAY, XB_MULTI_USER ); iRc += TestMethod( po, "CreateTable()", (xbInt32) iRc2, XB_NO_ERROR ); if( iRc2 ) x.DisplayError( iRc2 ); +*/ + +// return 0; #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 )"; + sSql = "CREATE INDEX tag1 ON Address.DBF( CITY, STATE, DTOS( LASTUPDATE )) FILTER .NOT. DELETED()"; + // xbString sSql = "CREATE INDEX tag1 ON Address.DBF( CITY, STATE )"; iRc2 = sql.ExecuteNonQuery( sSql ); iRc += TestMethod( po, "SqL CreateIndex()", (xbInt32) iRc2, XB_NO_ERROR ); @@ -118,65 +143,107 @@ int main( int argCnt, char **av ) 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')"; + sSql = "INSERT INTO Address (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, "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')"; + sSql = "INSERT INTO Address (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"; + sSql = "ALTER TABLE Address.DBF RENAME TO AddressR.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'"; + sSql = "DELETE FROM AddressR.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'"; + sSql = "UNDELETE FROM AddressR.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"; + sSql = "DELETE FROM AddressR.DBF"; iRc2 = sql.ExecuteNonQuery( sSql ); iRc += TestMethod( po, "SqlDelete()", (xbInt32) iRc2, XB_NO_ERROR ); if( iRc2 ) x.DisplayError( iRc2 ); - sSql = "UNDELETE FROM TestSqlR.DBF"; + sSql = "UNDELETE FROM AddressR.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 = SqlDbfZ.CreateTable( "ZipCode.DBF", "", MyZipRecord, XB_OVERLAY, XB_MULTI_USER ); + iRc += TestMethod( po, "CreateTable()", (xbInt32) iRc2, XB_NO_ERROR ); + if( iRc2 ) + x.DisplayError( iRc2 ); + + +// sSql = "INSERT INTO ZipCode.DBF ( ZIPCODE, CITY, STATE ) VALUES ( 75087, 'Rockwall', 'TX' )"; + + +// std::cout << "---------------------------------------------------------\n"; +// std::cout << sSql.Str() << "\n"; + + sSql = "INSERT INTO ZipCode ( CITY ) VALUES ( 'city' )"; + iRc2 = sql.ExecuteNonQuery( sSql ); + + + iRc += TestMethod( po, "SqlInsert()", (xbInt32) iRc2, XB_NO_ERROR ); + if( iRc2 ) + x.DisplayError( iRc2 ); + + + +//**************** work in progress + +/* + sSql = "DELETE FROM AddressR.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 ); + iRc += TestMethod( po, "Close()", SqlDbfZ.Close(), XB_NO_ERROR ); + + +// return 0; + +// std::cout << "---------------------------------------------------------\n"; + + xbStmt sqlQry1( &x ); +// sSql = "SELECT CITY, STATE, ZIPCODE FROM Address.DBF T LEFT JOIN LJ.DBF LJ WHERE CITY IS NOT NULL ORDER BY 2 GROUP BY STATE HAVING ZIPCODE .NOT. NULL"; +// sSql = "SELECT CITY, STATE, ZIPCODE FROM AddressR.DBF T WHERE CITY IS NOT NULL ORDER BY 2 GROUP BY STATE HAVING ZIPCODE .NOT. NULL"; + +// sSql = "SELECT CITY, STATE, ZIPCODE FROM AddressR A LEFT JOIN ZipCode Z ON A.ZIPCODE = Z.ZIPCODE WHERE CITY IS NOT NULL ORDER BY 2 GROUP BY STATE HAVING ZIPCODE .NOT. NULL"; +// sSql = "SELECT M.ID, M.LEFTFK0, L0.CFLD FROM MAIN0 M LEFT JOIN LEFT0 L0 ON M.LEFTFK0 = L0.LEFTFK0 WHERE M.ID IS NOT NULL"; + iRc += TestMethod( po, "Select()", sqlQry1.ExecuteQuery( sSql ), XB_NO_ERROR ); + + sqlQry1.DumpStmtInternals(); + + // sqlQry1.Test(); + + + x.DisplayTableList(); + if( po > 0 || iRc < 0 ) fprintf( stdout, "Total Errors = %d\n", iRc * -1 ); diff --git a/src/tests/xb_test_string.cpp b/src/tests/xb_test_string.cpp index 9d730db..2f01e51 100755 --- a/src/tests/xb_test_string.cpp +++ b/src/tests/xb_test_string.cpp @@ -2,7 +2,7 @@ XBase63 Software Library -Copyright (c) 1997,2003,2014, 2022 Gary A Kunkel +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. @@ -46,6 +46,7 @@ int main( int argCnt, char **av = NULL ) xbString sMsg; #ifdef XB_LOGGING_SUPPORT + x.SetLogDirectory( PROJECT_LOG_DIR ); x.EnableMsgLogging(); if( po ){ std::cout << "Logfile is [" << x.GetLogFqFileName().Str() << "]" << std::endl; @@ -55,7 +56,6 @@ int main( int argCnt, char **av = NULL ) #endif x.SetDataDirectory( PROJECT_DATA_DIR ); - x.EnableMsgLogging(); InitTime(); @@ -260,6 +260,13 @@ int main( int argCnt, char **av = NULL ) rc += TestMethod( po, "Pos(\"000\") ", (xbInt32) s1.Pos( "000" ), 0 ); rc += TestMethod( po, "Pos(\"DEF\") ", (xbInt32) s1.Pos( "DEF" ), 1 ); + s1 = "ABC.123.abc"; + rc += TestMethod( po, "Pos( '.', 4 )", (xbInt32) s1.Pos( '.', 4 ), 4 ); + rc += TestMethod( po, "Pos( '.', 5 )", (xbInt32) s1.Pos( '.', 5 ), 8 ); + rc += TestMethod( po, "Pos( '.', 9 )", (xbInt32) s1.Pos( '.', 9 ), 0 ); + + + s1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; rc += TestMethod( po, "Remove(3,5) ", s1.Remove( 3, 5 ), "ABHIJKLMNOPQRSTUVWXYZ", 21 ); diff --git a/src/tests/xb_test_tblmgr.cpp b/src/tests/xb_test_tblmgr.cpp index 451432c..d048594 100755 --- a/src/tests/xb_test_tblmgr.cpp +++ b/src/tests/xb_test_tblmgr.cpp @@ -2,7 +2,7 @@ XBase64 Software Library -Copyright (c) 1997,2003,2014, 2022 Gary A Kunkel +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. @@ -13,7 +13,7 @@ Email Contact: */ -// This program tests the class xbXBase +// This program tests the table manager functions. // usage: xb_test_tblmgr QUITE|NORMAL|VERBOSE @@ -25,33 +25,35 @@ using namespace xb; int main( int argCnt, char **av ) { - int rc = 0; - int po = 1; /* print option */ + int iRc = 0; + int iPo = 1; /* print option */ /* 0 - QUIET */ /* 1 - NORMAL */ /* 2 - VERBOSE */ if( argCnt > 1 ) { if( av[1][0] == 'Q' ) - po = 0; + iPo = 0; else if( av[1][0] == 'V' ) - po = 2; + iPo = 2; } xbXBase x; -#ifdef XB_LOGGING_SUPPORT + #ifdef XB_LOGGING_SUPPORT + x.SetLogDirectory( PROJECT_LOG_DIR ); x.EnableMsgLogging(); - if( po ){ + if( iPo ){ std::cout << "Logfile is [" << x.GetLogFqFileName().Str() << "]" << std::endl; } xbString sMsg; sMsg.Sprintf( "Program [%s] initializing...", av[0] ); x.WriteLogMessage( sMsg ); -#endif + #endif + InitTime(); - if( po == 2 ){ + if( iPo == 2 ){ std::cout << "DisplayError Test ==> "; x.DisplayError( 0 ); #ifdef WIN32 @@ -73,14 +75,14 @@ int main( int argCnt, char **av ) return -1; #endif - rc += TestMethod( po, "AddTblToTblLst()", x.AddTblToTblList( d1, "TestTableC" ), 0 ); - 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 ); + iRc += TestMethod( iPo, "AddTblToTblLst()", x.AddTblToTblList( d1, "TestTableC" ), 0 ); + iRc += TestMethod( iPo, "AddTblToTblLst()", x.AddTblToTblList( d1, "TestTableA" ), 0 ); + iRc += TestMethod( iPo, "AddTblToTblLst()", x.AddTblToTblList( d1, "TestTableB" ), 0 ); + iRc += TestMethod( iPo, "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 ); + iRc += TestMethod( iPo, "AddTblToTblLst()", x.AddTblToTblList( d1, "TestTableC" ), XB_DUP_TABLE_OR_ALIAS ); std::cout << "**** Next list should have one each of TestTableA, B, C, D sorted in alpha order ****" << std::endl; x.DisplayTableList(); @@ -90,7 +92,7 @@ int main( int argCnt, char **av ) std::cout << "[PASS] GetDbfPtr()" << std::endl; else{ std::cout << "[FAIL] GetDbfPtr()" << std::endl; - rc--; + iRc--; } @@ -98,70 +100,59 @@ std::cout << "cp0\n"; x.SetDataDirectory( "/ABCDEFG/" ); #ifdef WIN32 - rc += TestMethod( po, "Set/GetDataDirectory()", x.GetDataDirectory(), "\\ABCDEFG\\", 9 ); + iRc += TestMethod( iPo, "Set/GetDataDirectory()", x.GetDataDirectory(), "\\ABCDEFG\\", 9 ); #else - rc += TestMethod( po, "Set/GetDataDirectory()", x.GetDataDirectory(), "/ABCDEFG/", 9 ); + iRc += TestMethod( iPo, "Set/GetDataDirectory()", x.GetDataDirectory(), "/ABCDEFG/", 9 ); #endif std::cout << "cp1\n"; x.SetDataDirectory( "/ABCDEFG" ); #ifdef WIN32 - rc += TestMethod( po, "Set/GetDataDirectory()", x.GetDataDirectory(), "\\ABCDEFG", 8 ); + iRc += TestMethod( iPo, "Set/GetDataDirectory()", x.GetDataDirectory(), "\\ABCDEFG", 8 ); #else - rc += TestMethod( po, "Set/GetDataDirectory()", x.GetDataDirectory(), "/ABCDEFG", 8 ); + iRc += TestMethod( iPo, "Set/GetDataDirectory()", x.GetDataDirectory(), "/ABCDEFG", 8 ); #endif - std::cout << "cp2\n"; - - x.SetDataDirectory( "\\ABCDEFG\\"); #ifdef WIN32 - rc += TestMethod( po, "Set/GetDataDirectory()", x.GetDataDirectory(), "\\ABCDEFG\\", 9 ); + iRc += TestMethod( iPo, "Set/GetDataDirectory()", x.GetDataDirectory(), "\\ABCDEFG\\", 9 ); #else - rc += TestMethod( po, "Set/GetDataDirectory()", x.GetDataDirectory(), "/ABCDEFG/", 9 ); + iRc += TestMethod( iPo, "Set/GetDataDirectory()", x.GetDataDirectory(), "/ABCDEFG/", 9 ); #endif - std::cout << "cp3\n"; - - x.SetDataDirectory( "\\ABCDEFG" ); #ifdef WIN32 - rc += TestMethod( po, "Set/GetDataDirectory()", x.GetDataDirectory(), "\\ABCDEFG", 8 ); + iRc += TestMethod( iPo, "Set/GetDataDirectory()", x.GetDataDirectory(), "\\ABCDEFG", 8 ); #else - rc += TestMethod( po, "Set/GetDataDirectory()", x.GetDataDirectory(), "/ABCDEFG", 8 ); + iRc += TestMethod( iPo, "Set/GetDataDirectory()", x.GetDataDirectory(), "/ABCDEFG", 8 ); #endif - - std::cout << "cp4\n"; - - x.SetDataDirectory( "ABCDEFG" ); - rc += TestMethod( po, "Set/GetDataDirectory()", x.GetDataDirectory(), "ABCDEFG", 7 ); - + iRc += TestMethod( iPo, "Set/GetDataDirectory()", x.GetDataDirectory(), "ABCDEFG", 7 ); - rc += TestMethod( po, "RemoveTblFromDbList()", x.RemoveTblFromTblList( "TestTableB" ), 0 ); - rc += TestMethod( po, "RemoveTblFromDbList()", x.RemoveTblFromTblList( "TestTableB" ), XB_NOT_FOUND ); + iRc += TestMethod( iPo, "RemoveTblFromDbList()", x.RemoveTblFromTblList( "TestTableB" ), 0 ); + iRc += TestMethod( iPo, "RemoveTblFromDbList()", x.RemoveTblFromTblList( "TestTableB" ), XB_NOT_FOUND ); std::cout << "**** Next list should not have TestTableB in it ****" << std::endl; x.DisplayTableList(); - rc += TestMethod( po, "RemoveTblFromDbList()", x.RemoveTblFromTblList( "TestTableA" ), 0 ); - rc += TestMethod( po, "RemoveTblFromDbList()", x.RemoveTblFromTblList( "TestTableC" ), 0 ); - rc += TestMethod( po, "RemoveTblFromDbList()", x.RemoveTblFromTblList( "TestTableD" ), 0 ); + iRc += TestMethod( iPo, "RemoveTblFromDbList()", x.RemoveTblFromTblList( "TestTableA" ), 0 ); + iRc += TestMethod( iPo, "RemoveTblFromDbList()", x.RemoveTblFromTblList( "TestTableC" ), 0 ); + iRc += TestMethod( iPo, "RemoveTblFromDbList()", x.RemoveTblFromTblList( "TestTableD" ), 0 ); delete d1; - if( po > 0 || rc < 0 ) - fprintf( stdout, "Total Errors = %d\n", rc * -1 ); + if( iPo > 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], rc * -1 ); + sMsg.Sprintf( "Program [%s] terminating with [%d] errors...", av[0], iRc * -1 ); x.WriteLogMessage( sMsg ); #endif - return rc; + return iRc; } diff --git a/src/tests/xb_test_uda.cpp b/src/tests/xb_test_uda.cpp index dec41fa..18693b5 100755 --- a/src/tests/xb_test_uda.cpp +++ b/src/tests/xb_test_uda.cpp @@ -2,7 +2,7 @@ XBase64 Software Library -Copyright (c) 1997,2003,2014, 2022 Gary A Kunkel +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. @@ -45,7 +45,8 @@ int main( int argCnt, char **av ) xbXBase x; -#ifdef XB_LOGGING_SUPPORT + #ifdef XB_LOGGING_SUPPORT + x.SetLogDirectory( PROJECT_LOG_DIR ); x.EnableMsgLogging(); if( po ){ std::cout << "Logfile is [" << x.GetLogFqFileName().Str() << "]" << std::endl; @@ -53,11 +54,9 @@ 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(); xbUda uda; iRc += TestMethod( po, "GetTokencCnt()", uda.GetTokenCnt(), 0 ); diff --git a/src/tests/xb_test_xbase.cpp b/src/tests/xb_test_xbase.cpp index 9d523c5..4751c25 100755 --- a/src/tests/xb_test_xbase.cpp +++ b/src/tests/xb_test_xbase.cpp @@ -2,7 +2,7 @@ XBase64 Software Library -Copyright (c) 1997,2003,2014, 2022 Gary A Kunkel +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. @@ -27,26 +27,34 @@ using namespace xb; int main( int argCnt, char **av ) { int iRc = 0; - int po = 1; /* print option */ + int iPo = 1; /* print option */ /* 0 - QUIET */ /* 1 - NORMAL */ /* 2 - VERBOSE */ if( argCnt > 1 ) { if( av[1][0] == 'Q' ) - po = 0; + iPo = 0; else if( av[1][0] == 'V' ) - po = 2; + iPo = 2; } xbXBase x; xbString sMsg; #ifdef XB_LOGGING_SUPPORT + + + xbString sLogDir = PROJECT_LOG_DIR; +// x.SetLogDirectory( sLogDir ); + x.SetLogDirectory( PROJECT_LOG_DIR ); + + x.EnableMsgLogging(); - if( po ){ + if( iPo ){ std::cout << "Logfile is [" << x.GetLogFqFileName().Str() << "]" << std::endl; } + sMsg.Sprintf( "Program [%s] initializing...", av[0] ); x.WriteLogMessage( sMsg ); #endif @@ -54,8 +62,8 @@ int main( int argCnt, char **av ) x.SetDefaultDateFormat( "YY-MM-DD" ); - iRc += TestMethod( po, "SetDefaultDateFormat", x.GetDefaultDateFormat(), "YY-MM-DD", 8 ); - if( po == 2 ){ + iRc += TestMethod( iPo, "SetDefaultDateFormat", x.GetDefaultDateFormat(), "YY-MM-DD", 8 ); + if( iPo == 2 ){ if( x.GetEndianType() == 'L' ) std::cout << "Little Endian Architecture" << std::endl; else if( x.GetEndianType() == 'B' ) @@ -64,38 +72,32 @@ int main( int argCnt, char **av ) std::cout << "Undefine Endian Architecture" << std::endl; } - iRc += TestMethod( po, "GetErrorMessage", x.GetErrorMessage( XB_DBF_FILE_NOT_OPEN ), "DBF File Not Open", 17 ); + iRc += TestMethod( iPo, "GetErrorMessage", x.GetErrorMessage( XB_DBF_FILE_NOT_OPEN ), "DBF File Not Open", 17 ); #ifdef XB_LOGGING_SUPPORT - xbString sLogDir = PROJECT_LOG_DIR; - iRc += TestMethod( po, "GetDefaultLogDirectory()", x.GetDefaultLogDirectory(), sLogDir, sLogDir.Len()); - + iRc += TestMethod( iPo, "GetLogDirectory()", x.GetLogDirectory(), sLogDir, sLogDir.Len()); xbString sLogName = CMAKE_SYSTEM_NAME; sLogName += "_"; sLogName += XB_PLATFORM; sLogName += ".xbLog.txt"; - iRc += TestMethod( po, "GetDefaultLogFileName()", x.GetDefaultLogFileName(), sLogName, sLogName.Len()); - - x.WriteLogMessage( "test" ); + iRc += TestMethod( iPo, "GetLogFileName()", x.GetLogFileName(), sLogName, sLogName.Len()); + x.WriteLogMessage( "Program xb_test_xbase - test logfile message" ); #endif x.xbSleep( 250 ); - - - if( po == 2 ){ + if( iPo == 2 ){ std::cout << "DisplayError Test ==> "; x.DisplayError( 0 ); } - - if( po > 0 || iRc < 0 ) + 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 ); -#endif + #endif return iRc; } |