summaryrefslogtreecommitdiff
path: root/AK/Tests
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-10-15 18:29:21 +0200
committerAndreas Kling <kling@serenityos.org>2020-10-15 23:49:53 +0200
commit76aab2fe8d53cec8f0078fd87ecd653b06344840 (patch)
treecb4188f122eaaf13c5bf608201bb8c40514abe9f /AK/Tests
parent20907780bd97e81acd7c3acdf53a1e1527e33256 (diff)
downloadserenity-76aab2fe8d53cec8f0078fd87ecd653b06344840.zip
AK: Improve HashMap tests a little bit
Diffstat (limited to 'AK/Tests')
-rw-r--r--AK/Tests/TestHashMap.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/AK/Tests/TestHashMap.cpp b/AK/Tests/TestHashMap.cpp
index fb8f483a0c..cb4ff4c3b2 100644
--- a/AK/Tests/TestHashMap.cpp
+++ b/AK/Tests/TestHashMap.cpp
@@ -83,8 +83,8 @@ TEST_CASE(case_insensitive)
{
HashMap<String, int, CaseInsensitiveStringTraits> casemap;
EXPECT_EQ(String("nickserv").to_lowercase(), String("NickServ").to_lowercase());
- casemap.set("nickserv", 3);
- casemap.set("NickServ", 3);
+ EXPECT_EQ(casemap.set("nickserv", 3), AK::HashSetResult::InsertedNewEntry);
+ EXPECT_EQ(casemap.set("NickServ", 3), AK::HashSetResult::ReplacedExistingEntry);
EXPECT_EQ(casemap.size(), 1u);
}
@@ -120,4 +120,15 @@ TEST_CASE(hashmap_of_nonnullownptr_get)
EXPECT_EQ(objects.size(), 3u);
}
+TEST_CASE(many_strings)
+{
+ HashMap<String, int> strings;
+ for (int i = 0; i < 999; ++i) {
+ strings.set(String::number(i), i);
+ }
+ for (auto& it : strings) {
+ EXPECT_EQ(it.key.to_int().value(), it.value);
+ }
+}
+
TEST_MAIN(HashMap)