diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2022-12-07 13:17:14 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2022-12-07 13:17:14 +0100 |
commit | 4875a3dd9b183dcd2256e2abfc4ccf7484c233b4 (patch) | |
tree | 0abbea881ded030851014ffdd60fbf71fead8f65 /src/tests/xb_test_uda.cpp | |
parent | daf17154bf13139d9375f48525d19d6aaba08155 (diff) |
New upstream version 4.0.2upstream/4.0.2
Diffstat (limited to 'src/tests/xb_test_uda.cpp')
-rwxr-xr-x | src/tests/xb_test_uda.cpp | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/src/tests/xb_test_uda.cpp b/src/tests/xb_test_uda.cpp new file mode 100755 index 0000000..dec41fa --- /dev/null +++ b/src/tests/xb_test_uda.cpp @@ -0,0 +1,98 @@ +/* xb_test_uda.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: + + XDB-devel@lists.sourceforge.net + XDB-users@lists.sourceforge.net + +*/ + +// This program tests the uda (user data area) functions + +// usage: xb_test_uda QUITE|NORMAL|VERBOSE + + + +#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; + } + + + + 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 ); +#endif + + + x.SetDataDirectory( PROJECT_DATA_DIR ); + x.EnableMsgLogging(); + + xbUda uda; + iRc += TestMethod( po, "GetTokencCnt()", uda.GetTokenCnt(), 0 ); + xbString s1; + xbString s2; + iRc += TestMethod( po, "AddTokenForKey()", uda.AddTokenForKey( "B", "BBBB" ), XB_NO_ERROR ); + s1 = "C"; + iRc += TestMethod( po, "AddTokenForKey()", uda.AddTokenForKey( s1, "CCCC" ), XB_NO_ERROR ); + s2 = "DDDD"; + iRc += TestMethod( po, "AddTokenForKey()", uda.AddTokenForKey( "D", s2 ), XB_NO_ERROR ); + + s1 = "A"; + s2 = "AAAA"; + iRc += TestMethod( po, "AddTokenForKey()", uda.AddTokenForKey( s1, s2 ), XB_NO_ERROR ); + iRc += TestMethod( po, "AddTokenForKey()", uda.AddTokenForKey( "AA", "AAAAA" ), XB_NO_ERROR ); + iRc += TestMethod( po, "AddTokenForKey()", uda.AddTokenForKey( "BB", "BBBBB" ), XB_NO_ERROR ); + iRc += TestMethod( po, "AddTokenForKey()", uda.AddTokenForKey( "CC", "CCCCC" ), XB_NO_ERROR ); + iRc += TestMethod( po, "AddTokenForKey()", uda.AddTokenForKey( "DD", "DDDDD" ), XB_NO_ERROR ); + iRc += TestMethod( po, "GetTokencCnt()", uda.GetTokenCnt(), 8); + + iRc += TestMethod( po, "UpdTokenForKey()", uda.UpdTokenForKey( "BB", "9999" ), XB_NO_ERROR ); + iRc += TestMethod( po, "UpdTokenForKey()", uda.DelTokenForKey( "CC" ), XB_NO_ERROR ); + iRc += TestMethod( po, "GetTokencCnt()", uda.GetTokenCnt(), 7 ); + +#ifdef XB_DEBUG_SUPPORT + uda.DumpUda(); +#endif // XB_DEBUG_SUPPORT + + uda.Clear(); + iRc += TestMethod( po, "GetTokencCnt()", uda.GetTokenCnt(), 0 ); + +#ifdef XB_LOGGING_SUPPORT + sMsg.Sprintf( "Program [%s] terminating with [%d] errors...", av[0], iRc * -1 ); + x.WriteLogMessage( sMsg ); +#endif + + return iRc; +} |