mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
AK: Add Span::ends_with()
Originally I added this to use it in Utf16View::ends_with(), but the final implementation ended up a lot simpler. I chose to keep this anyway since it mirrors Span::starts_with().
This commit is contained in:
parent
a9862d60bf
commit
54dd45d3f6
Notes:
github-actions[bot]
2025-07-24 11:20:08 +00:00
Author: https://github.com/gmta
Commit: 54dd45d3f6
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5574
Reviewed-by: https://github.com/trflynn89 ✅
2 changed files with 24 additions and 0 deletions
|
|
@ -152,6 +152,22 @@ TEST_CASE(starts_with)
|
|||
EXPECT(bytes.starts_with(hey_bytes_u8));
|
||||
}
|
||||
|
||||
TEST_CASE(ends_with)
|
||||
{
|
||||
char const* str = "HeyFriends!";
|
||||
ReadonlyBytes bytes { str, strlen(str) };
|
||||
char const* str_friends = "Friends!";
|
||||
ReadonlyBytes friends_bytes { str_friends, strlen(str_friends) };
|
||||
EXPECT(bytes.ends_with(friends_bytes));
|
||||
char const* str_nah = "Nah";
|
||||
ReadonlyBytes nah_bytes { str_nah, strlen(str_nah) };
|
||||
EXPECT(!bytes.ends_with(nah_bytes));
|
||||
|
||||
u8 const dse_array[3] = { 'd', 's', '!' };
|
||||
ReadonlyBytes dse_bytes_u8 { dse_array, 3 };
|
||||
EXPECT(bytes.ends_with(dse_bytes_u8));
|
||||
}
|
||||
|
||||
TEST_CASE(contains_slow)
|
||||
{
|
||||
Vector<String> list { "abc"_string, "def"_string, "ghi"_string };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue