Skip to content

Commit f7c9b40

Browse files
committed
Added tests for acquiring constructor with input null pointer
1 parent 2d751cf commit f7c9b40

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/runtime_tests.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,37 @@ TEST_CASE("owner acquiring constructor with deleter", "[owner_construction]") {
237237
REQUIRE(mem_track.double_del() == 0u);
238238
}
239239

240+
TEST_CASE("owner acquiring constructor null", "[owner_construction]") {
241+
memory_tracker mem_track;
242+
243+
{
244+
test_ptr ptr{static_cast<test_object*>(nullptr)};
245+
REQUIRE(instances == 0);
246+
REQUIRE(ptr.get() == nullptr);
247+
}
248+
249+
REQUIRE(instances == 0);
250+
REQUIRE(mem_track.leaks() == 0u);
251+
REQUIRE(mem_track.double_del() == 0u);
252+
}
253+
254+
TEST_CASE("owner acquiring constructor null with deleter", "[owner_construction]") {
255+
memory_tracker mem_track;
256+
257+
{
258+
test_ptr_with_deleter ptr{static_cast<test_object*>(nullptr), test_deleter{42}};
259+
REQUIRE(instances == 0);
260+
REQUIRE(instances_deleter == 1);
261+
REQUIRE(ptr.get() == nullptr);
262+
REQUIRE(ptr.get_deleter().state_ == 42);
263+
}
264+
265+
REQUIRE(instances == 0);
266+
REQUIRE(instances_deleter == 0);
267+
REQUIRE(mem_track.leaks() == 0u);
268+
REQUIRE(mem_track.double_del() == 0u);
269+
}
270+
240271
TEST_CASE("owner implicit conversion constructor", "[owner_construction]") {
241272
memory_tracker mem_track;
242273

0 commit comments

Comments
 (0)