mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-04 15:45:25 +00:00
AK: Ensure empty StringViews all compare as equal
Before this change, a StringView with a character-data pointer would never compare as equal to one with a null pointer, even if they were both length 0. This could happen for example if one is default-initialized, and the other is created as a substring.
This commit is contained in:
committed by
Andreas Kling
parent
87fc7028d7
commit
ec5101a1d3
@@ -38,6 +38,13 @@ TEST_CASE(compare_views)
|
||||
EXPECT_EQ(view1, foo1);
|
||||
EXPECT_EQ(view1, foo2);
|
||||
EXPECT_EQ(view1, "foo");
|
||||
|
||||
ByteString empty = "";
|
||||
auto empty_view = view1.substring_view(0, 0);
|
||||
StringView default_view = {};
|
||||
EXPECT_EQ(empty.view(), ""sv);
|
||||
EXPECT_EQ(empty_view, ""sv);
|
||||
EXPECT_EQ(default_view, ""sv);
|
||||
}
|
||||
|
||||
TEST_CASE(conforms_to_iterator_protocol)
|
||||
|
||||
Reference in New Issue
Block a user