Skip to content

Commit 55d73ae

Browse files
committed
Added test for constructing observer_ptr from derived type
1 parent d8675b1 commit 55d73ae

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/runtime_tests.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,18 @@ TEST_CASE("observer acquiring constructor", "[observer_construction]") {
593593
REQUIRE(instances == 0);
594594
}
595595

596+
TEST_CASE("observer acquiring constructor derived", "[observer_construction]") {
597+
{
598+
test_ptr_derived ptr_owner{new test_object_derived};
599+
test_optr ptr{ptr_owner};
600+
REQUIRE(instances == 1);
601+
REQUIRE(ptr.lock() != nullptr);
602+
REQUIRE(ptr.expired() == false);
603+
}
604+
605+
REQUIRE(instances == 0);
606+
}
607+
596608
TEST_CASE("observer implicit copy conversion constructor", "[observer_construction]") {
597609
{
598610
test_ptr_derived ptr_owner{new test_object_derived};

0 commit comments

Comments
 (0)