diff --git a/AK/StringView.h b/AK/StringView.h index 7fd23ef333..a30d517ea0 100644 --- a/AK/StringView.h +++ b/AK/StringView.h @@ -348,6 +348,7 @@ struct CaseInsensitiveStringViewTraits : public Traits { return 0; return case_insensitive_string_hash(s.characters_without_null_termination(), s.length()); } + static bool equals(StringView const& a, StringView const& b) { return a.equals_ignoring_case(b); } }; } diff --git a/Tests/AK/TestHashMap.cpp b/Tests/AK/TestHashMap.cpp index a6b5d2dea2..bbb4876c5d 100644 --- a/Tests/AK/TestHashMap.cpp +++ b/Tests/AK/TestHashMap.cpp @@ -108,6 +108,14 @@ TEST_CASE(case_insensitive) EXPECT_EQ(casemap.size(), 1u); } +TEST_CASE(case_insensitive_stringview) +{ + HashMap casemap; + EXPECT_EQ(casemap.set("nickserv"sv, 3), AK::HashSetResult::InsertedNewEntry); + EXPECT_EQ(casemap.set("NickServ"sv, 3), AK::HashSetResult::ReplacedExistingEntry); + EXPECT_EQ(casemap.size(), 1u); +} + TEST_CASE(hashmap_of_nonnullownptr_get) { struct Object {