diff --git a/AK/Utf16View.cpp b/AK/Utf16View.cpp index ea2234b9ff9..1503b9e50ae 100644 --- a/AK/Utf16View.cpp +++ b/AK/Utf16View.cpp @@ -344,8 +344,6 @@ size_t Utf16View::calculate_length_in_code_points() const bool Utf16View::equals_ignoring_case(Utf16View const& other) const { - if (length_in_code_units() == 0) - return other.length_in_code_units() == 0; if (length_in_code_units() != other.length_in_code_units()) return false; diff --git a/Tests/AK/TestUtf16.cpp b/Tests/AK/TestUtf16.cpp index 6f2fc98db26..585dff22061 100644 --- a/Tests/AK/TestUtf16.cpp +++ b/Tests/AK/TestUtf16.cpp @@ -307,6 +307,21 @@ TEST_CASE(decode_invalid_utf16) } } +TEST_CASE(equals_ignoring_case) +{ + auto string1 = MUST(AK::utf8_to_utf16("foobar"sv)); + auto string2 = MUST(AK::utf8_to_utf16("FooBar"sv)); + EXPECT(Utf16View { string1 }.equals_ignoring_case(Utf16View { string2 })); + + string1 = MUST(AK::utf8_to_utf16(""sv)); + string2 = MUST(AK::utf8_to_utf16(""sv)); + EXPECT(Utf16View { string1 }.equals_ignoring_case(Utf16View { string2 })); + + string1 = MUST(AK::utf8_to_utf16(""sv)); + string2 = MUST(AK::utf8_to_utf16("FooBar"sv)); + EXPECT(!Utf16View { string1 }.equals_ignoring_case(Utf16View { string2 })); +} + TEST_CASE(substring_view) { auto string = MUST(AK::utf8_to_utf16("Привет 😀"sv));