From 11a34205808098e503f145b2a779078dd509729e Mon Sep 17 00:00:00 2001 From: Andres Noetzli Date: Thu, 23 Aug 2018 16:28:21 -0700 Subject: Add missing overrides in unit tests (#2362) --- test/unit/context/cdlist_black.h | 4 ++-- test/unit/context/cdmap_black.h | 5 +++-- test/unit/context/cdmap_white.h | 14 +++++--------- test/unit/context/cdo_black.h | 14 +++++--------- test/unit/context/context_black.h | 33 ++++++++++++--------------------- test/unit/context/context_mm_black.h | 14 +++++--------- test/unit/context/context_white.h | 16 ++++++---------- 7 files changed, 38 insertions(+), 62 deletions(-) (limited to 'test/unit/context') diff --git a/test/unit/context/cdlist_black.h b/test/unit/context/cdlist_black.h index 7545fa808..8a31f70ca 100644 --- a/test/unit/context/cdlist_black.h +++ b/test/unit/context/cdlist_black.h @@ -40,9 +40,9 @@ class CDListBlack : public CxxTest::TestSuite { Context* d_context; public: - void setUp() { d_context = new Context(); } + void setUp() override { d_context = new Context(); } - void tearDown() { delete d_context; } + void tearDown() override { delete d_context; } // test at different sizes. this triggers grow() behavior differently. // grow() was completely broken in revision 256 diff --git a/test/unit/context/cdmap_black.h b/test/unit/context/cdmap_black.h index 8cc1b73c2..2d2b3f409 100644 --- a/test/unit/context/cdmap_black.h +++ b/test/unit/context/cdmap_black.h @@ -31,14 +31,15 @@ class CDMapBlack : public CxxTest::TestSuite { Context* d_context; public: - void setUp() { + void setUp() override + { d_context = new Context; // Debug.on("context"); // Debug.on("gc"); // Debug.on("pushpop"); } - void tearDown() { delete d_context; } + void tearDown() override { delete d_context; } // Returns the elements in a CDHashMap. static std::map GetElements(const CDHashMap& map) { diff --git a/test/unit/context/cdmap_white.h b/test/unit/context/cdmap_white.h index 232eb55a8..0f111cd61 100644 --- a/test/unit/context/cdmap_white.h +++ b/test/unit/context/cdmap_white.h @@ -27,17 +27,13 @@ class CDMapWhite : public CxxTest::TestSuite { Context* d_context; -public: + public: + void setUp() override { d_context = new Context; } - void setUp() { - d_context = new Context; - } - - void tearDown() { - delete d_context; - } + void tearDown() override { delete d_context; } - void testUnreachableSaveAndRestore() { + void testUnreachableSaveAndRestore() + { CDHashMap map(d_context); TS_ASSERT_THROWS_NOTHING(map.makeCurrent()); diff --git a/test/unit/context/cdo_black.h b/test/unit/context/cdo_black.h index f5666173d..2838ae322 100644 --- a/test/unit/context/cdo_black.h +++ b/test/unit/context/cdo_black.h @@ -33,17 +33,13 @@ private: Context* d_context; -public: + public: + void setUp() override { d_context = new Context; } - void setUp() { - d_context = new Context; - } - - void tearDown() { - delete d_context; - } + void tearDown() override { delete d_context; } - void testIntCDO() { + void testIntCDO() + { // Test that push/pop maintains the original value CDO a1(d_context); a1 = 5; diff --git a/test/unit/context/context_black.h b/test/unit/context/context_black.h index 63b60edc9..b4be4197c 100644 --- a/test/unit/context/context_black.h +++ b/test/unit/context/context_black.h @@ -36,12 +36,10 @@ struct MyContextNotifyObj : public ContextNotifyObj { ContextNotifyObj(context, pre), nCalls(0) { } - - virtual ~MyContextNotifyObj() {} - void contextNotifyPop() { - ++nCalls; - } + ~MyContextNotifyObj() override {} + + void contextNotifyPop() override { ++nCalls; } }; class MyContextObj : public ContextObj { @@ -75,18 +73,15 @@ public: nSaves(0) { } - virtual ~MyContextObj() { - destroy(); - } + ~MyContextObj() override { destroy(); } - ContextObj* save(ContextMemoryManager* pcmm) { + ContextObj* save(ContextMemoryManager* pcmm) override + { ++nSaves; return new(pcmm) MyContextObj(*this); } - void restore(ContextObj* contextObj) { - nCalls = notify.nCalls; - } + void restore(ContextObj* contextObj) override { nCalls = notify.nCalls; } void makeCurrent() { ContextObj::makeCurrent(); @@ -99,17 +94,13 @@ private: Context* d_context; -public: + public: + void setUp() override { d_context = new Context; } - void setUp() { - d_context = new Context; - } - - void tearDown() { - delete d_context; - } + void tearDown() override { delete d_context; } - void testContextPushPop() { + void testContextPushPop() + { // Test what happens when the context is popped below 0 // the interface doesn't declare any exceptions d_context->push(); diff --git a/test/unit/context/context_mm_black.h b/test/unit/context/context_mm_black.h index ed64b5eac..beace137e 100644 --- a/test/unit/context/context_mm_black.h +++ b/test/unit/context/context_mm_black.h @@ -33,13 +33,11 @@ private: ContextMemoryManager* d_cmm; -public: + public: + void setUp() override { d_cmm = new ContextMemoryManager(); } - void setUp() { - d_cmm = new ContextMemoryManager(); - } - - void testPushPop() { + void testPushPop() + { #ifdef CVC4_DEBUG_CONTEXT_MEMORY_MANAGER #warning "Using the debug context memory manager, omitting unit tests" #else @@ -96,7 +94,5 @@ public: #endif /* __CVC4__CONTEXT__CONTEXT_MM_H */ } - void tearDown() { - delete d_cmm; - } + void tearDown() override { delete d_cmm; } }; diff --git a/test/unit/context/context_white.h b/test/unit/context/context_white.h index 64e6e184b..2c1ef8e71 100644 --- a/test/unit/context/context_white.h +++ b/test/unit/context/context_white.h @@ -29,18 +29,14 @@ private: Context* d_context; -public: + public: + void setUp() override { d_context = new Context; } - void setUp() { - d_context = new Context; - } - - void tearDown() { - delete d_context; - } + void tearDown() override { delete d_context; } - void testContextSimple() { - Scope *s = d_context->getTopScope(); + void testContextSimple() + { + Scope* s = d_context->getTopScope(); TS_ASSERT(s == d_context->getBottomScope()); TS_ASSERT(d_context->getLevel() == 0); -- cgit v1.2.3