From c577d5b5f4f241c89bf3dbeab3f0b79af0d05b99 Mon Sep 17 00:00:00 2001 From: Tyler Dauwalder Date: Mon, 15 Jul 2002 06:50:53 +0000 Subject: [PATCH] Rewritten completely; designed to work with new framework git-svn-id: file:///srv/svn/repos/haiku/trunk/current@233 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/tools/cppunit/TestSuite.cpp | 84 +++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 src/tools/cppunit/TestSuite.cpp diff --git a/src/tools/cppunit/TestSuite.cpp b/src/tools/cppunit/TestSuite.cpp new file mode 100644 index 0000000000..dd9f4278ff --- /dev/null +++ b/src/tools/cppunit/TestSuite.cpp @@ -0,0 +1,84 @@ +#include +#include +#include + +// Default constructor +BTestSuite::BTestSuite( std::string name ) + : fName(name) +{ +} + +// Destructor +BTestSuite::~BTestSuite() { + deleteContents(); +} + + +// Deletes all tests in the suite. +void +BTestSuite::deleteContents() { + for ( std::map::iterator it = fTests.begin(); + it != fTests.end(); + ++it) + delete it->second; + fTests.clear(); +} + + +/// Runs the tests and collects their result in a TestResult. +void +BTestSuite::run( CppUnit::TestResult *result ) { + for ( std::map::iterator it = fTests.begin(); + it != fTests.end(); + ++it ) + { + if ( result->shouldStop() ) + break; + + Test *test = it->second; + test->run( result ); + } +} + + +// Counts the number of test cases that will be run by this test. +int +BTestSuite::countTestCases() const { + int count = 0; + + for ( std::map::const_iterator it = fTests.begin(); + it != fTests.end(); + ++it ) + count += it->second->countTestCases(); + + return count; +} + + +// Adds a test to the suite. +void +BTestSuite::addTest(std::string name, CppUnit::Test *test) { + fTests[name] = test; +} + + +// Returns a string representation of the test suite. +std::string +BTestSuite::toString() const { + return "suite " + getName(); +} + + +// Returns the name of the test suite. +std::string +BTestSuite::getName() const { + return fName; +} + + +const std::map & +BTestSuite::getTests() const { + return fTests; +} + +