-
Notifications
You must be signed in to change notification settings - Fork 142
Expand file tree
/
Copy pathtest_virtualDestructor.cpp
More file actions
36 lines (30 loc) · 965 Bytes
/
test_virtualDestructor.cpp
File metadata and controls
36 lines (30 loc) · 965 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
* Copyright (c) 2020 Arduino. All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include <catch2/catch_test_macros.hpp>
#include <api/IPAddress.h>
#include <TCPClientMock.h>
/*
* The purpose of these tests is to highlight potential memory leaking
* issues that may arise from the lack of virtual destructors.
* These test cases will never fail under unit testing,
* but they should trigger valgrind error reporting
*/
TEST_CASE("Testing polymorphic IPAddress memory free", "[ipaddress-delete-01]")
{
arduino::Printable* p = new IPAddress();
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdelete-non-virtual-dtor"
delete p;
#pragma GCC diagnostic pop
}
TEST_CASE("Testing polymorphic client memory free", "[client-delete-01]")
{
arduino::Client* p = new TCPClientMock;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdelete-non-virtual-dtor"
delete p;
#pragma GCC diagnostic pop
}