diff options
Diffstat (limited to 'src/cppunit/TestSuite.cpp')
| -rw-r--r-- | src/cppunit/TestSuite.cpp | 91 |
1 files changed, 50 insertions, 41 deletions
diff --git a/src/cppunit/TestSuite.cpp b/src/cppunit/TestSuite.cpp index 33ea2ce..7659939 100644 --- a/src/cppunit/TestSuite.cpp +++ b/src/cppunit/TestSuite.cpp @@ -3,85 +3,94 @@ namespace CppUnit { +/// Default constructor +TestSuite::TestSuite( std::string name ) + : m_name( name ) +{ +} + + +/// Destructor +TestSuite::~TestSuite() +{ + deleteContents(); +} + + /// Deletes all tests in the suite. -void TestSuite::deleteContents () +void +TestSuite::deleteContents() { - for (std::vector<Test *>::iterator it = m_tests.begin (); - it != m_tests.end (); - ++it) + for ( std::vector<Test *>::iterator it = m_tests.begin(); + it != m_tests.end(); + ++it) delete *it; m_tests.clear(); } + /// Runs the tests and collects their result in a TestResult. -void TestSuite::run (TestResult *result) +void +TestSuite::run( TestResult *result ) { - for (std::vector<Test *>::iterator it = m_tests.begin (); - it != m_tests.end (); - ++it) { - if (result->shouldStop ()) - break; - - Test *test = *it; - test->run (result); - } - + for ( std::vector<Test *>::iterator it = m_tests.begin(); + it != m_tests.end(); + ++it ) + { + if ( result->shouldStop() ) + break; + + Test *test = *it; + test->run( result ); + } } /// Counts the number of test cases that will be run by this test. -int TestSuite::countTestCases () const +int +TestSuite::countTestCases() const { - int count = 0; + int count = 0; - for (std::vector<Test *>::const_iterator it = m_tests.begin (); - it != m_tests.end (); - ++it) - count += (*it)->countTestCases (); - - return count; + for ( std::vector<Test *>::const_iterator it = m_tests.begin(); + it != m_tests.end(); + ++it ) + count += (*it)->countTestCases(); + return count; } -/// Default constructor -TestSuite::TestSuite (std::string name) - : m_name (name) -{ -} - -/// Destructor -TestSuite::~TestSuite () -{ - deleteContents (); -} /// Adds a test to the suite. void - TestSuite::addTest (Test *test) +TestSuite::addTest( Test *test ) { - m_tests.push_back (test); + m_tests.push_back( test ); } /// Returns a string representation of the test suite. std::string - TestSuite::toString () const +TestSuite::toString() const { - return "suite " + getName(); + return "suite " + getName(); } + /// Returns the name of the test suite. std::string - TestSuite::getName () const +TestSuite::getName() const { return m_name; } -const std::vector<Test *>& - TestSuite::getTests () const + +const std::vector<Test *> & +TestSuite::getTests() const { return m_tests; } + } // namespace CppUnit |
