AK: Add a test for iterating a HashTable during clear (should assert)

Ideally we should also verify that the assertion actually happens,
but we need some support in the TestSuite framework for that.
This commit is contained in:
Andreas Kling 2019-08-02 09:24:15 +02:00
commit a9a1a5dfa9
Notes: sideshowbarker 2024-07-19 12:56:51 +09:00

View file

@ -62,4 +62,18 @@ TEST_CASE(case_insensitive)
EXPECT_EQ(casemap.size(), 1); EXPECT_EQ(casemap.size(), 1);
} }
TEST_CASE(assert_on_iteration_during_clear)
{
struct Object {
~Object()
{
m_map->begin();
}
HashMap<int, Object>* m_map;
};
HashMap<int, Object> map;
map.set(0, { &map });
map.clear();
}
TEST_MAIN(HashMap) TEST_MAIN(HashMap)