#include "cppunit/TestSuite.h"
#include "cppunit/TestResult.h"
namespace CppUnit {
TestSuite::TestSuite( string name )
: m_name( name )
{
}
TestSuite::~TestSuite()
{
deleteContents();
}
void
TestSuite::deleteContents()
{
for ( vector<Test *>::iterator it = m_tests.begin();
it != m_tests.end();
++it)
delete *it;
m_tests.clear();
}
void
TestSuite::run( TestResult *result )
{
for ( vector<Test *>::iterator it = m_tests.begin();
it != m_tests.end();
++it )
{
if ( result->shouldStop() )
break;
Test *test = *it;
test->run( result );
}
}
int
TestSuite::countTestCases() const
{
int count = 0;
for ( vector<Test *>::const_iterator it = m_tests.begin();
it != m_tests.end();
++it )
count += (*it)->countTestCases();
return count;
}
void
TestSuite::addTest( Test *test )
{
m_tests.push_back( test );
}
string
TestSuite::toString() const
{
return "suite " + getName();
}
string
TestSuite::getName() const
{
return m_name;
}
const vector<Test *> &
TestSuite::getTests() const
{
return m_tests;
}
}