test/util/TestIntrusiveTreeSet: add constant_time_size test

This commit is contained in:
Max Kellermann 2024-11-12 08:12:41 +01:00 committed by Max Kellermann
parent 6dce8dcaa5
commit eb1463fd7c
1 changed files with 12 additions and 2 deletions

View File

@ -26,12 +26,16 @@ struct IntItem final : IntrusiveTreeSetHook<IntrusiveHookMode::TRACK> {
} // anonymous namespace
TEST(IntrusiveTreeSet, Basic)
template<bool constant_time_size>
static void
TestBasic()
{
IntItem a{1}, b{2}, c{3}, d{4}, e{5}, f{1};
IntrusiveTreeSet<IntItem,
IntrusiveTreeSetOperators<IntItem, IntItem::GetKey>> set;
IntrusiveTreeSetOperators<IntItem, IntItem::GetKey>,
IntrusiveTreeSetBaseHookTraits<IntItem>,
IntrusiveTreeSetOptions{.constant_time_size=constant_time_size}> set;
EXPECT_EQ(set.size(), 0U);
EXPECT_TRUE(set.empty());
@ -120,6 +124,12 @@ TEST(IntrusiveTreeSet, Basic)
EXPECT_EQ(f.value, 1);
}
TEST(IntrusiveTreeSet, Basic)
{
TestBasic<false>();
TestBasic<true>();
}
template<int... values>
static constexpr auto
MakeIntItems(std::integer_sequence<int, values...>) noexcept