#include <TestSuite.h>
#include <cppunit/Test.h>
#include <cppunit/TestResult.h>
using std::map;
using std::string;
_EXPORT
BTestSuite::BTestSuite( string name )
: fName(name)
{
}
_EXPORT
BTestSuite::~BTestSuite() {
deleteContents();
}
_EXPORT
void
BTestSuite::deleteContents() {
for ( map<string, CppUnit::Test*>::iterator it = fTests.begin();
it != fTests.end();
++it)
delete it->second;
fTests.clear();
}
_EXPORT
void
BTestSuite::run( CppUnit::TestResult *result ) {
for ( map<string, CppUnit::Test*>::iterator it = fTests.begin();
it != fTests.end();
++it )
{
if ( result->shouldStop() )
break;
Test *test = it->second;
test->run( result );
}
}
_EXPORT
int
BTestSuite::countTestCases() const {
int count = 0;
for ( map<string, CppUnit::Test *>::const_iterator it = fTests.begin();
it != fTests.end();
++it )
count += it->second->countTestCases();
return count;
}
_EXPORT
void
BTestSuite::addTest(string name, CppUnit::Test *test) {
fTests[name] = test;
}
_EXPORT
string
BTestSuite::toString() const {
return "suite " + getName();
}
_EXPORT
string
BTestSuite::getName() const {
return fName;
}
_EXPORT
const map<string, CppUnit::Test*> &
BTestSuite::getTests() const {
return fTests;
}