int Runner::runCommandLine( int argc, const char *argv[] ) const { typedef std::deque<std::string> TestNames; Runner subrunner; for ( int index = 1; index < argc; ++index ) { std::string opt = argv[index]; if ( opt == "--list-tests" ) { listTests(); return 0; } else if ( opt == "--test-auto" ) { preventDialogOnCrash(); } else if ( opt == "--test" ) { ++index; if ( index < argc ) { unsigned int testNameIndex; if ( testIndex( argv[index], testNameIndex ) ) { subrunner.add( tests_[testNameIndex] ); } else { fprintf( stderr, "Test '%s' does not exist!\n", argv[index] ); return 2; } } else { printUsage( argv[0] ); return 2; } } else { printUsage( argv[0] ); return 2; } } bool succeeded; if ( subrunner.testCount() > 0 ) { succeeded = subrunner.runAllTest( subrunner.testCount() > 1 ); } else { succeeded = runAllTest( true ); } return succeeded ? 0 : 1; }
// 入口函数 int main(int argc, char* argv[]) { (void)argc; (void)argv; irect r = {.pos={.x=0,.y=0}}; (void)r; runAllTest(); return 0; }