Skip to content

Commit 80c1235

Browse files
committed
HeapTest: Add definition for virtual destructor
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 <[email protected]>
1 parent 46d2273 commit 80c1235

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

unittest/heap_test.cc

+6
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ int test_data[] = { 8, 1, 2, -4, 7, 9, 65536, 4, 9, 0};
2626
// The fixture for testing GenericHeap and DoublePtr.
2727
class HeapTest : public testing::Test {
2828
public:
29+
virtual ~HeapTest();
2930
// Pushes the test data onto both the heap and the KDVector.
3031
void PushTestData(GenericHeap<IntKDPair>* heap, KDVector* v) {
3132
for (int i = 0; i < ARRAYSIZE(test_data); ++i) {
@@ -66,6 +67,11 @@ class HeapTest : public testing::Test {
6667
}
6768
};
6869

70+
// Destructor.
71+
// It is defined here, so the compiler can create a single vtable
72+
// instead of a weak vtable (fixes compiler warning).
73+
HeapTest::~HeapTest() = default;
74+
6975
// Tests that a sort using a GenericHeap matches the result of a sort using
7076
// a KDVector.
7177
TEST_F(HeapTest, SortTest) {

0 commit comments

Comments
 (0)