Blame src/cppunit/TestRunner.cpp

Packit 8c9aa0
#include <cppunit/config/SourcePrefix.h>
Packit 8c9aa0
#include <cppunit/TestRunner.h>
Packit 8c9aa0
#include <cppunit/TestPath.h>
Packit 8c9aa0
#include <cppunit/TestResult.h>
Packit 8c9aa0
Packit 8c9aa0
Packit 8c9aa0
CPPUNIT_NS_BEGIN
Packit 8c9aa0
Packit 8c9aa0
Packit 8c9aa0
TestRunner::WrappingSuite::WrappingSuite( const std::string &name ) 
Packit 8c9aa0
    : TestSuite( name )
Packit 8c9aa0
{
Packit 8c9aa0
}
Packit 8c9aa0
Packit 8c9aa0
Packit 8c9aa0
int 
Packit 8c9aa0
TestRunner::WrappingSuite::getChildTestCount() const
Packit 8c9aa0
{
Packit 8c9aa0
  if ( hasOnlyOneTest() )
Packit 8c9aa0
    return getUniqueChildTest()->getChildTestCount();
Packit 8c9aa0
  return TestSuite::getChildTestCount();
Packit 8c9aa0
}
Packit 8c9aa0
Packit 8c9aa0
Packit 8c9aa0
std::string 
Packit 8c9aa0
TestRunner::WrappingSuite::getName() const
Packit 8c9aa0
{
Packit 8c9aa0
  if ( hasOnlyOneTest() )
Packit 8c9aa0
    return getUniqueChildTest()->getName();
Packit 8c9aa0
  return TestSuite::getName();
Packit 8c9aa0
}
Packit 8c9aa0
Packit 8c9aa0
Packit 8c9aa0
Test *
Packit 8c9aa0
TestRunner::WrappingSuite::doGetChildTestAt( int index ) const
Packit 8c9aa0
{
Packit 8c9aa0
  if ( hasOnlyOneTest() )
Packit 8c9aa0
    return getUniqueChildTest()->getChildTestAt( index );
Packit 8c9aa0
  return TestSuite::doGetChildTestAt( index );
Packit 8c9aa0
}
Packit 8c9aa0
Packit 8c9aa0
Packit 8c9aa0
void 
Packit 8c9aa0
TestRunner::WrappingSuite::run( TestResult *result )
Packit 8c9aa0
{
Packit 8c9aa0
  if ( hasOnlyOneTest() )
Packit 8c9aa0
    getUniqueChildTest()->run( result );
Packit 8c9aa0
  else
Packit 8c9aa0
    TestSuite::run( result );
Packit 8c9aa0
}
Packit 8c9aa0
Packit 8c9aa0
Packit 8c9aa0
bool 
Packit 8c9aa0
TestRunner::WrappingSuite::hasOnlyOneTest() const
Packit 8c9aa0
{
Packit 8c9aa0
  return TestSuite::getChildTestCount() == 1;
Packit 8c9aa0
}
Packit 8c9aa0
Packit 8c9aa0
Packit 8c9aa0
Test *
Packit 8c9aa0
TestRunner::WrappingSuite::getUniqueChildTest() const
Packit 8c9aa0
{
Packit 8c9aa0
  return TestSuite::doGetChildTestAt( 0 );
Packit 8c9aa0
}
Packit 8c9aa0
Packit 8c9aa0
Packit 8c9aa0
Packit 8c9aa0
Packit 8c9aa0
Packit 8c9aa0
TestRunner::TestRunner()
Packit 8c9aa0
    : m_suite( new WrappingSuite() )
Packit 8c9aa0
{
Packit 8c9aa0
}
Packit 8c9aa0
Packit 8c9aa0
Packit 8c9aa0
TestRunner::~TestRunner()
Packit 8c9aa0
{
Packit 8c9aa0
  delete m_suite;
Packit 8c9aa0
}
Packit 8c9aa0
Packit 8c9aa0
Packit 8c9aa0
void 
Packit 8c9aa0
TestRunner::addTest( Test *test )
Packit 8c9aa0
{
Packit 8c9aa0
  m_suite->addTest( test ); 
Packit 8c9aa0
}
Packit 8c9aa0
Packit 8c9aa0
Packit 8c9aa0
void 
Packit 8c9aa0
TestRunner::run( TestResult &controller,
Packit 8c9aa0
                 const std::string &testPath )
Packit 8c9aa0
{
Packit 8c9aa0
  TestPath path = m_suite->resolveTestPath( testPath );
Packit 8c9aa0
  Test *testToRun = path.getChildTest();
Packit 8c9aa0
Packit 8c9aa0
  controller.runTest( testToRun );
Packit 8c9aa0
}
Packit 8c9aa0
Packit 8c9aa0
Packit 8c9aa0
CPPUNIT_NS_END
Packit 8c9aa0