Skip to content

Commit

Permalink
HeapTest: Add definition for virtual destructor
Browse files Browse the repository at this point in the history
This fixes a compiler warning from clang:

unittest/heap_test.cc:27:7: warning:
 'HeapTest' has no out-of-line virtual method definitions;
 its vtable will be emitted in every translation unit [-Wweak-vtables]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Sep 4, 2018
1 parent 46d2273 commit 80c1235
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions unittest/heap_test.cc
Expand Up @@ -26,6 +26,7 @@ int test_data[] = { 8, 1, 2, -4, 7, 9, 65536, 4, 9, 0};
// The fixture for testing GenericHeap and DoublePtr.
class HeapTest : public testing::Test {
public:
virtual ~HeapTest();
// Pushes the test data onto both the heap and the KDVector.
void PushTestData(GenericHeap<IntKDPair>* heap, KDVector* v) {
for (int i = 0; i < ARRAYSIZE(test_data); ++i) {
Expand Down Expand Up @@ -66,6 +67,11 @@ class HeapTest : public testing::Test {
}
};

// Destructor.
// It is defined here, so the compiler can create a single vtable
// instead of a weak vtable (fixes compiler warning).
HeapTest::~HeapTest() = default;

// Tests that a sort using a GenericHeap matches the result of a sort using
// a KDVector.
TEST_F(HeapTest, SortTest) {
Expand Down

0 comments on commit 80c1235

Please sign in to comment.