diff --git a/testrunner.cpp b/testrunner.cpp index 901de37da..d8d1575ec 100644 --- a/testrunner.cpp +++ b/testrunner.cpp @@ -27,10 +27,10 @@ bool CheckCodingStyle = true; extern std::vector Files; -int main() +int main(int argc, const char *argv[]) { Files.push_back( "test.cpp" ); - TestFixture::runTests(); + TestFixture::runTests( (argc==2) ? argv[1] : NULL ); return 0; } diff --git a/testsuite.cpp b/testsuite.cpp index 7cd962262..e5bd5204e 100644 --- a/testsuite.cpp +++ b/testsuite.cpp @@ -103,8 +103,16 @@ void TestFixture::printTests() } } -void TestFixture::runTests() +void TestFixture::runTests(const char cmd[]) { + std::string classname(cmd ? cmd : ""); + std::string testname(""); + if ( classname.find("::") != std::string::npos ) + { + testname = classname.substr( classname.find("::") + 2 ); + classname.erase( classname.find("::") ); + } + countTests = 0; errmsg.str(""); @@ -112,7 +120,8 @@ void TestFixture::runTests() for ( std::list::const_iterator it = tests.begin(); it != tests.end(); ++it ) { - (*it)->run(); + if ( classname.empty() || (*it)->classname == classname ) + (*it)->run(); } std::cout << "\n\nTesting Complete\nNumber of tests: " << countTests << "\n"; diff --git a/testsuite.h b/testsuite.h index 0b2af5316..a1a2ed8df 100644 --- a/testsuite.h +++ b/testsuite.h @@ -22,7 +22,7 @@ public: virtual ~TestFixture() { } static void printTests(); - static void runTests(); + static void runTests(const char cmd[]); };