From b2a0483805c4015db323057bd953c423867d097d Mon Sep 17 00:00:00 2001 From: haorui wang <56127613+HR1025@users.noreply.github.com> Date: Fri, 19 Aug 2022 00:37:35 +0800 Subject: [PATCH] fix(CppUint) : RepeatedTest compile error (#3759) * chore(CppUnit) : style format and revise comment fix(CppUnit) : RepeatedTest compile error * chore(CppUnit) : remove TestResult forward declare in RepeatedTest.h --- CppUnit/include/CppUnit/RepeatedTest.h | 9 ++++----- CppUnit/include/CppUnit/Test.h | 2 +- CppUnit/include/CppUnit/TestCaller.h | 2 +- CppUnit/include/CppUnit/TestDecorator.h | 2 +- CppUnit/src/TestDecorator.cpp | 2 +- CppUnit/src/TestSuite.cpp | 4 ++-- 6 files changed, 10 insertions(+), 11 deletions(-) diff --git a/CppUnit/include/CppUnit/RepeatedTest.h b/CppUnit/include/CppUnit/RepeatedTest.h index 21499f780..9dfdf38b2 100644 --- a/CppUnit/include/CppUnit/RepeatedTest.h +++ b/CppUnit/include/CppUnit/RepeatedTest.h @@ -10,14 +10,13 @@ #include "CppUnit/CppUnit.h" #include "CppUnit/Guards.h" #include "CppUnit/TestDecorator.h" +#include "CppUnit/TestResult.h" namespace CppUnit { class Test; -class TestResult; - /* * A decorator that runs a test repeatedly. @@ -35,7 +34,7 @@ public: int countTestCases(); std::string toString(); - void run(TestResult *result); + void run(TestResult* result, const Test::Callback& callback = nullptr); private: const int _timesRepeat; @@ -43,7 +42,7 @@ private: // Counts the number of test cases that will be run by this test. -inline RepeatedTest::countTestCases () +inline int RepeatedTest::countTestCases() { return TestDecorator::countTestCases() * _timesRepeat; } @@ -57,7 +56,7 @@ inline std::string RepeatedTest::toString() // Runs a repeated test -inline void RepeatedTest::run(TestResult *result) +inline void RepeatedTest::run(TestResult *result, const Test::Callback& callback) { for (int n = 0; n < _timesRepeat; n++) { diff --git a/CppUnit/include/CppUnit/Test.h b/CppUnit/include/CppUnit/Test.h index aeabfe099..bacab5ee5 100644 --- a/CppUnit/include/CppUnit/Test.h +++ b/CppUnit/include/CppUnit/Test.h @@ -56,7 +56,7 @@ inline Test::~Test() // Runs a test and collects its result in a TestResult instance. -inline void Test::run(TestResult *result, const Callback& callback) +inline void Test::run(TestResult* result, const Callback& callback) { } diff --git a/CppUnit/include/CppUnit/TestCaller.h b/CppUnit/include/CppUnit/TestCaller.h index 46f29c15c..6161e299b 100644 --- a/CppUnit/include/CppUnit/TestCaller.h +++ b/CppUnit/include/CppUnit/TestCaller.h @@ -42,7 +42,7 @@ namespace CppUnit { * } * * You can use a TestCaller to bind any test method on a TestCase - * class, as long as it returns accepts void and returns void. + * class, as long as it accepts void and returns void. * * See TestCase */ diff --git a/CppUnit/include/CppUnit/TestDecorator.h b/CppUnit/include/CppUnit/TestDecorator.h index 7ade2d431..cda17c097 100644 --- a/CppUnit/include/CppUnit/TestDecorator.h +++ b/CppUnit/include/CppUnit/TestDecorator.h @@ -35,7 +35,7 @@ public: int countTestCases() const; - void run(TestResult* result, const Test::Callback& callback); + void run(TestResult* result, const Test::Callback& callback = nullptr); std::string toString() const; diff --git a/CppUnit/src/TestDecorator.cpp b/CppUnit/src/TestDecorator.cpp index 10da39bdc..281289d96 100644 --- a/CppUnit/src/TestDecorator.cpp +++ b/CppUnit/src/TestDecorator.cpp @@ -26,7 +26,7 @@ int TestDecorator::countTestCases() const } -void TestDecorator::run(TestResult* result, const Test::Callback& callback = nullptr) +void TestDecorator::run(TestResult* result, const Test::Callback& callback) { _test->run(result); } diff --git a/CppUnit/src/TestSuite.cpp b/CppUnit/src/TestSuite.cpp index 00d336d06..1ba61678e 100644 --- a/CppUnit/src/TestSuite.cpp +++ b/CppUnit/src/TestSuite.cpp @@ -23,7 +23,7 @@ void TestSuite::run(TestResult *result, const Test::Callback& callback) { for (std::vector::iterator it = _tests.begin(); it != _tests.end(); ++it) { - if (result->shouldStop ()) + if (result->shouldStop()) break; Test *test = *it; @@ -39,7 +39,7 @@ int TestSuite::countTestCases() const { int count = 0; - for (std::vector::const_iterator it = _tests.begin (); it != _tests.end (); ++it) + for (std::vector::const_iterator it = _tests.begin(); it != _tests.end(); ++it) count += (*it)->countTestCases(); return count;