Skip to content

Commit

Permalink
Simplify C++98 compat
Browse files Browse the repository at this point in the history
  • Loading branch information
thetic committed Oct 31, 2022
1 parent 8cc621c commit b29cd69
Show file tree
Hide file tree
Showing 119 changed files with 1,032 additions and 1,039 deletions.
4 changes: 2 additions & 2 deletions examples/AllTests/AllTests.cpp
Expand Up @@ -34,12 +34,12 @@
class MyDummyComparator : public MockNamedValueComparator
{
public:
virtual bool isEqual(const void* object1, const void* object2) _override
virtual bool isEqual(const void* object1, const void* object2) override
{
return object1 == object2;
}

virtual SimpleString valueToString(const void* object) _override
virtual SimpleString valueToString(const void* object) override
{
return StringFrom(object);
}
Expand Down
4 changes: 2 additions & 2 deletions examples/AllTests/CircularBufferTest.cpp
Expand Up @@ -33,11 +33,11 @@ TEST_GROUP(CircularBuffer)
{
CircularBuffer* buffer;

void setup() _override
void setup() override
{
buffer = new CircularBuffer();
}
void teardown() _override
void teardown() override
{
delete buffer;
}
Expand Down
12 changes: 6 additions & 6 deletions examples/AllTests/EventDispatcherTest.cpp
Expand Up @@ -32,15 +32,15 @@
class ObserverMock : public EventObserver
{
public:
virtual void notify(const Event& event, int timeOutInSeconds) _override
virtual void notify(const Event& event, int timeOutInSeconds) override
{
mock()
.actualCall("notify")
.onObject(this)
.withParameterOfType("Event", "event", (void*)&event)
.withParameter("timeOutInSeconds", timeOutInSeconds);
}
virtual void notifyRegistration(EventObserver* newObserver) _override
virtual void notifyRegistration(EventObserver* newObserver) override
{
mock().actualCall("notifyRegistration").onObject(this).withParameter("newObserver", newObserver);
}
Expand All @@ -49,11 +49,11 @@ class ObserverMock : public EventObserver
class EventComparator : public MockNamedValueComparator
{
public:
virtual bool isEqual(const void* object1, const void* object2) _override
virtual bool isEqual(const void* object1, const void* object2) override
{
return ((const Event*)object1)->type == ((const Event*)object2)->type;
}
virtual SimpleString valueToString(const void* object) _override
virtual SimpleString valueToString(const void* object) override
{
return StringFrom(((const Event*)object)->type);
}
Expand All @@ -67,12 +67,12 @@ TEST_GROUP(EventDispatcher)
ObserverMock observer2;
EventComparator eventComparator;

void setup() _override
void setup() override
{
dispatcher = new EventDispatcher;
mock().installComparator("Event", eventComparator);
}
void teardown() _override
void teardown() override
{
delete dispatcher;
mock().removeAllComparatorsAndCopiers();
Expand Down
2 changes: 1 addition & 1 deletion examples/AllTests/FEDemoTest.cpp
Expand Up @@ -46,7 +46,7 @@ extern "C" {

TEST_GROUP(FE_Demo)
{
void setup() _override
void setup() override
{
IEEE754ExceptionsPlugin::disableInexact();
}
Expand Down
4 changes: 2 additions & 2 deletions examples/AllTests/HelloTest.cpp
Expand Up @@ -43,12 +43,12 @@ TEST_GROUP(HelloWorld)
va_end(arguments);
return 1;
}
void setup() _override
void setup() override
{
buffer = new SimpleString();
UT_PTR_SET(PrintFormated, &output_method);
}
void teardown() _override
void teardown() override
{
delete buffer;
}
Expand Down
12 changes: 6 additions & 6 deletions examples/AllTests/MockDocumentationTest.cpp
Expand Up @@ -69,7 +69,7 @@ class ClassFromProductionCode
class ClassFromProductionCodeMock : public ClassFromProductionCode
{
public:
virtual void importantFunction() _override
virtual void importantFunction() override
{
mock().actualCall("importantFunction").onObject(this);
}
Expand Down Expand Up @@ -102,11 +102,11 @@ TEST(MockDocumentation, parameters)
class MyTypeComparator : public MockNamedValueComparator
{
public:
virtual bool isEqual(const void* object1, const void* object2) _override
virtual bool isEqual(const void* object1, const void* object2) override
{
return object1 == object2;
}
virtual SimpleString valueToString(const void* object) _override
virtual SimpleString valueToString(const void* object) override
{
return StringFrom(object);
}
Expand Down Expand Up @@ -199,12 +199,12 @@ TEST(MockDocumentation, CInterface)

TEST_GROUP(FooTestGroup)
{
void setup() _override
void setup() override
{
// Init stuff
}

void teardown() _override
void teardown() override
{
// Uninit stuff
}
Expand All @@ -222,7 +222,7 @@ TEST(FooTestGroup, MoreFoo)

TEST_GROUP(BarTestGroup)
{
void setup() _override
void setup() override
{
// Init Bar
}
Expand Down
4 changes: 2 additions & 2 deletions examples/AllTests/MockPrinter.h
Expand Up @@ -46,12 +46,12 @@ class MockPrinter : public Printer
explicit MockPrinter() {}
virtual ~MockPrinter() {}

virtual void Print(const char* s) _override
virtual void Print(const char* s) override
{
savedOutput.append(s);
}

virtual void Print(long int value) _override
virtual void Print(long int value) override
{
SimpleString buffer;
buffer = StringFromFormat("%ld", value);
Expand Down
4 changes: 2 additions & 2 deletions examples/AllTests/PrinterTest.cpp
Expand Up @@ -34,12 +34,12 @@ TEST_GROUP(Printer)
Printer* printer;
MockPrinter* mockPrinter;

void setup() _override
void setup() override
{
mockPrinter = new MockPrinter();
printer = mockPrinter;
}
void teardown() _override
void teardown() override
{
delete printer;
}
Expand Down
24 changes: 11 additions & 13 deletions include/CppUTest/CppUTestConfig.h
Expand Up @@ -322,20 +322,18 @@ typedef struct cpputest_ulonglong cpputest_ulonglong;

/* Visual C++ 10.0+ (2010+) supports the override keyword, but doesn't define the C++ version as C++11 */
#if defined(__cplusplus) && ((__cplusplus >= 201103L) || (defined(_MSC_VER) && (_MSC_VER >= 1600)))
#if !defined(__ghs__)
#define CPPUTEST_COMPILER_FULLY_SUPPORTS_CXX11
#define _override override
#else
/* GreenHills is not compatible with other compilers with regards to where
* it expects the override specifier to be on methods that return function
* pointers. Given this, it is easiest to not use the override specifier.
*/
#define _override
#endif
#define NULLPTR nullptr
#if defined(__ghs__)
/* GreenHills is not compatible with other compilers with regards to where
* it expects the override specifier to be on methods that return function
* pointers. Given this, it is easiest to not use the override specifier.
*/
#define override
#endif
#else
#define _override
#define NULLPTR NULL
#define override
#ifndef nullptr
#define nullptr NULL
#endif
#endif

/* Visual C++ 11.0+ (2012+) supports the override keyword on destructors */
Expand Down
24 changes: 12 additions & 12 deletions include/CppUTest/JUnitTestOutput.h
Expand Up @@ -40,20 +40,20 @@ class JUnitTestOutput: public TestOutput
JUnitTestOutput();
virtual ~JUnitTestOutput() _destructor_override;

virtual void printTestsStarted() _override;
virtual void printTestsEnded(const TestResult& result) _override;
virtual void printCurrentTestStarted(const UtestShell& test) _override;
virtual void printCurrentTestEnded(const TestResult& res) _override;
virtual void printCurrentGroupStarted(const UtestShell& test) _override;
virtual void printCurrentGroupEnded(const TestResult& res) _override;
virtual void printTestsStarted() override;
virtual void printTestsEnded(const TestResult& result) override;
virtual void printCurrentTestStarted(const UtestShell& test) override;
virtual void printCurrentTestEnded(const TestResult& res) override;
virtual void printCurrentGroupStarted(const UtestShell& test) override;
virtual void printCurrentGroupEnded(const TestResult& res) override;

virtual void printBuffer(const char*) _override;
virtual void print(const char*) _override;
virtual void print(long) _override;
virtual void print(size_t) _override;
virtual void printFailure(const TestFailure& failure) _override;
virtual void printBuffer(const char*) override;
virtual void print(const char*) override;
virtual void print(long) override;
virtual void print(size_t) override;
virtual void printFailure(const TestFailure& failure) override;

virtual void flush() _override;
virtual void flush() override;

virtual SimpleString createFileName(const SimpleString& group);
void setPackageName(const SimpleString &package);
Expand Down
4 changes: 2 additions & 2 deletions include/CppUTest/MemoryLeakDetector.h
Expand Up @@ -117,7 +117,7 @@ class MemoryLeakOutputStringBuffer
struct MemoryLeakDetectorNode
{
MemoryLeakDetectorNode() :
size_(0), number_(0), memory_(NULLPTR), file_(NULLPTR), line_(0), allocator_(NULLPTR), period_(mem_leak_period_enabled), allocation_stage_(0), next_(NULLPTR)
size_(0), number_(0), memory_(nullptr), file_(nullptr), line_(0), allocator_(nullptr), period_(mem_leak_period_enabled), allocation_stage_(0), next_(nullptr)
{
}

Expand All @@ -140,7 +140,7 @@ struct MemoryLeakDetectorNode
struct MemoryLeakDetectorList
{
MemoryLeakDetectorList() :
head_(NULLPTR)
head_(nullptr)
{}

void addNewNode(MemoryLeakDetectorNode* node);
Expand Down
6 changes: 3 additions & 3 deletions include/CppUTest/MemoryLeakWarningPlugin.h
Expand Up @@ -42,11 +42,11 @@ class MemoryLeakFailure;
class MemoryLeakWarningPlugin: public TestPlugin
{
public:
MemoryLeakWarningPlugin(const SimpleString& name, MemoryLeakDetector* localDetector = NULLPTR);
MemoryLeakWarningPlugin(const SimpleString& name, MemoryLeakDetector* localDetector = nullptr);
virtual ~MemoryLeakWarningPlugin() _destructor_override;

virtual void preTestAction(UtestShell& test, TestResult& result) _override;
virtual void postTestAction(UtestShell& test, TestResult& result) _override;
virtual void preTestAction(UtestShell& test, TestResult& result) override;
virtual void postTestAction(UtestShell& test, TestResult& result) override;

virtual const char* FinalReport(size_t toBeDeletedLeaks = 0);

Expand Down
12 changes: 6 additions & 6 deletions include/CppUTest/SimpleStringInternalCache.h
Expand Up @@ -81,14 +81,14 @@ class SimpleStringCacheAllocator : public TestMemoryAllocator
SimpleStringCacheAllocator(SimpleStringInternalCache& cache, TestMemoryAllocator* previousAllocator);
virtual ~SimpleStringCacheAllocator() _destructor_override;

virtual char* alloc_memory(size_t size, const char* file, size_t line) _override;
virtual void free_memory(char* memory, size_t size, const char* file, size_t line) _override;
virtual char* alloc_memory(size_t size, const char* file, size_t line) override;
virtual void free_memory(char* memory, size_t size, const char* file, size_t line) override;

virtual const char* name() const _override;
virtual const char* alloc_name() const _override;
virtual const char* free_name() const _override;
virtual const char* name() const override;
virtual const char* alloc_name() const override;
virtual const char* free_name() const override;

virtual TestMemoryAllocator* actualAllocator() _override;
virtual TestMemoryAllocator* actualAllocator() override;
TestMemoryAllocator* originalAllocator();
private:
SimpleStringInternalCache& cache_;
Expand Down
10 changes: 5 additions & 5 deletions include/CppUTest/TeamCityTestOutput.h
Expand Up @@ -10,12 +10,12 @@ class TeamCityTestOutput: public ConsoleTestOutput
TeamCityTestOutput(void);
virtual ~TeamCityTestOutput(void) _destructor_override;

virtual void printCurrentTestStarted(const UtestShell& test) _override;
virtual void printCurrentTestEnded(const TestResult& res) _override;
virtual void printCurrentGroupStarted(const UtestShell& test) _override;
virtual void printCurrentGroupEnded(const TestResult& res) _override;
virtual void printCurrentTestStarted(const UtestShell& test) override;
virtual void printCurrentTestEnded(const TestResult& res) override;
virtual void printCurrentGroupStarted(const UtestShell& test) override;
virtual void printCurrentGroupEnded(const TestResult& res) override;

virtual void printFailure(const TestFailure& failure) _override;
virtual void printFailure(const TestFailure& failure) override;

protected:

Expand Down

0 comments on commit b29cd69

Please sign in to comment.