summaryrefslogtreecommitdiff
path: root/AK/Tests/TestHashMap.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-07-13 11:00:29 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-07-13 11:00:29 +0200
commitd9d13f2445e33ae09c7423337f095fca205e519a (patch)
treeaf36126c01ceb18283175eb663b8d470b4d9918d /AK/Tests/TestHashMap.cpp
parentb425de18cc564b740ec0bef19b5a4df19bcdceb3 (diff)
downloadserenity-d9d13f2445e33ae09c7423337f095fca205e519a.zip
AK: Support case-insensitive HashMap<String, T>.
We achieve this by allowing you to specify custom traits for the key type. For convenience, we also provide a CaseInsensitiveStringTraits for String.
Diffstat (limited to 'AK/Tests/TestHashMap.cpp')
-rw-r--r--AK/Tests/TestHashMap.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/AK/Tests/TestHashMap.cpp b/AK/Tests/TestHashMap.cpp
index 0820cd9c42..55455b1d16 100644
--- a/AK/Tests/TestHashMap.cpp
+++ b/AK/Tests/TestHashMap.cpp
@@ -32,5 +32,14 @@ int main()
EXPECT(number_to_string.find(3) == number_to_string.end());
EXPECT_EQ(loop_counter, 3);
+
+ {
+ 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.size(), 1);
+ }
+
return 0;
}