summaryrefslogtreecommitdiff
path: root/src/cppunit/TestSuite.cpp
diff options
context:
space:
mode:
authorBastiaan Bakker <bastiaan.bakker@lifeline.nl>2001-04-28 17:23:32 +0000
committerBastiaan Bakker <bastiaan.bakker@lifeline.nl>2001-04-28 17:23:32 +0000
commit6d95c46d9dc342bea176c8fbcd101db8eba24bef (patch)
tree3a42ea08625f64972f520cbeda2da3c68bbe9692 /src/cppunit/TestSuite.cpp
parent7e4ccacdbcf2f78005447f16e49d339d2a70e9ca (diff)
downloadcppunit-6d95c46d9dc342bea176c8fbcd101db8eba24bef.tar.gz
Moved files in subdir cppunit to src/cppunit.
Diffstat (limited to 'src/cppunit/TestSuite.cpp')
-rw-r--r--src/cppunit/TestSuite.cpp86
1 files changed, 86 insertions, 0 deletions
diff --git a/src/cppunit/TestSuite.cpp b/src/cppunit/TestSuite.cpp
new file mode 100644
index 0000000..8fe5e65
--- /dev/null
+++ b/src/cppunit/TestSuite.cpp
@@ -0,0 +1,86 @@
+#include "cppunit/TestSuite.h"
+#include "cppunit/TestResult.h"
+
+namespace CppUnit {
+
+/// Deletes all tests in the suite.
+void TestSuite::deleteContents ()
+{
+ 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)
+{
+ 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 count = 0;
+
+ 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)
+{
+ m_tests.push_back (test);
+}
+
+
+/// Returns a string representation of the test suite.
+std::string
+ TestSuite::toString () const
+{
+ return "suite " + getName();
+}
+
+/// Returns the name of the test suite.
+std::string
+ TestSuite::getName () const
+{
+ return m_name;
+}
+
+} // namespace CppUnit
+