00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <spl/Debug.h>
00018 #include <spl/Exception.h>
00019 #include <spl/Log.h>
00020 #include <spl/UnitTest.h>
00021
00022 #if defined (DEBUG) || defined(_DEBUG)
00023
00024 extern void TVectorTest();
00025 extern void THashtableTest();
00026 extern void TestObjectPool();
00027 extern void TestCommandLine();
00028 extern void TestStringBuffer();
00029 extern void TestPacket();
00030 extern void TestTString();
00031 extern void TestStreams();
00032 extern void TestRecordSet();
00033 extern void _RWLockTest();
00034 extern void _TestList();
00035 extern void _TestVariant();
00036 extern void _TestCommand();
00037 extern void _TestRandom();
00038 extern void _TestDate();
00039 extern void _TestDateTime();
00040 extern void _TestDes();
00041 extern void _TestRSA();
00042 extern void _TestMutex();
00043 extern void _TestDesStream();
00044 extern void _TestStateMachine();
00045 extern void _TestTinyXml();
00046 extern void _TestMath();
00047 extern void _TestNetwork();
00048 extern void _TestConfigSettings();
00049 extern void _TestMemoryPool();
00050 extern void _TestDelimFile();
00051 extern void _TestUri();
00052 extern void _TestDecimal();
00053 extern void _TestNumeric();
00054 extern void _TestFile();
00055 extern void _TestSemaphore();
00056 extern void _TestStringTokenizer();
00057 extern void _TestXPathLex();
00058 extern void _TestXPathParse();
00059 extern void _TestRefCountPtr();
00060
00061 extern void _TestStringTable();
00062 extern void _TestVarInterp();
00063 extern void _TestBigInteger();
00064 extern void _TestSqlLite();
00065 extern void _TestRegex();
00066 extern void _TestEnv();
00067 extern void _TestXPath();
00068 extern void _TestJsLex();
00069 extern void _ExceptionTestHarness();
00070 extern void RedblacktreeTestHarness();
00071 extern void _testdebug();
00072
00073 void TestHarness::RunTests()
00074 {
00075 try
00076 {
00077 DEBUG_FREE_HEAP();
00078
00079 _testdebug();
00080 DEBUG_CLEAR_MEM_CHECK_POINTS();
00081 DEBUG_DUMP_MEM_LEAKS();
00082 DEBUG_FREE_HEAP();
00083
00084 TestTString();
00085 DEBUG_CLEAR_MEM_CHECK_POINTS();
00086 DEBUG_DUMP_MEM_LEAKS();
00087 DEBUG_FREE_HEAP();
00088
00089 _TestRefCountPtr();
00090 DEBUG_CLEAR_MEM_CHECK_POINTS();
00091 DEBUG_DUMP_MEM_LEAKS();
00092 DEBUG_FREE_HEAP();
00093
00094 _TestNumeric();
00095 DEBUG_CLEAR_MEM_CHECK_POINTS();
00096 DEBUG_DUMP_MEM_LEAKS();
00097 DEBUG_FREE_HEAP();
00098
00099 _TestDate();
00100 DEBUG_CLEAR_MEM_CHECK_POINTS();
00101 DEBUG_DUMP_MEM_LEAKS();
00102 DEBUG_FREE_HEAP();
00103
00104 _TestDateTime();
00105 DEBUG_CLEAR_MEM_CHECK_POINTS();
00106 DEBUG_DUMP_MEM_LEAKS();
00107 DEBUG_FREE_HEAP();
00108
00109 _ExceptionTestHarness();
00110 DEBUG_CLEAR_MEM_CHECK_POINTS();
00111 DEBUG_DUMP_MEM_LEAKS();
00112 DEBUG_FREE_HEAP();
00113
00114 _TestDecimal();
00115 DEBUG_CLEAR_MEM_CHECK_POINTS();
00116 DEBUG_DUMP_MEM_LEAKS();
00117 DEBUG_FREE_HEAP();
00118
00119 _TestRandom();
00120 DEBUG_CLEAR_MEM_CHECK_POINTS();
00121 DEBUG_DUMP_MEM_LEAKS();
00122 DEBUG_FREE_HEAP();
00123
00124 _TestMath();
00125 DEBUG_CLEAR_MEM_CHECK_POINTS();
00126 DEBUG_DUMP_MEM_LEAKS();
00127 DEBUG_FREE_HEAP();
00128
00129 TVectorTest();
00130 DEBUG_CLEAR_MEM_CHECK_POINTS();
00131 DEBUG_DUMP_MEM_LEAKS();
00132 DEBUG_FREE_HEAP();
00133
00134 _TestList();
00135 DEBUG_CLEAR_MEM_CHECK_POINTS();
00136 DEBUG_DUMP_MEM_LEAKS();
00137 DEBUG_FREE_HEAP();
00138 DEBUG_VALIDATE();
00139
00140 _TestVariant();
00141 DEBUG_CLEAR_MEM_CHECK_POINTS();
00142 DEBUG_DUMP_MEM_LEAKS();
00143 DEBUG_FREE_HEAP();
00144 DEBUG_VALIDATE();
00145
00146 _TestBigInteger();
00147 DEBUG_CLEAR_MEM_CHECK_POINTS();
00148 DEBUG_DUMP_MEM_LEAKS();
00149 DEBUG_FREE_HEAP();
00150 DEBUG_VALIDATE();
00151
00152 THashtableTest();
00153 DEBUG_CLEAR_MEM_CHECK_POINTS();
00154 DEBUG_DUMP_MEM_LEAKS();
00155 DEBUG_FREE_HEAP();
00156
00157 TestStringBuffer();
00158 DEBUG_CLEAR_MEM_CHECK_POINTS();
00159 DEBUG_DUMP_MEM_LEAKS();
00160 DEBUG_FREE_HEAP();
00161
00162 _TestStringTokenizer();
00163 DEBUG_CLEAR_MEM_CHECK_POINTS();
00164 DEBUG_DUMP_MEM_LEAKS();
00165 DEBUG_FREE_HEAP();
00166
00167 _TestStringTable();
00168 DEBUG_CLEAR_MEM_CHECK_POINTS();
00169 DEBUG_DUMP_MEM_LEAKS();
00170 DEBUG_FREE_HEAP();
00171
00172 RedblacktreeTestHarness();
00173 DEBUG_CLEAR_MEM_CHECK_POINTS();
00174 DEBUG_DUMP_MEM_LEAKS();
00175 DEBUG_FREE_HEAP();
00176
00177 TestObjectPool();
00178 DEBUG_CLEAR_MEM_CHECK_POINTS();
00179 DEBUG_DUMP_MEM_LEAKS();
00180 DEBUG_FREE_HEAP();
00181
00182 TestCommandLine();
00183 DEBUG_CLEAR_MEM_CHECK_POINTS();
00184 DEBUG_DUMP_MEM_LEAKS();
00185 DEBUG_FREE_HEAP();
00186
00187 _TestDes();
00188 DEBUG_CLEAR_MEM_CHECK_POINTS();
00189 DEBUG_DUMP_MEM_LEAKS();
00190 DEBUG_FREE_HEAP();
00191
00192 _TestRSA();
00193 DEBUG_CLEAR_MEM_CHECK_POINTS();
00194 DEBUG_DUMP_MEM_LEAKS();
00195 DEBUG_FREE_HEAP();
00196
00197 TestStreams();
00198 DEBUG_CLEAR_MEM_CHECK_POINTS();
00199 DEBUG_DUMP_MEM_LEAKS();
00200 DEBUG_FREE_HEAP();
00201
00202 _TestDelimFile();
00203 DEBUG_CLEAR_MEM_CHECK_POINTS();
00204 DEBUG_DUMP_MEM_LEAKS();
00205 DEBUG_FREE_HEAP();
00206
00207 _TestFile();
00208 DEBUG_CLEAR_MEM_CHECK_POINTS();
00209 DEBUG_DUMP_MEM_LEAKS();
00210 DEBUG_FREE_HEAP();
00211
00212 _TestCommand();
00213 DEBUG_CLEAR_MEM_CHECK_POINTS();
00214 DEBUG_DUMP_MEM_LEAKS();
00215 DEBUG_FREE_HEAP();
00216 DEBUG_VALIDATE();
00217
00218 TestRecordSet();
00219 DEBUG_CLEAR_MEM_CHECK_POINTS();
00220 DEBUG_DUMP_MEM_LEAKS();
00221 DEBUG_FREE_HEAP();
00222
00223 TestPacket();
00224 DEBUG_CLEAR_MEM_CHECK_POINTS();
00225 DEBUG_DUMP_MEM_LEAKS();
00226 DEBUG_FREE_HEAP();
00227
00228 _TestUri();
00229 DEBUG_CLEAR_MEM_CHECK_POINTS();
00230 DEBUG_DUMP_MEM_LEAKS();
00231 DEBUG_FREE_HEAP();
00232
00233 _TestDesStream();
00234 DEBUG_CLEAR_MEM_CHECK_POINTS();
00235 DEBUG_DUMP_MEM_LEAKS();
00236 DEBUG_FREE_HEAP();
00237
00238 _TestTinyXml();
00239 DEBUG_CLEAR_MEM_CHECK_POINTS();
00240 DEBUG_DUMP_MEM_LEAKS();
00241 DEBUG_FREE_HEAP();
00242
00243 _TestStateMachine();
00244 DEBUG_CLEAR_MEM_CHECK_POINTS();
00245 DEBUG_DUMP_MEM_LEAKS();
00246 DEBUG_FREE_HEAP();
00247
00248 _TestNetwork();
00249 DEBUG_CLEAR_MEM_CHECK_POINTS();
00250 DEBUG_DUMP_MEM_LEAKS();
00251 DEBUG_FREE_HEAP();
00252
00253 _TestConfigSettings();
00254 DEBUG_CLEAR_MEM_CHECK_POINTS();
00255 DEBUG_DUMP_MEM_LEAKS();
00256 DEBUG_FREE_HEAP();
00257
00258 _TestMemoryPool();
00259 DEBUG_CLEAR_MEM_CHECK_POINTS();
00260 DEBUG_DUMP_MEM_LEAKS();
00261 DEBUG_FREE_HEAP();
00262
00263 _TestVarInterp();
00264 DEBUG_CLEAR_MEM_CHECK_POINTS();
00265 DEBUG_DUMP_MEM_LEAKS();
00266 DEBUG_FREE_HEAP();
00267
00268 _TestJsLex();
00269 DEBUG_CLEAR_MEM_CHECK_POINTS();
00270 DEBUG_DUMP_MEM_LEAKS();
00271 DEBUG_FREE_HEAP();
00272
00273 _TestXPathLex();
00274 DEBUG_CLEAR_MEM_CHECK_POINTS();
00275 DEBUG_DUMP_MEM_LEAKS();
00276 DEBUG_FREE_HEAP();
00277
00278 _TestXPathParse();
00279 DEBUG_CLEAR_MEM_CHECK_POINTS();
00280 DEBUG_DUMP_MEM_LEAKS();
00281 DEBUG_FREE_HEAP();
00282
00283 _TestXPath();
00284 DEBUG_CLEAR_MEM_CHECK_POINTS();
00285 DEBUG_DUMP_MEM_LEAKS();
00286 DEBUG_FREE_HEAP();
00287
00288
00289
00290
00291
00292
00293 _TestMutex();
00294 DEBUG_CLEAR_MEM_CHECK_POINTS();
00295 DEBUG_DUMP_MEM_LEAKS();
00296 DEBUG_FREE_HEAP();
00297
00298 _RWLockTest();
00299 DEBUG_CLEAR_MEM_CHECK_POINTS();
00300 DEBUG_DUMP_MEM_LEAKS();
00301 DEBUG_FREE_HEAP();
00302
00303 _TestSemaphore();
00304 DEBUG_CLEAR_MEM_CHECK_POINTS();
00305 DEBUG_DUMP_MEM_LEAKS();
00306 DEBUG_FREE_HEAP();
00307
00308 _TestRegex();
00309 DEBUG_CLEAR_MEM_CHECK_POINTS();
00310 DEBUG_DUMP_MEM_LEAKS();
00311 DEBUG_FREE_HEAP();
00312
00313 _TestEnv();
00314 DEBUG_CLEAR_MEM_CHECK_POINTS();
00315 DEBUG_DUMP_MEM_LEAKS();
00316 DEBUG_FREE_HEAP();
00317
00318 _TestSqlLite();
00319 DEBUG_CLEAR_MEM_CHECK_POINTS();
00320 DEBUG_DUMP_MEM_LEAKS();
00321 DEBUG_FREE_HEAP();
00322
00323 DEBUG_VALIDATE();
00324 }
00325 catch ( Exception *ex )
00326 {
00327 Log::SWrite(ex);
00328 delete ex;
00329 }
00330 catch ( OutOfMemoryException mex )
00331 {
00332 Log::SWrite(mex);
00333 }
00334 }
00335 #else
00336 void TestHarness::RunTests()
00337 {
00338 }
00339 #endif