Skip to content

Commit 726c5a7

Browse files
committed
Fix missing coverage of deleting control block in enable_observer_from_this
1 parent a543571 commit 726c5a7

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

tests/runtime_tests.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3157,16 +3157,20 @@ TEST_CASE("observer from this after release", "[observer_from_this]") {
31573157
test_object_observer_from_this* ptr2 = ptr1.release();
31583158
const test_object_observer_from_this* cptr2 = ptr2;
31593159

3160-
test_optr_from_this optr_from_this = ptr2->observer_from_this();
3161-
test_optr_from_this_const optr_from_this_const = cptr2->observer_from_this();
3160+
{
3161+
test_optr_from_this optr_from_this = ptr2->observer_from_this();
3162+
test_optr_from_this_const optr_from_this_const = cptr2->observer_from_this();
31623163

3163-
REQUIRE(instances == 1);
3164-
REQUIRE(optr_from_this.expired() == true);
3165-
REQUIRE(optr_from_this_const.expired() == true);
3166-
REQUIRE(optr_from_this.get() == nullptr);
3167-
REQUIRE(optr_from_this_const.get() == nullptr);
3164+
REQUIRE(instances == 1);
3165+
REQUIRE(optr_from_this.expired() == true);
3166+
REQUIRE(optr_from_this_const.expired() == true);
3167+
REQUIRE(optr_from_this.get() == nullptr);
3168+
REQUIRE(optr_from_this_const.get() == nullptr);
3169+
}
31683170

3171+
// The object holds the last reference to the control block
31693172
delete ptr2;
3173+
REQUIRE(instances == 0);
31703174
}
31713175

31723176
REQUIRE(instances == 0);

0 commit comments

Comments
 (0)