mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-06 08:10:02 +00:00
AK: Remove superfluous check from Utf16View::equals_ignoring_case()
Returning true if both lengths are 0 is already handled by the default case.
This commit is contained in:
parent
b558b4dba6
commit
7d7f6fa494
Notes:
github-actions[bot]
2025-06-13 13:10:57 +00:00
Author: https://github.com/gmta
Commit: 7d7f6fa494
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5067
Reviewed-by: https://github.com/tcl3
Reviewed-by: https://github.com/trflynn89
2 changed files with 15 additions and 2 deletions
|
@ -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;
|
||||
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue