mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:07:35 +00:00
AK: Add a basic unit test for FileSystemPath
Just to make sure that things are on the up-and-up.
This commit is contained in:
parent
1f9b8f0e7c
commit
43ec733b61
2 changed files with 35 additions and 1 deletions
29
AK/Tests/TestFileSystemPath.cpp
Normal file
29
AK/Tests/TestFileSystemPath.cpp
Normal file
|
@ -0,0 +1,29 @@
|
|||
#include <AK/TestSuite.h>
|
||||
|
||||
#include <AK/AKString.h>
|
||||
#include <AK/FileSystemPath.h>
|
||||
|
||||
TEST_CASE(construct)
|
||||
{
|
||||
EXPECT_EQ(FileSystemPath().is_valid(), false);
|
||||
}
|
||||
|
||||
TEST_CASE(basic)
|
||||
{
|
||||
FileSystemPath path("/abc/def/ghi.txt");
|
||||
EXPECT_EQ(path.is_valid(), true);
|
||||
EXPECT_EQ(path.basename(), "ghi.txt");
|
||||
EXPECT_EQ(path.title(), "ghi");
|
||||
EXPECT_EQ(path.extension(), "txt");
|
||||
EXPECT_EQ(path.parts().size(), 3);
|
||||
EXPECT_EQ(path.parts(), Vector<String>({ "abc", "def", "ghi.txt" }));
|
||||
EXPECT_EQ(path.string(), "/abc/def/ghi.txt");
|
||||
}
|
||||
|
||||
TEST_CASE(dotdot_coalescing)
|
||||
{
|
||||
EXPECT_EQ(FileSystemPath("/home/user/../../not/home").string(), "/not/home");
|
||||
EXPECT_EQ(FileSystemPath("/../../../../").string(), "/");
|
||||
}
|
||||
|
||||
TEST_MAIN(FileSystemPath)
|
Loading…
Add table
Add a link
Reference in a new issue