diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-07-13 11:00:29 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-07-13 11:00:29 +0200 |
commit | d9d13f2445e33ae09c7423337f095fca205e519a (patch) | |
tree | af36126c01ceb18283175eb663b8d470b4d9918d /AK/Tests | |
parent | b425de18cc564b740ec0bef19b5a4df19bcdceb3 (diff) | |
download | serenity-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')
-rw-r--r-- | AK/Tests/TestHashMap.cpp | 9 | ||||
-rw-r--r--[-rwxr-xr-x] | AK/Tests/TestString.cpp | 0 |
2 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; } diff --git a/AK/Tests/TestString.cpp b/AK/Tests/TestString.cpp index 808d0904be..808d0904be 100755..100644 --- a/AK/Tests/TestString.cpp +++ b/AK/Tests/TestString.cpp |