/* * Copyright (c) 2022, the SerenityOS developers. * * SPDX-License-Identifier: BSD-2-Clause */ #include #include static u64 deleter_call_count = 0; TEST_CASE(should_call_custom_deleter) { auto deleter = [](auto* p) { if (p) ++deleter_call_count; }; auto ptr = OwnPtr {}; ptr.clear(); EXPECT_EQ(0u, deleter_call_count); ptr = adopt_own_if_nonnull(&deleter_call_count); EXPECT_EQ(0u, deleter_call_count); ptr.clear(); EXPECT_EQ(1u, deleter_call_count); }