Testing: Only run tests in a specified class
This commit is contained in:
parent
cde8e89987
commit
69e5e09581
|
@ -27,10 +27,10 @@ bool CheckCodingStyle = true;
|
||||||
extern std::vector<std::string> Files;
|
extern std::vector<std::string> Files;
|
||||||
|
|
||||||
|
|
||||||
int main()
|
int main(int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
Files.push_back( "test.cpp" );
|
Files.push_back( "test.cpp" );
|
||||||
TestFixture::runTests();
|
TestFixture::runTests( (argc==2) ? argv[1] : NULL );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;
|
countTests = 0;
|
||||||
errmsg.str("");
|
errmsg.str("");
|
||||||
|
|
||||||
|
@ -112,7 +120,8 @@ void TestFixture::runTests()
|
||||||
|
|
||||||
for ( std::list<TestFixture *>::const_iterator it = tests.begin(); it != tests.end(); ++it )
|
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";
|
std::cout << "\n\nTesting Complete\nNumber of tests: " << countTests << "\n";
|
||||||
|
|
|
@ -22,7 +22,7 @@ public:
|
||||||
virtual ~TestFixture() { }
|
virtual ~TestFixture() { }
|
||||||
|
|
||||||
static void printTests();
|
static void printTests();
|
||||||
static void runTests();
|
static void runTests(const char cmd[]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue