Testing: Only run tests in a specified class

This commit is contained in:
Daniel Marjamäki 2008-10-26 11:11:26 +00:00
parent cde8e89987
commit 69e5e09581
3 changed files with 14 additions and 5 deletions

View File

@ -27,10 +27,10 @@ bool CheckCodingStyle = true;
extern std::vector<std::string> 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;
}

View File

@ -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<TestFixture *>::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";

View File

@ -22,7 +22,7 @@ public:
virtual ~TestFixture() { }
static void printTests();
static void runTests();
static void runTests(const char cmd[]);
};