sl@0: /*********************************************************************************** sl@0: Main.cpp sl@0: * Portions Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. sl@0: * Copyright (c) 1997 sl@0: * Mark of the Unicorn, Inc. sl@0: * sl@0: * Permission to use, copy, modify, distribute and sell this software sl@0: * and its documentation for any purpose is hereby granted without fee, sl@0: * provided that the above copyright notice appear in all copies and sl@0: * that both that copyright notice and this permission notice appear sl@0: * in supporting documentation. Mark of the Unicorn makes no sl@0: * representations about the suitability of this software for any sl@0: * purpose. It is provided "as is" without express or implied warranty. sl@0: sl@0: * Copyright (c) 1997 sl@0: * Moscow Center for SPARC Technology sl@0: * sl@0: * Permission to use, copy, modify, distribute and sell this software sl@0: * and its documentation for any purpose is hereby granted without fee, sl@0: * provided that the above copyright notice appear in all copies and sl@0: * that both that copyright notice and this permission notice appear sl@0: * in supporting documentation. Moscow Center for SPARC Technology makes sl@0: no sl@0: * representations about the suitability of this software for any sl@0: * purpose. It is provided "as is" without express or implied warranty. sl@0: sl@0: ***********************************************************************************/ sl@0: #include "Prefix.h" sl@0: #include "Tests.h" sl@0: sl@0: #if defined (EH_NEW_IOSTREAMS) sl@0: # include sl@0: # else sl@0: # include sl@0: #endif sl@0: sl@0: #if defined(macintosh)&&(!defined(__MRC__) && !defined(__SC__)) || defined (_MAC) && defined(__MWERKS__) sl@0: sl@0: # include sl@0: # include sl@0: # include sl@0: sl@0: # ifdef EH_NEW_HEADERS sl@0: # include sl@0: # include sl@0: # include sl@0: # else sl@0: # include sl@0: # include sl@0: # include sl@0: # endif sl@0: sl@0: # if defined (_STL_DEBUG) sl@0: sl@0: # if defined ( EH_USE_SGI_STL ) sl@0: // Override assertion behavior sl@0: # include sl@0: //# include sl@0: void STLPORT::__stl_debug_message(const char * format_str, ...) sl@0: { sl@0: std::va_list args; sl@0: va_start( args, format_str ); sl@0: char msg[256]; sl@0: std::vsnprintf(msg, sizeof(msg)/sizeof(*msg) - 1, format_str, args ); sl@0: DebugStr( c2pstr(msg) ); sl@0: } sl@0: # else sl@0: /*=================================================================================== sl@0: __assertion_failed (override standard library function) sl@0: sl@0: EFFECTS: Breaks into the debugger and shows the assertion. This implementation sl@0: is Mac-specific; others could be added for other platforms. sl@0: ====================================================================================*/ sl@0: extern "C" sl@0: { sl@0: void __assertion_failed(char *condition, char *testfilename, int lineno); sl@0: void __assertion_failed(char *condition, char *testfilename, int lineno) sl@0: { sl@0: char msg[256]; sl@0: std::strncpy( msg, condition, 255 ); sl@0: std::strncat( msg, ": ", 255 ); sl@0: std::strncat( msg, testfilename, 255 ); sl@0: std::strncat( msg, ", ", 255 ); sl@0: char line[20]; sl@0: std::sprintf( line, "%d", lineno ); sl@0: std::strncat( msg, line, 255 ); sl@0: DebugStr( c2pstr( msg ) ); sl@0: } sl@0: } sl@0: # endif sl@0: sl@0: # endif sl@0: sl@0: #endif sl@0: sl@0: #include "nc_alloc.h" sl@0: sl@0: #if defined (EH_NEW_HEADERS) sl@0: # include sl@0: # include sl@0: # else sl@0: # include sl@0: # include sl@0: #endif sl@0: sl@0: #include "TestClass.h" sl@0: #include "LeakCheck.h" sl@0: #include "test_construct.h" sl@0: #ifdef __BORLANDC__ sl@0: # include sl@0: #endif sl@0: sl@0: # if defined(EH_USE_NAMESPACES) sl@0: namespace // dwa 1/21/00 - must use unnamed namespace here to avoid conflict under gcc using native streams sl@0: { sl@0: using namespace std; sl@0: // using std::cerr; sl@0: // using std::endl; sl@0: } sl@0: # endif sl@0: sl@0: sl@0: /*=================================================================================== sl@0: usage (file-static helper) sl@0: sl@0: EFFECTS: Prints a message describing the command-line parameters sl@0: ====================================================================================*/ sl@0: static void usage(const char* name) sl@0: { sl@0: cerr<] [-s ] [-l] [-e] [-q]/[-v] [-t] [test_name...]\n"; sl@0: cerr<<"\t[-n ] : number of test iterations, default==100;"<] : base value for random container sizes, default==1000;"< sl@0: # else sl@0: # include sl@0: # endif sl@0: sl@0: #if defined(_WIN32_WCE) || defined(__SYMBIAN32__) sl@0: #include sl@0: #endif sl@0: sl@0: int _STLP_CALL main(int argc, char** argv) sl@0: { sl@0: #if defined(_WIN32_WCE) || defined(__SYMBIAN32__) sl@0: std::ofstream file( "c:\\eh_test.txt" ); sl@0: std::streambuf* old_cout_buf = cout.rdbuf(file.rdbuf()); sl@0: std::streambuf* old_cerr_buf = cerr.rdbuf(file.rdbuf()); sl@0: #endif sl@0: #if defined( __MWERKS__ ) && defined( macintosh ) // Get command line. sl@0: argc = ccommand(&argv); sl@0: // Allow the i/o window to be repositioned. sl@0: // EH_STD::string s; sl@0: // getline(EH_STD::cin, s); sl@0: #endif sl@0: unsigned int niters=2; sl@0: bool run_all=true; sl@0: bool run_slist = false; sl@0: bool run_list = false; sl@0: bool run_vector = false; sl@0: bool run_bit_vector = false; sl@0: bool run_deque = false; sl@0: bool run_hash_map = false; sl@0: bool run_hash_set = false; sl@0: bool run_set = false; sl@0: bool run_map = false; sl@0: bool run_algo = false; sl@0: bool run_algobase = false; sl@0: bool run_rope = false; sl@0: bool run_string = false; sl@0: bool run_bitset = false; sl@0: bool run_valarray = false; sl@0: sl@0: int cur_argv; sl@0: char *p, *p1; sl@0: #if defined (EH_NEW_IOSTREAMS) sl@0: std::ios_base::sync_with_stdio(false); sl@0: #endif sl@0: sl@0: cerr << argv[0]<<" : Exception handling testsuite.\n"; sl@0: cerr.flush(); sl@0: sl@0: bool track_allocations = false; sl@0: // parse parameters : sl@0: // leak_test [-iterations] [-test] ... sl@0: for (cur_argv=1; cur_argv