diff options
author | Andreas Kling <kling@serenityos.org> | 2022-03-06 19:37:26 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-03-07 00:08:22 +0100 |
commit | 455224d4766df886a43c19e9c015533c025d40dd (patch) | |
tree | 22777340061b279cc6b6735e0440d51878866816 /Tests/AK/TestHashTable.cpp | |
parent | 9d8da1697e054c7b12210cb14451abc398add7ae (diff) | |
download | serenity-455224d4766df886a43c19e9c015533c025d40dd.zip |
AK: Add test for unbounded HashTable capacity leak
Diffstat (limited to 'Tests/AK/TestHashTable.cpp')
-rw-r--r-- | Tests/AK/TestHashTable.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Tests/AK/TestHashTable.cpp b/Tests/AK/TestHashTable.cpp index 1ec0fe7679..a521763e23 100644 --- a/Tests/AK/TestHashTable.cpp +++ b/Tests/AK/TestHashTable.cpp @@ -224,3 +224,13 @@ TEST_CASE(basic_contains) EXPECT_EQ(table.remove(1), true); EXPECT_EQ(table.contains(1), false); } + +TEST_CASE(capacity_leak) +{ + HashTable<int> table; + for (size_t i = 0; i < 10000; ++i) { + table.set(i); + table.remove(i); + } + EXPECT(table.capacity() < 100u); +} |