From a9a1a5dfa967356ffe733e36a010f472332b5fe7 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 2 Aug 2019 09:24:15 +0200 Subject: [PATCH] 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. --- AK/Tests/TestHashMap.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/AK/Tests/TestHashMap.cpp b/AK/Tests/TestHashMap.cpp index 1c17eab5ff..9daa7e494c 100644 --- a/AK/Tests/TestHashMap.cpp +++ b/AK/Tests/TestHashMap.cpp @@ -62,4 +62,18 @@ TEST_CASE(case_insensitive) EXPECT_EQ(casemap.size(), 1); } +TEST_CASE(assert_on_iteration_during_clear) +{ + struct Object { + ~Object() + { + m_map->begin(); + } + HashMap* m_map; + }; + HashMap map; + map.set(0, { &map }); + map.clear(); +} + TEST_MAIN(HashMap)