⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 repeatedtest.h

📁 著名的uncle Bob的Agile software development的代码
💻 H
字号:

#ifndef CPPUNIT_REPEATEDTEST_H
#define CPPUNIT_REPEATEDTEST_H

#ifndef CPPUNIT_GUARDS_H
#include "Guards.h"
#endif

#ifndef CPPUNIT_TESTDECORATOR_H
#include "TestDecorator.h"
#endif

class Test;
class TestResult;


/*
 * A decorator that runs a test repeatedly.
 * Does not assume ownership of the test it decorates
 *
 */

class RepeatedTest : public TestDecorator 
{
    REFERENCEOBJECT (RepeatedTest)

public:
                        RepeatedTest (Test *test, int timesRepeat)
                            : TestDecorator (test), m_timesRepeat (timesRepeat) {}

    int                 countTestCases ();
    std::string         toString ();
    void                run (TestResult *result);

private:
    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);
    }
}


#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -