mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 04:58:13 +00:00
AK: Add case insensitive String::ends_with support
FileSystemPath::has_extension was jumping through hoops and allocating memory to do a case insensitive comparison needlessly. Extend the existing String::ends_with method to allow the caller to specify the case sensitivity required.
This commit is contained in:
parent
8e4b858b3f
commit
332f96e7ca
7 changed files with 53 additions and 12 deletions
|
@ -85,4 +85,36 @@ TEST_CASE(relative_paths)
|
|||
}
|
||||
}
|
||||
|
||||
TEST_CASE(has_extension)
|
||||
{
|
||||
{
|
||||
FileSystemPath path("/tmp/simple.png");
|
||||
EXPECT(path.has_extension(".png"));
|
||||
EXPECT(path.has_extension(".pnG"));
|
||||
EXPECT(path.has_extension(".PNG"));
|
||||
}
|
||||
|
||||
{
|
||||
FileSystemPath path("/TMP/SIMPLE.PNG");
|
||||
EXPECT(path.has_extension(".png"));
|
||||
EXPECT(path.has_extension(".pnG"));
|
||||
EXPECT(path.has_extension(".PNG"));
|
||||
}
|
||||
|
||||
{
|
||||
FileSystemPath path(".png");
|
||||
EXPECT(path.has_extension(".png"));
|
||||
}
|
||||
|
||||
{
|
||||
FileSystemPath path;
|
||||
EXPECT_EQ(path.has_extension(".png"), false);
|
||||
}
|
||||
|
||||
{
|
||||
FileSystemPath path("png");
|
||||
EXPECT_EQ(path.has_extension(".png"), false);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_MAIN(FileSystemPath)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue