diff options
author | Bastiaan Bakker <bastiaan.bakker@lifeline.nl> | 2001-04-22 22:09:57 +0000 |
---|---|---|
committer | Bastiaan Bakker <bastiaan.bakker@lifeline.nl> | 2001-04-22 22:09:57 +0000 |
commit | c910c4cc5cde77b7ef034c50058d8d5f11bd4b71 (patch) | |
tree | b6150386cb0a000c96ac573ac161e262231ba42e /include/cppunit/extensions/RepeatedTest.h | |
parent | 788f81ef8dac04bb5fd0b88cc6d0ef150c4c5a6f (diff) | |
download | cppunit-c910c4cc5cde77b7ef034c50058d8d5f11bd4b71.tar.gz |
Merged extension headers back in from Micheal Feathers version.
Diffstat (limited to 'include/cppunit/extensions/RepeatedTest.h')
-rw-r--r-- | include/cppunit/extensions/RepeatedTest.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/include/cppunit/extensions/RepeatedTest.h b/include/cppunit/extensions/RepeatedTest.h new file mode 100644 index 0000000..a8c3246 --- /dev/null +++ b/include/cppunit/extensions/RepeatedTest.h @@ -0,0 +1,62 @@ + +#ifndef CPPUNIT_REPEATEDTEST_H +#define CPPUNIT_REPEATEDTEST_H + +#ifndef CPPUNIT_TESTDECORATOR_H +#include "TestDecorator.h" +#endif + +namespace CppUnit { + +class Test; +class TestResult; + + +/* + * A decorator that runs a test repeatedly. + * Does not assume ownership of the test it decorates + * + */ + +class RepeatedTest : public TestDecorator +{ +public: + RepeatedTest (Test *test, int timesRepeat) + : TestDecorator (test), m_timesRepeat (timesRepeat) {} + + int countTestCases (); + std::string toString (); + void run (TestResult *result); + +private: + RepeatedTest( const RepeatedTest & ); + void operator( const RepeatedTest & ); + + const int m_timesRepeat; +}; + + +// Counts the number of test cases that will be run by this test. +inline RepeatedTest::countTestCases () +{ return TestDecorator::countTestCases () * m_timesRepeat; } + +// Returns the name of the test instance. +inline std::string RepeatedTest::toString () +{ return TestDecorator::toString () + " (repeated)"; } + +// Runs a repeated test +inline void RepeatedTest::run (TestResult *result) +{ + for (int n = 0; n < m_timesRepeat; n++) { + if (result->shouldStop ()) + break; + + TestDecorator::run (result); + } +} + + + +} // namespace CppUnit + +#endif
\ No newline at end of file |