mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
AK: Add unit tests for StringUtils::find_last
This method was added without tests. Add some now to ensure future changes do not break it.
This commit is contained in:
parent
9cab4958e6
commit
8064c9fc4d
Notes:
sideshowbarker
2024-07-17 10:54:57 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/8064c9fc4d Pull-request: https://github.com/SerenityOS/serenity/pull/22562 Reviewed-by: https://github.com/nico ✅
1 changed files with 19 additions and 0 deletions
|
@ -407,6 +407,25 @@ TEST_CASE(find)
|
|||
EXPECT_EQ(AK::StringUtils::find(test_string, "78"sv).has_value(), false);
|
||||
}
|
||||
|
||||
TEST_CASE(find_last)
|
||||
{
|
||||
auto test_string = "abcdabc"sv;
|
||||
|
||||
EXPECT_EQ(AK::StringUtils::find_last(test_string, ""sv), 7u);
|
||||
EXPECT_EQ(AK::StringUtils::find_last(test_string, "a"sv), 4u);
|
||||
EXPECT_EQ(AK::StringUtils::find_last(test_string, "b"sv), 5u);
|
||||
EXPECT_EQ(AK::StringUtils::find_last(test_string, "c"sv), 6u);
|
||||
EXPECT_EQ(AK::StringUtils::find_last(test_string, "ab"sv), 4u);
|
||||
EXPECT_EQ(AK::StringUtils::find_last(test_string, "bc"sv), 5u);
|
||||
EXPECT_EQ(AK::StringUtils::find_last(test_string, "abc"sv), 4u);
|
||||
EXPECT_EQ(AK::StringUtils::find_last(test_string, "abcd"sv), 0u);
|
||||
EXPECT_EQ(AK::StringUtils::find_last(test_string, test_string), 0u);
|
||||
|
||||
EXPECT(!AK::StringUtils::find_last(test_string, "1"sv).has_value());
|
||||
EXPECT(!AK::StringUtils::find_last(test_string, "e"sv).has_value());
|
||||
EXPECT(!AK::StringUtils::find_last(test_string, "abd"sv).has_value());
|
||||
}
|
||||
|
||||
TEST_CASE(replace_all_overlapping)
|
||||
{
|
||||
// Replace only should take into account non-overlapping instances of the
|
||||
|
|
Loading…
Reference in a new issue