mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
AK+Tests: Make CaseInsensitiveStringViewTraits work with HashMap again
This commit is contained in:
parent
822e32eb11
commit
79b9dd6248
Notes:
sideshowbarker
2024-07-17 01:42:39 +09:00
Author: https://github.com/BenWiederhake Commit: https://github.com/SerenityOS/serenity/commit/79b9dd6248 Pull-request: https://github.com/SerenityOS/serenity/pull/16934 Reviewed-by: https://github.com/ADKaster ✅ Reviewed-by: https://github.com/davidot
2 changed files with 9 additions and 0 deletions
|
@ -348,6 +348,7 @@ struct CaseInsensitiveStringViewTraits : public Traits<StringView> {
|
|||
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); }
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -108,6 +108,14 @@ TEST_CASE(case_insensitive)
|
|||
EXPECT_EQ(casemap.size(), 1u);
|
||||
}
|
||||
|
||||
TEST_CASE(case_insensitive_stringview)
|
||||
{
|
||||
HashMap<StringView, int, CaseInsensitiveStringViewTraits> 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 {
|
||||
|
|
Loading…
Reference in a new issue