Go to the source code of this file.
|
| TEST_CASE ("shared_ptr reset with no arguments clears", "[shared_ptr][reset]") |
|
| TEST_CASE ("shared_ptr reset with pointer", "[shared_ptr][reset]") |
|
| TEST_CASE ("shared_ptr reset with pointer and deleter", "[shared_ptr][reset]") |
|
| TEST_CASE ("shared_ptr reset with pointer, deleter and allocator", "[shared_ptr][reset]") |
|
◆ TEST_CASE() [1/4]
TEST_CASE |
( |
"shared_ptr reset with no arguments clears" |
, |
|
|
"" |
[shared_ptr][reset] |
|
) |
| |
Definition at line 28 of file shared_ptr_reset.cpp.
30 A *ptr1 =
new A(deleted);
32 REQUIRE(t_ptr1.get() == ptr1);
33 REQUIRE_FALSE(deleted);
35 REQUIRE(t_ptr1.get() ==
nullptr);
Wrapper aroung std::shared_ptr that throws when a wrapped null pointer is dereferenced.
◆ TEST_CASE() [2/4]
TEST_CASE |
( |
"shared_ptr reset with pointer" |
, |
|
|
"" |
[shared_ptr][reset] |
|
) |
| |
Definition at line 39 of file shared_ptr_reset.cpp.
40 bool deleted1 =
false;
41 A *ptr1 =
new A(deleted1);
42 bool deleted2 =
false;
43 B *ptr2 =
new B(deleted2);
46 REQUIRE(t_ptr1.get() == ptr1);
47 REQUIRE_FALSE(deleted1);
49 REQUIRE(t_ptr1.get() == ptr2);
Wrapper aroung std::shared_ptr that throws when a wrapped null pointer is dereferenced.
◆ TEST_CASE() [3/4]
TEST_CASE |
( |
"shared_ptr reset with pointer and deleter" |
, |
|
|
"" |
[shared_ptr][reset] |
|
) |
| |
Definition at line 53 of file shared_ptr_reset.cpp.
54 bool deleted1 =
false;
55 A *ptr1 =
new A(deleted1);
56 bool deleted2 =
false;
57 B *ptr2 =
new B(deleted2);
59 bool lamda_called =
false;
60 auto deleter = [&lamda_called](A *p) {
66 REQUIRE(t_ptr1.get() == ptr1);
67 REQUIRE_FALSE(deleted1);
69 t_ptr1.reset(ptr2, deleter);
70 REQUIRE_FALSE(lamda_called);
72 REQUIRE(t_ptr1.get() == ptr2);
76 REQUIRE(lamda_called);
77 REQUIRE(t_ptr1.get() ==
nullptr);
Wrapper aroung std::shared_ptr that throws when a wrapped null pointer is dereferenced.
◆ TEST_CASE() [4/4]
TEST_CASE |
( |
"shared_ptr reset with |
pointer, |
|
|
deleter and allocator" |
, |
|
|
"" |
[shared_ptr][reset] |
|
) |
| |
Definition at line 80 of file shared_ptr_reset.cpp.
82 bool deleted1 =
false;
83 A *ptr1 =
new A(deleted1);
84 bool deleted2 =
false;
85 B *ptr2 =
new B(deleted2);
87 bool lamda_called =
false;
88 auto deleter = [&lamda_called](A *p) {
94 REQUIRE(t_ptr1.get() == ptr1);
95 REQUIRE_FALSE(deleted1);
97 std::allocator<void *> allocator;
98 t_ptr1.reset(ptr2, deleter, allocator);
99 REQUIRE_FALSE(lamda_called);
101 REQUIRE(t_ptr1.get() == ptr2);
105 REQUIRE(lamda_called);
106 REQUIRE(t_ptr1.get() ==
nullptr);
Wrapper aroung std::shared_ptr that throws when a wrapped null pointer is dereferenced.