mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
24 lines
554 B
C++
24 lines
554 B
C++
|
/*
|
||
|
* Copyright (c) 2022, the SerenityOS developers.
|
||
|
*
|
||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||
|
*/
|
||
|
|
||
|
#include <LibTest/TestCase.h>
|
||
|
|
||
|
#include <AK/OwnPtr.h>
|
||
|
|
||
|
static u64 deleter_call_count = 0;
|
||
|
|
||
|
TEST_CASE(should_call_custom_deleter)
|
||
|
{
|
||
|
auto deleter = [](auto* p) { if (p) ++deleter_call_count; };
|
||
|
auto ptr = OwnPtr<u64, decltype(deleter)> {};
|
||
|
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);
|
||
|
}
|