libroot/posix/stdio: Remove unused portions.
[haiku.git] / src / tools / cppunit / BTestSuite.cpp
blob00c1e722d3d7fa3f3de7f7f9ac66c1b629df49e0
1 #include <TestSuite.h>
2 #include <cppunit/Test.h>
3 #include <cppunit/TestResult.h>
5 using std::map;
6 using std::string;
8 // Default constructor
9 _EXPORT
10 BTestSuite::BTestSuite( string name )
11 : fName(name)
15 // Destructor
16 _EXPORT
17 BTestSuite::~BTestSuite() {
18 deleteContents();
22 // Deletes all tests in the suite.
23 _EXPORT
24 void
25 BTestSuite::deleteContents() {
26 for ( map<string, CppUnit::Test*>::iterator it = fTests.begin();
27 it != fTests.end();
28 ++it)
29 delete it->second;
30 fTests.clear();
34 /// Runs the tests and collects their result in a TestResult.
35 _EXPORT
36 void
37 BTestSuite::run( CppUnit::TestResult *result ) {
38 for ( map<string, CppUnit::Test*>::iterator it = fTests.begin();
39 it != fTests.end();
40 ++it )
42 if ( result->shouldStop() )
43 break;
45 Test *test = it->second;
46 test->run( result );
51 // Counts the number of test cases that will be run by this test.
52 _EXPORT
53 int
54 BTestSuite::countTestCases() const {
55 int count = 0;
57 for ( map<string, CppUnit::Test *>::const_iterator it = fTests.begin();
58 it != fTests.end();
59 ++it )
60 count += it->second->countTestCases();
62 return count;
66 // Adds a test to the suite.
67 _EXPORT
68 void
69 BTestSuite::addTest(string name, CppUnit::Test *test) {
70 fTests[name] = test;
74 // Returns a string representation of the test suite.
75 _EXPORT
76 string
77 BTestSuite::toString() const {
78 return "suite " + getName();
82 // Returns the name of the test suite.
83 _EXPORT
84 string
85 BTestSuite::getName() const {
86 return fName;
90 _EXPORT
91 const map<string, CppUnit::Test*> &
92 BTestSuite::getTests() const {
93 return fTests;