TestSuite.cpp
Upload User: dzyhzl
Upload Date: 2019-04-29
Package Size: 56270k
Code Size: 1k
Development Platform:

C/C++

  1. #include "TestSuite.h"
  2. #include "TestResult.h"
  3. // Deletes all tests in the suite.
  4. void TestSuite::deleteContents ()
  5. {
  6.     for (std::vector<Test *>::iterator it = m_tests.begin ();
  7.             it != m_tests.end ();
  8.             ++it)
  9.         delete *it;
  10. }
  11. // Runs the tests and collects their result in a TestResult.
  12. void TestSuite::run (TestResult *result)
  13. {
  14.     for (std::vector<Test *>::iterator it = m_tests.begin ();
  15.             it != m_tests.end ();
  16.             ++it) {
  17.         if (result->shouldStop ())
  18.             break;
  19.         Test *test = *it;
  20.         test->run (result);
  21.     }
  22. }
  23. // Counts the number of test cases that will be run by this test.
  24. int TestSuite::countTestCases ()
  25. {
  26.     int count = 0;
  27.     for (std::vector<Test *>::iterator it = m_tests.begin ();
  28.             it != m_tests.end ();
  29.             ++it)
  30.         count += (*it)->countTestCases ();
  31.     return count;
  32. }