mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:57:43 +00:00
AK: Make StringUtils::matches() handle escaping correctly
Previously any backslash and the character following it were ignored. This commit adds a fall through to match the character following the backslash without checking whether it is "special".
This commit is contained in:
parent
0e26f2657e
commit
af2ffcaba8
2 changed files with 20 additions and 2 deletions
|
@ -76,6 +76,21 @@ TEST_CASE(matches_trailing)
|
|||
EXPECT(AK::StringUtils::matches("ab"sv, "*ab****"sv));
|
||||
}
|
||||
|
||||
TEST_CASE(match_backslash_escape)
|
||||
{
|
||||
EXPECT(AK::StringUtils::matches("ab*"sv, "ab\\*"sv));
|
||||
EXPECT(!AK::StringUtils::matches("abc"sv, "ab\\*"sv));
|
||||
EXPECT(!AK::StringUtils::matches("abcd"sv, "ab\\*"sv));
|
||||
EXPECT(AK::StringUtils::matches("ab?"sv, "ab\\?"sv));
|
||||
EXPECT(!AK::StringUtils::matches("abc"sv, "ab\\?"sv));
|
||||
}
|
||||
|
||||
TEST_CASE(match_trailing_backslash)
|
||||
{
|
||||
EXPECT(AK::StringUtils::matches("x\\"sv, "x\\"sv));
|
||||
EXPECT(AK::StringUtils::matches("x\\"sv, "x\\\\"sv));
|
||||
}
|
||||
|
||||
TEST_CASE(convert_to_int)
|
||||
{
|
||||
auto value = AK::StringUtils::convert_to_int(StringView());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue