summaryrefslogtreecommitdiff
path: root/AK/Tests/TestFileSystemPath.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-08-07 21:07:02 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-08-07 21:07:02 +0200
commit43ec733b61a3f38b7f4c8e12786fd3762de72425 (patch)
treed6b7c8844dce4eb721f6dff93fff1e56d2d10b2d /AK/Tests/TestFileSystemPath.cpp
parent1f9b8f0e7c732ec70a77db7eaf22071f43ef46e9 (diff)
downloadserenity-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.cpp29
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)