diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-08-07 21:07:02 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-08-07 21:07:02 +0200 |
commit | 43ec733b61a3f38b7f4c8e12786fd3762de72425 (patch) | |
tree | d6b7c8844dce4eb721f6dff93fff1e56d2d10b2d /AK/Tests/TestFileSystemPath.cpp | |
parent | 1f9b8f0e7c732ec70a77db7eaf22071f43ef46e9 (diff) | |
download | serenity-43ec733b61a3f38b7f4c8e12786fd3762de72425.zip |
AK: Add a basic unit test for FileSystemPath
Just to make sure that things are on the up-and-up.
Diffstat (limited to 'AK/Tests/TestFileSystemPath.cpp')
-rw-r--r-- | AK/Tests/TestFileSystemPath.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/AK/Tests/TestFileSystemPath.cpp b/AK/Tests/TestFileSystemPath.cpp new file mode 100644 index 0000000000..a3d29344ef --- /dev/null +++ b/AK/Tests/TestFileSystemPath.cpp @@ -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) |