ReactOS 0.4.15-dev-8093-g3285f69
main.cpp File Reference
#include "Prefix.h"
#include "Tests.h"
#include <iostream>
#include "nc_alloc.h"
#include <vector>
#include <cstring>
#include "TestClass.h"
#include "LeakCheck.h"
#include "test_construct.h"
#include <set>
Include dependency graph for main.cpp:

Go to the source code of this file.

Functions

static void usage (const char *name)
 
int _STLP_CALL main (int argc, char **argv)
 

Function Documentation

◆ main()

int _STLP_CALL main ( int argc  ,
char **  argv 
)

Definition at line 154 of file main.cpp.

155{
156#if defined(_WIN32_WCE)
157 std::ofstream file( "\\eh_test.txt" );
158 std::streambuf* old_cout_buf = cout.rdbuf(file.rdbuf());
159 std::streambuf* old_cerr_buf = cerr.rdbuf(file.rdbuf());
160#endif
161#if defined( __MWERKS__ ) && defined( macintosh ) // Get command line.
162 argc = ccommand(&argv);
163 // Allow the i/o window to be repositioned.
164// EH_STD::string s;
165// getline(EH_STD::cin, s);
166#endif
167 unsigned int niters=2;
168 bool run_all=true;
169 bool run_slist = false;
170 bool run_list = false;
171 bool run_vector = false;
172 bool run_bit_vector = false;
173 bool run_deque = false;
174 bool run_hash_map = false;
175 bool run_hash_set = false;
176 bool run_set = false;
177 bool run_map = false;
178 bool run_algo = false;
179 bool run_algobase = false;
180 bool run_rope = false;
181 bool run_string = false;
182 bool run_bitset = false;
183 bool run_valarray = false;
184
185 int cur_argv;
186 char *p, *p1;
187#if defined (EH_NEW_IOSTREAMS)
188 std::ios_base::sync_with_stdio(false);
189#endif
190
191 cerr << argv[0]<<" : Exception handling testsuite.\n";
192 cerr.flush();
193
194 bool track_allocations = false;
195 // parse parameters :
196 // leak_test [-iterations] [-test] ...
197 for (cur_argv=1; cur_argv<argc; cur_argv++) {
198 p = argv[cur_argv];
199 if (*p == '-') {
200 switch (p[1]) {
201 case 'q':
203 break;
204 case 'v':
206 break;
207#if 0 // This option was never actually used -- dwa 9/22/97
208 case 'i':
209 gTestController.IgnoreLeaks(true);
210 break;
211#endif
212 case 'n':
213 p1 = argv[++cur_argv];
214 if (p1 && EH_CSTD::sscanf(p1, "%i", &niters)==1)
215 cerr <<" Doing "<<niters<<" iterations\n";
216 else
217 usage(argv[0]);
218 break;
219 case 't':
220 track_allocations = true;
221 break;
222 case 'e':
224 break;
225 case 's':
226 p1 = argv[++cur_argv];
227 if (p1 && EH_CSTD::sscanf(p1, "%i", &random_base)==1)
228 cerr <<" Setting "<<random_base<<" as base for random sizes.\n";
229 else
230 usage(argv[0]);
231 break;
232 default:
233 usage(argv[0]);
234 break;
235 }
236 } else {
237 run_all = false;
238 // test name
239 if (EH_CSTD::strcmp(p, "algo")==0) {
240 run_algo=true;
241 } else if (EH_CSTD::strcmp(p, "vector")==0) {
242 run_vector=true;
243 } else if (EH_CSTD::strcmp(p, "bit_vector")==0) {
244 run_bit_vector=true;
245 } else if (EH_CSTD::strcmp(p, "list")==0) {
246 run_list=true;
247 } else if (EH_CSTD::strcmp(p, "slist")==0) {
248 run_slist=true;
249 } else if (EH_CSTD::strcmp(p, "deque")==0) {
250 run_deque=true;
251 } else if (EH_CSTD::strcmp(p, "set")==0) {
252 run_set=true;
253 } else if (EH_CSTD::strcmp(p, "map")==0) {
254 run_map=true;
255 } else if (EH_CSTD::strcmp(p, "hash_set")==0) {
256 run_hash_set=true;
257 } else if (EH_CSTD::strcmp(p, "hash_map")==0) {
258 run_hash_map=true;
259 } else if (EH_CSTD::strcmp(p, "rope")==0) {
260 run_rope=true;
261 } else if (EH_CSTD::strcmp(p, "string")==0) {
262 run_string=true;
263 } else if (EH_CSTD::strcmp(p, "bitset")==0) {
264 run_bitset=true;
265 } else if (EH_CSTD::strcmp(p, "valarray")==0) {
266 run_valarray=true;
267 } else {
268 usage(argv[0]);
269 }
270
271 }
272 }
273
274 gTestController.TrackAllocations( track_allocations );
275
276 // Over and over...
277 for ( unsigned i = 0; i < niters ; i++ )
278 {
279 cerr << "iteration #" << i << "\n";
280 if (run_all || run_algobase) {
282 cerr << "EH test : algobase" << endl;
284 }
285 if (run_all || run_algo) {
287 cerr << "EH test : algo" << endl;
288 test_algo();
289 }
290
291 if (run_all || run_vector) {
293 cerr << "EH test : vector" << endl;
294 test_vector();
295 }
296
297#if defined( EH_BIT_VECTOR_IMPLEMENTED )
298 if (run_all || run_bit_vector) {
300 cerr << "EH test : bit_vector" << endl;
302 }
303#endif
304
305 if (run_all || run_list) {
307 cerr << "EH test : list" << endl;
308 test_list();
309 }
310
311#if defined( EH_SLIST_IMPLEMENTED )
312 if (run_all || run_slist) {
314 cerr << "EH test : slist" << endl;
315 test_slist();
316 }
317#endif // EH_SLIST_IMPLEMENTED
318
319 if (run_all || run_deque) {
321 cerr << "EH test : deque" << endl;
322 test_deque();
323 }
324 if (run_all || run_set) {
326 cerr << "EH test : set" << endl;
327 test_set();
329 cerr << "EH test : multiset" << endl;
331 }
332
333 if (run_all || run_map) {
335 cerr << "EH test : map" << endl;
336 test_map();
338 cerr << "EH test : multimap" << endl;
340 }
341
342#if defined( EH_HASHED_CONTAINERS_IMPLEMENTED )
343 if (run_all || run_hash_map) {
345 cerr << "EH test : hash_map" << endl;
347 gTestController.SetCurrentContainer("hash_multimap");
348 cerr << "EH test : hash_multimap" << endl;
350 }
351
352 if (run_all || run_hash_set) {
354 cerr << "EH test : hash_set" << endl;
356 gTestController.SetCurrentContainer("hash_multiset");
357 cerr << "EH test : hash_multiset" << endl;
359 }
360#endif // EH_HASHED_CONTAINERS_IMPLEMENTED
361
362#if defined( EH_ROPE_IMPLEMENTED )
363 // CW1.8 can't compile this for some reason!
364#if !( defined(__MWERKS__) && __MWERKS__ < 0x1900 )
365 if (run_all || run_rope) {
367 cerr << "EH test : rope" << endl;
368 test_rope();
369 }
370#endif
371#endif // EH_ROPE_IMPLEMENTED
372#if defined( EH_STRING_IMPLEMENTED )
373 if (run_all || run_string) {
375 cerr << "EH test : string" << endl;
376 test_string();
377 }
378#endif
379#if defined( EH_BITSET_IMPLEMENTED )
380 if (run_all || run_bitset) {
382 cerr << "EH test : bitset" << endl;
383 test_bitset();
384 }
385#endif
386#if defined( EH_VALARRAY_IMPLEMENTED )
387 if (run_all || run_bitset) {
389 cerr << "EH test : valarray" << endl;
390 test_valarray();
391 }
392#endif
393 }
394
396
397 cerr << "EH test : Done\n";
398
399#if defined(_WIN32_WCE)
400 cout.rdbuf(old_cout_buf);
401 cerr.rdbuf(old_cerr_buf);
402 file.close();
403#endif
404
405 return 0;
406}
static int argc
Definition: ServiceArgs.c:12
basic_ostream< _CharT, _Traits > &_STLP_CALL endl(basic_ostream< _CharT, _Traits > &__os)
Definition: _ostream.h:357
GLfloat GLfloat p
Definition: glext.h:8902
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define cout
Definition: iostream.cpp:38
#define cerr
Definition: iostream.cpp:39
static void test_slist(void)
Definition: sync.c:298
#define argv
Definition: mplay32.c:18
TestController gTestController
Definition: nc_alloc.cpp:46
unsigned random_base
static void TrackAllocations(bool)
Definition: nc_alloc.h:130
static void SetVerbose(bool val)
Definition: nc_alloc.h:176
static void TurnOffExceptions()
Definition: nc_alloc.h:180
static void SetCurrentContainer(const char *str)
Definition: nc_alloc.h:168
Definition: fci.c:127
Definition: file.c:64
void test_algo()
Definition: test_algo.cpp:248
void test_algobase()
void test_bit_vector()
void test_deque()
Definition: test_deque.cpp:47
void test_hash_multimap()
void test_hash_map()
void test_hash_set()
void test_hash_multiset()
void test_multimap()
Definition: test_map.cpp:50
void test_map()
Definition: test_map.cpp:98
void test_rope()
Definition: test_rope.cpp:49
void test_multiset()
Definition: test_set.cpp:41
void test_set()
Definition: test_set.cpp:75
void test_string()
Definition: test_string.cpp:38
void test_vector()
Definition: test_vector.cpp:74

◆ usage()

static void usage ( const char name)
static

Definition at line 128 of file main.cpp.

129{
130 cerr<<"Usage : "<<name<<" [-n <iterations>] [-s <size>] [-l] [-e] [-q]/[-v] [-t] [test_name...]\n";
131 cerr<<"\t[-n <iterations>] : number of test iterations, default==100;"<<endl;
132 cerr<<"\t[-s <size>] : base value for random container sizes, default==1000;"<<endl;
133 cerr<<"\t[-e] : don't throw exceptions, test for leak in normal conditions;"<<endl;
134// This option was never actually used -- dwa 9/22/97
135// cerr<<"\t[-i] : ignore leak errors;"<<endl;
136 cerr<<"\t[-q] : quiet mode;"<<endl;
137 cerr<<"\t[-v] : verbose mode;"<<endl;
138 cerr<<"\t[-t] : track each allocation;"<<endl;
139 cerr<<"\t[test name [test name...]] : run only some of the tests by name (default==all tests):"<<endl;
140 cerr<<"\t\tpossible test names are : algo vector bit_vector list slist deque set map hash_set hash_map rope string bitset valarray"<<endl;
141 EH_CSTD::exit(1);
142}
Definition: name.c:39