mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-01-31 18:07:14 +01:00
4a6bfc086c
Switched to POCO library for unified platform/library interface. Deprecated the external module API. It was creating more problems than solving. Removed most built-in libraries in favor of system libraries for easier maintenance. Cleaned and secured code with help from static analyzers.
76 lines
1.2 KiB
C++
76 lines
1.2 KiB
C++
//
|
|
// RepeatedTest.h
|
|
//
|
|
|
|
|
|
#ifndef CppUnit_RepeatedTest_INCLUDED
|
|
#define CppUnit_RepeatedTest_INCLUDED
|
|
|
|
|
|
#include "CppUnit/CppUnit.h"
|
|
#include "CppUnit/Guards.h"
|
|
#include "CppUnit/TestDecorator.h"
|
|
|
|
|
|
namespace CppUnit {
|
|
|
|
|
|
class Test;
|
|
class TestResult;
|
|
|
|
|
|
/*
|
|
* A decorator that runs a test repeatedly.
|
|
* Does not assume ownership of the test it decorates
|
|
*
|
|
*/
|
|
class CppUnit_API RepeatedTest: public TestDecorator
|
|
{
|
|
REFERENCEOBJECT (RepeatedTest)
|
|
|
|
public:
|
|
RepeatedTest(Test* test, int timesRepeat): TestDecorator (test), _timesRepeat (timesRepeat)
|
|
{
|
|
}
|
|
|
|
int countTestCases();
|
|
std::string toString();
|
|
void run(TestResult *result);
|
|
|
|
private:
|
|
const int _timesRepeat;
|
|
};
|
|
|
|
|
|
// Counts the number of test cases that will be run by this test.
|
|
inline RepeatedTest::countTestCases ()
|
|
{
|
|
return TestDecorator::countTestCases() * _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 < _timesRepeat; n++)
|
|
{
|
|
if (result->shouldStop())
|
|
break;
|
|
|
|
TestDecorator::run(result);
|
|
}
|
|
}
|
|
|
|
|
|
} // namespace CppUnit
|
|
|
|
|
|
#endif // CppUnit_RepeatedTest_INCLUDED
|