Ticket #2488: cxxtest-fix.patch
File cxxtest-fix.patch, 32.2 KB (added by , 10 years ago) |
---|
-
libraries/source/cxxtest-4.3/cxxtest/Gui.h
27 27 GuiListener() : _state(GREEN_BAR) {} 28 28 virtual ~GuiListener() {} 29 29 30 virtual void runGui( int &argc, char **argv,TestListener &listener)30 virtual void runGui(TestListener &listener) 31 31 { 32 enterGui( argc, argv);32 enterGui(); 33 33 TestRunner::runAllTests(listener); 34 34 leaveGui(); 35 35 } 36 36 37 virtual void enterGui( int & /*argc*/, char ** /*argv*/) {}37 virtual void enterGui() {} 38 38 virtual void leaveGui() {} 39 39 40 40 // … … 171 171 template<class GuiT, class TuiT> 172 172 class GuiTuiRunner : public TeeListener 173 173 { 174 int* _argc;175 char **_argv;176 174 GuiT _gui; 177 175 TuiT _tui; 178 176 179 177 public: 180 GuiTuiRunner() : _argc(0), _argv(0){}178 GuiTuiRunner() {} 181 179 182 void process_commandline(int& argc, char** argv)180 bool process_commandline_args(int& i, int& argc, char* argv[]) 183 181 { 184 _argc = &argc; 185 _argv = argv; 186 setFirst(_gui); 187 setSecond(_tui); 182 if (i == 0) // Init 183 { 184 setFirst(_gui); 185 setSecond(_tui); 186 } 187 return _gui.parse_commandline_args(i, argc, argv); 188 } 189 190 void print_help(const char* name) 191 { 192 _gui.print_help(name); 188 193 } 189 194 190 195 int run() 191 196 { 192 _gui.runGui(* _argc, _argv, *this);197 _gui.runGui(*this); 193 198 return tracker().failedTests(); 194 199 } 195 200 }; -
libraries/source/cxxtest-4.3/cxxtest/PsTestWrapper.cpp
1 1 #include <cxxtest/PsTestWrapper.h> 2 2 3 namespace CxxTest 3 namespace CxxTest 4 4 { 5 const char *g_PsArgv0 = NULL; 6 const char *g_PsOnlySuite = NULL; 7 const char *g_PsOnlyTest = NULL; 8 bool g_PsListSuites = false; 9 } 10 No newline at end of file 5 const char *g_PsOnlySuite = NULL; 6 const char *g_PsOnlyTest = NULL; 7 } -
libraries/source/cxxtest-4.3/cxxtest/PsTestWrapper.h
1 1 #ifndef __cxxtest__PsTestWrapper_h__ 2 2 #define __cxxtest__PsTestWrapper_h__ 3 3 4 #include <cstdio> 5 4 #include <cxxtest/TestMain.h> 6 5 #include <cxxtest/Gui.h> 7 6 // (This is not actually a GUI, but we use the CxxTest GUI mechanism 8 7 // to capture argv and do some special processing) … … 18 17 19 18 #include "ps/DllLoader.h" 20 19 21 namespace CxxTest 20 namespace CxxTest 22 21 { 23 extern const char *g_PsArgv0; 24 extern const char *g_PsOnlySuite; 25 extern const char *g_PsOnlyTest; 26 extern bool g_PsListSuites; 22 extern const char *g_PsOnlySuite; 23 extern const char *g_PsOnlyTest; 27 24 28 class PsTestRunner : public TestRunner 25 class PsTestRunner : public TestRunner 26 { 27 public: 28 static void runAllTests(TestListener &listener) 29 29 { 30 public: 31 static void runAllTests( TestListener &listener ) 32 { 33 // Code copied from TestRunner: 34 tracker().setListener( &listener ); 35 _TS_TRY { PsTestRunner().runWorld(); } 36 _TS_LAST_CATCH( { tracker().failedTest( __FILE__, __LINE__, "Exception thrown from world" ); } ); 37 tracker().setListener( 0 ); 38 } 39 40 void runWorld() 41 { 42 RealWorldDescription wd; 43 WorldGuard sg; 30 // Code copied from TestRunner: 31 tracker().setListener(&listener); 32 _TS_TRY { PsTestRunner().runWorld(); } 33 _TS_LAST_CATCH({ tracker().failedTest(__FILE__, __LINE__, "Exception thrown from world"); }); 34 tracker().setListener(0); 35 } 44 36 45 // Print all the (initially active) test suites, as an 46 // occasionally handy test-runner-debugging feature 47 if ( g_PsListSuites ) 48 for ( SuiteDescription *sd = wd.firstSuite(); sd; sd = sd->next() ) 49 if ( sd->active() ) 50 printf( "%s\n", sd->suiteName() ); 37 void runWorld() 38 { 39 RealWorldDescription wd; 40 WorldGuard sg; 51 41 52 // Allow all but one suite/test to be disabled 53 if ( g_PsOnlySuite ) { 54 for ( SuiteDescription *sd = wd.firstSuite(); sd; sd = sd->next() ) { 55 if ( stringsEqual( sd->suiteName(), g_PsOnlySuite ) ) { 56 for ( TestDescription *td = sd->firstTest(); td; td = td->next() ) 57 if ( g_PsOnlyTest && !stringsEqual( td->testName(), g_PsOnlyTest ) ) 58 td->setActive( false ); 59 } else { 60 sd->setActive( false ); 61 } 62 } 63 } 64 else 42 // Allow all but one suite/test to be disabled 43 if (g_PsOnlySuite) 44 { 45 for (SuiteDescription *sd = wd.firstSuite(); sd; sd = sd->next()) 65 46 { 66 // By default, disable all tests with names containing "DISABLED" 67 // (they can only be run by explicitly naming the suite/test) 68 for ( SuiteDescription *sd = wd.firstSuite(); sd; sd = sd->next() ) { 69 for ( TestDescription *td = sd->firstTest(); td; td = td->next() ) 70 if ( strstr( td->testName(), "DISABLED" ) ) 71 td->setActive( false ); 47 if (stringsEqual(sd->suiteName(), g_PsOnlySuite)) 48 { 49 for (TestDescription *td = sd->firstTest(); td; td = td->next()) 50 if (g_PsOnlyTest && !stringsEqual(td->testName(), g_PsOnlyTest)) 51 { 52 td->setActive(false); 53 } 54 } 55 else 56 { 57 sd->setActive(false); 72 58 } 73 59 } 74 75 // Code copied from TestRunner: 76 tracker().enterWorld( wd ); 77 if ( wd.setUp() ) { 78 for ( SuiteDescription *sd = wd.firstSuite(); sd; sd = sd->next() ) 79 if ( sd->active() ) { 80 runSuite( *sd ); 60 } 61 else 62 { 63 // By default, disable all tests with names containing "DISABLED" 64 // (they can only be run by explicitly naming the suite/test) 65 for (SuiteDescription *sd = wd.firstSuite(); sd; sd = sd->next()) 66 { 67 for (TestDescription *td = sd->firstTest(); td; td = td->next()) 68 if (strstr(td->testName(), "DISABLED")) 69 { 70 td->setActive(false); 81 71 } 82 wd.tearDown();83 72 } 84 tracker().leaveWorld( wd );85 73 } 86 };87 74 88 class PsTestWrapper : public PS_TEST_WRAPPER_BASE 75 // Code copied from TestRunner: 76 tracker().enterWorld(wd); 77 if (wd.setUp()) 78 { 79 for (SuiteDescription *sd = wd.firstSuite(); sd; sd = sd->next()) 80 if (sd->active()) 81 { 82 runSuite(*sd); 83 } 84 wd.tearDown(); 85 } 86 tracker().leaveWorld(wd); 87 } 88 }; 89 90 class PsTestWrapper : public PS_TEST_WRAPPER_BASE 91 { 92 public: 93 virtual void runGui(TestListener &listener) 94 { 95 enterGui(); 96 PsTestRunner::runAllTests(listener); 97 leaveGui(); 98 } 99 virtual bool parse_commandline_args(int& i, int& argc, char* argv[]) 89 100 { 90 public: 91 virtual void runGui( int &argc, char **argv, TestListener &listener ) 101 if (i == 0) 92 102 { 93 parseCommandLine( argc, argv ); 94 enterGui( argc, argv ); 95 PsTestRunner::runAllTests( listener ); 96 leaveGui(); 103 return true; 97 104 } 98 private: 99 void parseCommandLine( int argc, char **argv)105 106 if (!strcmp(argv[i], "-libdir")) 100 107 { 101 g_PsArgv0 = argv[0]; 108 if (++i >= argc) // TODO warn about missing arg 109 { 110 return false; 111 } 102 112 103 for ( int i = 1; i < argc; ++i ) { 104 if ( !strcmp( argv[i], "-test" ) && (i + 1 < argc) ) { 105 char *test = argv[++i]; 106 // Try splitting as "suite::test", else use the whole string as the suite name 107 char *colons = strstr( test, "::" ); 108 if ( colons ) { 109 colons[0] = '\0'; // (modifying argv is safe enough) 110 g_PsOnlySuite = test; 111 g_PsOnlyTest = colons + 2; 112 } else { 113 g_PsOnlySuite = test; 114 } 115 } else if ( !strcmp( argv[i], "-list" ) ) { 116 g_PsListSuites = true; 117 } else if ( !strcmp( argv[i], "-libdir" ) ) { 118 DllLoader::OverrideLibdir( argv[++i] ); 119 } else { 120 fprintf( stderr, "Unrecognized command line option '%s'\n", argv[i] ); 121 fprintf( stderr, "Permitted options:\n" ); 122 fprintf( stderr, " %s -list\n", argv[0] ); 123 fprintf( stderr, " %s -test TestSuiteName\n", argv[0] ); 124 fprintf( stderr, " %s -test TestSuiteName::test_case_name\n", argv[0] ); 125 fprintf( stderr, " %s -libdir .\n", argv[0] ); 126 fprintf( stderr, "\n" ); 127 } 113 DllLoader::OverrideLibdir(argv[i]); 114 } 115 else if (!strcmp(argv[i], "-test")) // Superseded by just specifying the "Suite" or "Suite Test" on the cli 116 { 117 if (++i >= argc) 118 { 119 return false; 120 } 121 122 char *test = argv[i]; 123 // Try splitting as "suite::test", else use the whole string as the suite name 124 char *colons = strstr(test, "::"); 125 if (colons) 126 { 127 colons[0] = '\0'; // (modifying argv is safe enough) 128 g_PsOnlySuite = test; 129 g_PsOnlyTest = colons + 2; 130 } 131 else 132 { 133 g_PsOnlySuite = test; 128 134 } 129 135 } 130 }; 136 else 137 { 138 return false; 139 } 140 141 return true; 142 } 143 virtual void print_help(const char* name) 144 { 145 CXXTEST_STD(cerr) << name << " -test TestSuiteName\n"; 146 CXXTEST_STD(cerr) << name << " -test TestSuiteName::test_case_name\n"; 147 CXXTEST_STD(cerr) << name << " -libdir <dir>" << CXXTEST_STD(endl); 148 } 149 private: 150 /*void parseCommandLine( int argc, char **argv ) 151 { 152 if ( !strcmp( argv[i], "-test" ) && (i + 1 < argc) ) { 153 } else if ( !strcmp( argv[i], "-list" ) ) { // duplicates --help-tests 154 g_PsListSuites = true; 155 } else { 156 fprintf( stderr, " %s -list\n", argv[0] ); 157 }*/ 158 }; 131 159 } 132 160 133 #endif // __cxxtest__PsTestWrapper_h__ 134 No newline at end of file 161 #endif // __cxxtest__PsTestWrapper_h__ -
libraries/source/cxxtest-4.3/cxxtest/QtGui.h
41 41 class QtGui : public GuiListener 42 42 { 43 43 public: 44 void enterGui(int &argc, char **argv)45 {46 parseCommandLine(argc, argv);47 createApplication(argc, argv);48 }49 50 44 void enterWorld(const WorldDescription &wd) 51 45 { 52 46 createWindow(wd); … … 100 94 } 101 95 } 102 96 97 virtual bool parse_commandline_args(int& i, int& argc, char* argv[]) 98 { 99 if (i == 0) 100 { 101 _startMinimized = _keep = false; 102 _title = argv[0]; 103 // Removes arguments it recognizes 104 _application = new QApplication(argc, argv); 105 return true; 106 } 107 108 if (!strcmp(argv[i], "-minimized")) 109 { 110 _startMinimized = true; 111 } 112 else if (!strcmp(argv[i], "-keep")) 113 { 114 _keep = true; 115 } 116 else if (!strcmp(argv[i], "-title")) 117 { 118 if (++i >= argc) 119 { 120 return false; 121 } 122 123 _title = argv[i]; 124 } 125 else 126 { 127 return false; 128 } 129 130 return true; 131 } 132 103 133 private: 104 134 QString _title; 105 135 bool _startMinimized, _keep; … … 112 142 QStatusBar *_statusBar; 113 143 QLabel *_suiteName, *_testName, *_testsDone; 114 144 115 void parseCommandLine(int argc, char **argv)116 {117 _startMinimized = _keep = false;118 _title = argv[0];119 120 for (int i = 1; i < argc; ++ i)121 {122 QString arg(argv[i]);123 if (arg == "-minimized")124 {125 _startMinimized = true;126 }127 else if (arg == "-keep")128 {129 _keep = true;130 }131 else if (arg == "-title" && (i + 1 < argc))132 {133 _title = argv[++i];134 }135 }136 }137 138 void createApplication(int &argc, char **argv)139 {140 _application = new QApplication(argc, argv);141 }142 143 145 void createWindow(const WorldDescription &wd) 144 146 { 145 147 getTotalTests(wd); -
libraries/source/cxxtest-4.3/cxxtest/RealDescriptions.cpp
55 55 { 56 56 bool ok; 57 57 _TS_TRY { ok = gf->setUp(); } 58 _TS_LAST_CATCH( 58 _TS_LAST_CATCH({ ok = false; }); 59 59 60 60 if (!ok) 61 61 { … … 70 70 _TSM_ASSERT_THROWS_NOTHING(file(), line(), "Exception thrown from setUp()", suite()->setUp(); ok = true); 71 71 if (ok == false) { return ok; } 72 72 } 73 _TS_CATCH_ABORT( 74 _TS_CATCH_SKIPPED( 73 _TS_CATCH_ABORT({ return false; }) 74 _TS_CATCH_SKIPPED({ return false; }); 75 75 76 76 return true; 77 77 } … … 87 87 { 88 88 _TSM_ASSERT_THROWS_NOTHING(file(), line(), "Exception thrown from tearDown()", suite()->tearDown()); 89 89 } 90 _TS_CATCH_ABORT( 91 _TS_CATCH_SKIPPED( 90 _TS_CATCH_ABORT({ return false; }) 91 _TS_CATCH_SKIPPED({ return false; }); 92 92 93 93 for (GlobalFixture *gf = GlobalFixture::lastGlobalFixture(); gf != 0; gf = gf->prevGlobalFixture()) 94 94 { 95 95 bool ok; 96 96 _TS_TRY { ok = gf->tearDown(); } 97 _TS_LAST_CATCH( 97 _TS_LAST_CATCH({ ok = false; }); 98 98 99 99 if (!ok) 100 100 { … … 119 119 void RealTestDescription::run() 120 120 { 121 121 _TS_TRY { runTest(); } 122 _TS_CATCH_ABORT( 123 _TS_CATCH_SKIPPED( 122 _TS_CATCH_ABORT({}) 123 _TS_CATCH_SKIPPED({}) 124 124 ___TSM_CATCH(file(), line(), "Exception thrown from test"); 125 125 } 126 126 … … 311 311 ok = false; 312 312 } 313 313 } 314 _TS_LAST_CATCH( 314 _TS_LAST_CATCH({ ok = false; }); 315 315 316 316 if (!ok) 317 317 { … … 329 329 { 330 330 bool ok; 331 331 _TS_TRY { ok = gf->tearDownWorld(); } 332 _TS_LAST_CATCH( 332 _TS_LAST_CATCH({ ok = false; }); 333 333 334 334 if (!ok) 335 335 { -
libraries/source/cxxtest-4.3/cxxtest/RealDescriptions.h
191 191 _TSM_ASSERT_THROWS_NOTHING(file(), _createLine, "Exception thrown from createSuite()", createSuite()); 192 192 _TSM_ASSERT(file(), _createLine, "createSuite() failed", suite() != 0); 193 193 } 194 _TS_CATCH_ABORT( 195 _TS_CATCH_SKIPPED( 194 _TS_CATCH_ABORT({ return false; }) 195 _TS_CATCH_SKIPPED({ return false; }); 196 196 197 197 return (suite() != 0); 198 198 } … … 209 209 { 210 210 _TSM_ASSERT_THROWS_NOTHING(file(), _destroyLine, "destroySuite() failed", destroySuite()); 211 211 } 212 _TS_CATCH_ABORT( 213 _TS_CATCH_SKIPPED( 212 _TS_CATCH_ABORT({ return false; }) 213 _TS_CATCH_SKIPPED({ return false; }); 214 214 215 215 return true; 216 216 } -
libraries/source/cxxtest-4.3/cxxtest/TestListener.h
23 23 24 24 #include <cxxtest/Descriptions.h> 25 25 26 #include <cstdio> 26 27 namespace CxxTest 27 28 { 28 29 class TestListener … … 30 31 public: 31 32 TestListener() {} 32 33 virtual ~TestListener() {} 33 virtual void process_commandline(int& /*argc*/, char** /*argv*/) {} 34 virtual void print_help(const char* /*name*/) {} 35 virtual bool process_commandline_args(int& /*i*/, int& /*argc*/, char* /*argv*/[]) { return false; } 34 36 35 37 virtual void enterWorld(const WorldDescription & /*desc*/) {} 36 38 virtual void enterSuite(const SuiteDescription & /*desc*/) {} -
libraries/source/cxxtest-4.3/cxxtest/TestMain.h
33 33 namespace CxxTest 34 34 { 35 35 36 inline void print_help(const char* name) 36 template <class TesterT> 37 inline void print_help(TesterT& tmp, const char* name) 37 38 { 38 CXXTEST_STD(cerr) << name << " <suitename>" << CXXTEST_STD(endl); 39 CXXTEST_STD(cerr) << name << " <suitename> <testname>" << CXXTEST_STD(endl); 40 CXXTEST_STD(cerr) << name << " -h" << CXXTEST_STD(endl); 41 CXXTEST_STD(cerr) << name << " --help" << CXXTEST_STD(endl); 42 CXXTEST_STD(cerr) << name << " --help-tests" << CXXTEST_STD(endl); 43 CXXTEST_STD(cerr) << name << " -v Enable tracing output." << CXXTEST_STD(endl); 39 CXXTEST_STD(cerr) << name << " <suitename>\n"; 40 CXXTEST_STD(cerr) << name << " <suitename> <testname>\n"; 41 CXXTEST_STD(cerr) << name << " -h\n"; 42 CXXTEST_STD(cerr) << name << " --help\n"; 43 CXXTEST_STD(cerr) << name << " --help-tests\n"; 44 CXXTEST_STD(cerr) << name << " -v Enable tracing output.\n"; 45 CXXTEST_STD(cerr) << "Frontend specific options:" << CXXTEST_STD(endl); 46 tmp.print_help(name); 44 47 } 45 48 #endif 46 49 … … 54 57 // This is a primitive parser, but I'm not sure what sort of portable 55 58 // parser should be used in cxxtest. 56 59 // 57 58 60 #if defined(_CXXTEST_HAVE_STD) 59 // 60 // Print command-line syntax 61 // 62 for (i nt i= 1; i < argc; i++)61 bool suiteSpecifed = false; 62 int i = 0; 63 tmp.process_commandline_args(i, argc, argv); 64 for (i = 1; i < argc; i++) 63 65 { 64 66 if ((CXXTEST_STD(strcmp)(argv[i], "-h") == 0) || (CXXTEST_STD(strcmp)(argv[i], "--help") == 0)) 65 67 { 66 print_help( argv[0]);68 print_help(tmp, argv[0]); 67 69 return 0; 68 70 } 69 else if ((CXXTEST_STD(strcmp)(argv[ 1], "--help-tests") == 0))71 else if ((CXXTEST_STD(strcmp)(argv[i], "--help-tests") == 0)) 70 72 { 71 73 CXXTEST_STD(cout) << "Suite/Test Names" << CXXTEST_STD(endl); 72 74 CXXTEST_STD(cout) << "---------------------------------------------------------------------------" << CXXTEST_STD(endl); … … 77 79 } 78 80 return 0; 79 81 } 80 } 81 82 // 83 // Process command-line options here. 84 // 85 while ((argc > 1) && (argv[1][0] == '-')) 86 { 87 if (CXXTEST_STD(strcmp)(argv[1], "-v") == 0) 82 else if (CXXTEST_STD(strcmp)(argv[i], "-v") == 0) 88 83 { 89 84 tracker().print_tracing = true; 90 85 } 91 else 92 { 93 CXXTEST_STD(cerr) << "ERROR: unknown option '" << argv[1] << "'" << CXXTEST_STD(endl); 94 return -1; 95 } 96 for (int i = 1; i < (argc - 1); i++) 97 { 98 argv[i] = argv[i + 1]; 99 } 100 argc--; 101 } 102 103 // 104 // Run experiments 105 // 106 bool status = false; 107 if ((argc == 2) && (argv[1][0] != '-')) 108 { 109 status = leaveOnly(argv[1]); 110 if (!status) 86 else if (argv[i][0] == '-') 111 87 { 112 CXXTEST_STD(cerr) << "ERROR: unknown suite '" << argv[1] << "'" << CXXTEST_STD(endl); 113 return -1; 88 // Increments i if it handles more arguments 89 if (!tmp.process_commandline_args(i, argc, argv)) 90 { 91 CXXTEST_STD(cerr) << "ERROR: unknown option '" << argv[i] << "'" << CXXTEST_STD(endl); 92 return -1; 93 } 114 94 } 115 } 116 if ((argc == 3) && (argv[1][0] != '-')) 117 { 118 status = leaveOnly(argv[1], argv[2]); 119 if (!status) 95 else 120 96 { 121 CXXTEST_STD(cerr) << "ERROR: unknown test '" << argv[1] << "::" << argv[2] << "'" << CXXTEST_STD(endl); 122 return -1; 97 if (suiteSpecifed) 98 { 99 CXXTEST_STD(cerr) << "ERROR: only one suite or one test can be specified" << CXXTEST_STD(endl); 100 return -1; 101 } 102 suiteSpecified = true; 103 bool status = false; 104 // Test case and test suite 105 if (i + 1 < argc) // suite and test 106 { 107 status = leaveOnly(argv[i], argv[i + 1]); 108 if (!status) 109 { 110 CXXTEST_STD(cerr) << "ERROR: unknown test '" << argv[i] << "::" << argv[i + 1] << "'" << CXXTEST_STD(endl); 111 return -1; 112 } 113 i++; // We handled two parameters 114 } 115 else // suite 116 { 117 // TODO also handle "Suite::Test"? 118 status = leaveOnly(argv[i]); 119 if (!status) 120 { 121 CXXTEST_STD(cerr) << "ERROR: unknown suite '" << argv[i] << "'" << CXXTEST_STD(endl); 122 return -1; 123 } 124 } 123 125 } 124 126 } 125 127 #endif 126 128 127 tmp.process_commandline(argc, argv);128 129 return tmp.run(); 129 130 } 130 131 -
libraries/source/cxxtest-4.3/cxxtest/TestRunner.h
27 27 { 28 28 class TestRunner 29 29 { 30 30 friend class PsTestRunner; 31 31 32 32 public: 33 33 … … 40 40 { 41 41 tracker().setListener(&listener); 42 42 _TS_TRY { TestRunner().runWorld(); } 43 _TS_LAST_CATCH( 43 _TS_LAST_CATCH({ tracker().failedTest(__FILE__, __LINE__, "Exception thrown from world"); }); 44 44 tracker().setListener(0); 45 45 } 46 46 -
libraries/source/cxxtest-4.3/cxxtest/Win32Gui.h
38 38 class Win32Gui : public GuiListener 39 39 { 40 40 public: 41 void enterGui(int &argc, char **argv)42 {43 parseCommandLine(argc, argv);44 }45 46 41 void enterWorld(const WorldDescription &wd) 47 42 { 48 43 getTotalTests(wd); … … 94 89 DestroyWindow(_mainWindow); 95 90 } 96 91 92 virtual bool parse_commandline_args(int& i, int& argc, char* argv[]) 93 { 94 if (i == 0) 95 { 96 _startMinimized = _keep = false; 97 _title = argv[0]; 98 return true; 99 } 100 101 if (!lstrcmpA(argv[i], "-minimized")) 102 { 103 _startMinimized = true; 104 } 105 else if (!lstrcmpA(argv[i], "-keep")) 106 { 107 _keep = false; 108 } 109 else if (!lstrcmpA(argv[i], "-title")) 110 { 111 if (++i >= argc) 112 { 113 return false; 114 } 115 116 _title = argv[i]; 117 } 118 else 119 { 120 return false; 121 } 122 123 return true; 124 } 125 97 126 private: 98 127 const char *_title; 99 128 bool _startMinimized, _keep; … … 117 146 DWORD _worldStart, _suiteStart, _testStart; 118 147 char _timeString[sizeof("00:00:00")]; 119 148 120 void parseCommandLine(int argc, char **argv)121 {122 _startMinimized = _keep = false;123 _title = argv[0];124 125 for (int i = 1; i < argc; ++ i)126 {127 if (!lstrcmpA(argv[i], "-minimized"))128 {129 _startMinimized = true;130 }131 else if (!lstrcmpA(argv[i], "-keep"))132 {133 _keep = true;134 }135 else if (!lstrcmpA(argv[i], "-title") && (i + 1 < argc))136 {137 _title = argv[++i];138 }139 }140 }141 142 149 void getTotalTests() 143 150 { 144 151 getTotalTests(tracker().world()); -
libraries/source/cxxtest-4.3/cxxtest/Win32ODSPrinter.h
5 5 6 6 #include "lib/sysdep/os/win/win.h" 7 7 8 namespace CxxTest 8 namespace CxxTest 9 9 { 10 11 12 13 14 char* buf = new char[n+1];15 16 17 18 19 20 21 10 class ods_ostreambuf : public std::streambuf 11 { 12 std::streamsize xsputn(const char* s, std::streamsize n) 13 { 14 char* buf = new char[n + 1]; 15 memcpy(buf, s, n); 16 buf[n] = '\0'; 17 OutputDebugStringA(buf); 18 delete[] buf; 19 return n; 20 } 21 }; 22 22 23 24 25 26 27 28 29 23 class Win32ODSPrinter : public ParenPrinter 24 { 25 ods_ostreambuf buf; 26 std::ostream ostr; 27 public: 28 Win32ODSPrinter() : buf(), ostr(&buf), ParenPrinter(ostr) {} 29 }; 30 30 } 31 31 32 32 #endif // __cxxtest__Win32ODSPrinter_h__ 33 No newline at end of file -
libraries/source/cxxtest-4.3/cxxtest/X11Gui.h
36 36 class X11Gui : public GuiListener 37 37 { 38 38 public: 39 void enterGui(int &argc, char **argv)40 {41 parseCommandLine(argc, argv);42 }43 44 39 void enterWorld(const WorldDescription &wd) 45 40 { 46 41 openDisplay(); … … 98 93 } 99 94 } 100 95 101 private: 102 const char *_programName; 103 Display *_display; 104 Window _window; 105 unsigned _numTotalTests, _testsDone; 106 char _strTotalTests[WorldDescription::MAX_STRLEN_TOTAL_TESTS]; 107 const char *_foregroundName, *_backgroundName; 108 const char *_greenName, *_yellowName, *_redName; 109 unsigned long _foreground, _background, _barColor; 110 int _width, _height; 111 GC _gc; 112 const char *_fontName; 113 XID _fontId; 114 XFontStruct *_fontInfo; 115 int _textHeight, _textDescent; 116 long _eventMask; 117 Colormap _colormap; 118 119 void parseCommandLine(int &argc, char **argv) 96 virtual bool parse_commandline_args(int& i, int& argc, char* argv[]) 120 97 { 121 _programName = argv[0]; 122 123 _fontName = 0; 124 _foregroundName = "Black"; 125 _backgroundName = "Grey"; 126 _greenName = "Green"; 127 _yellowName = "Yellow"; 128 _redName = "Red"; 98 if (i == 0) 99 { 100 _programName = argv[0]; 101 102 _fontName = 0; 103 _foregroundName = "Black"; 104 _backgroundName = "Grey"; 105 _greenName = "Green"; 106 _yellowName = "Yellow"; 107 _redName = "Red"; 108 return true; 109 } 129 110 130 for (int i = 1; i + 1 < argc; ++ i)111 if (!strcmp(argv[i], "-title")) 131 112 { 132 if ( !strcmp(argv[i], "-title"))113 if (++i >= argc) 133 114 { 134 _programName = argv[++ i];115 return false; 135 116 } 136 else if (!strcmp(argv[i], "-fn") || !strcmp(argv[i], "-font")) 117 118 _programName = argv[i]; 119 return true; 120 } 121 else if (!strcmp(argv[i], "-fn") || !strcmp(argv[i], "-font")) 122 { 123 if (++i >= argc) 137 124 { 138 _fontName = argv[++ i];125 return false; 139 126 } 140 else if (!strcmp(argv[i], "-fg") || !strcmp(argv[i], "-foreground")) 127 128 _fontName = argv[i]; 129 return true; 130 } 131 else if (!strcmp(argv[i], "-fg") || !strcmp(argv[i], "-foreground")) 132 { 133 if (++i >= argc) 141 134 { 142 _foregroundName = argv[++ i];135 return false; 143 136 } 144 else if (!strcmp(argv[i], "-bg") || !strcmp(argv[i], "-background")) 137 138 _foregroundName = argv[i]; 139 return true; 140 } 141 else if (!strcmp(argv[i], "-bg") || !strcmp(argv[i], "-background")) 142 { 143 if (++i >= argc) 145 144 { 146 _backgroundName = argv[++ i];145 return false; 147 146 } 148 else if (!strcmp(argv[i], "-green")) 147 148 _backgroundName = argv[i]; 149 return true; 150 } 151 else if (!strcmp(argv[i], "-green")) 152 { 153 if (++i >= argc) 149 154 { 150 _greenName = argv[++ i];155 return false; 151 156 } 152 else if (!strcmp(argv[i], "-yellow")) 157 158 _greenName = argv[i]; 159 return true; 160 } 161 else if (!strcmp(argv[i], "-yellow")) 162 { 163 if (++i >= argc) 153 164 { 154 _yellowName = argv[++ i];165 return false; 155 166 } 156 else if (!strcmp(argv[i], "-red")) 167 168 _yellowName = argv[i]; 169 return true; 170 } 171 else if (!strcmp(argv[i], "-red")) 172 { 173 if (++i >= argc) 157 174 { 158 _redName = argv[++ i];175 return false; 159 176 } 177 178 _redName = argv[i]; 179 return true; 160 180 } 181 return false; 161 182 } 162 183 184 private: 185 const char *_programName; 186 Display *_display; 187 Window _window; 188 unsigned _numTotalTests, _testsDone; 189 char _strTotalTests[WorldDescription::MAX_STRLEN_TOTAL_TESTS]; 190 const char *_foregroundName, *_backgroundName; 191 const char *_greenName, *_yellowName, *_redName; 192 unsigned long _foreground, _background, _barColor; 193 int _width, _height; 194 GC _gc; 195 const char *_fontName; 196 XID _fontId; 197 XFontStruct *_fontInfo; 198 int _textHeight, _textDescent; 199 long _eventMask; 200 Colormap _colormap; 201 163 202 void openDisplay() 164 203 { 165 204 _display = XOpenDisplay(NULL); -
libraries/source/cxxtest-4.3/cxxtest/XmlFormatter.h
385 385 std::ostringstream os; 386 386 const time_t current_date(time(0)); 387 387 char current_date_string[27]; 388 const size_t n = strlen(ctime_r(¤t_date,current_date_string)); 389 if (n) { 390 current_date_string[n-1] = '\0'; // remove the ending \n 391 } else { 388 const size_t n = strlen(ctime_r(¤t_date, current_date_string)); 389 if (n) 390 { 391 current_date_string[n - 1] = '\0'; // remove the ending \n 392 } 393 else 394 { 392 395 current_date_string[0] = '\0'; // just in case... 393 396 } 394 397 os << totaltime;