summaryrefslogtreecommitdiff
path: root/Tests
diff options
context:
space:
mode:
authorBen Wiederhake <BenWiederhake.GitHub@gmx.de>2021-09-11 12:55:07 +0200
committerBrian Gianforcaro <b.gianfo@gmail.com>2021-10-10 15:18:55 -0700
commit50ad2945275def8ff9d6ccc956f365dfeab520b5 (patch)
treed3903d3573b2eacf7d9a6b07691c768930fb9f68 /Tests
parent24e7196158e4673c90aca5c6bff89319d3427282 (diff)
downloadserenity-50ad2945275def8ff9d6ccc956f365dfeab520b5.zip
AK: Implement a way to resolve relative paths lexically
Diffstat (limited to 'Tests')
-rw-r--r--Tests/AK/TestLexicalPath.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/Tests/AK/TestLexicalPath.cpp b/Tests/AK/TestLexicalPath.cpp
index be6f9f43e6..f4959f73f3 100644
--- a/Tests/AK/TestLexicalPath.cpp
+++ b/Tests/AK/TestLexicalPath.cpp
@@ -128,6 +128,19 @@ TEST_CASE(trailing_slash)
EXPECT_EQ(path.parts_view().size(), 2u);
}
+TEST_CASE(resolve_absolute_path)
+{
+ EXPECT_EQ(LexicalPath::absolute_path("/home/anon", "foo.txt"), "/home/anon/foo.txt");
+ EXPECT_EQ(LexicalPath::absolute_path("/home/anon/", "foo.txt"), "/home/anon/foo.txt");
+ EXPECT_EQ(LexicalPath::absolute_path("/home/anon", "././foo.txt"), "/home/anon/foo.txt");
+ EXPECT_EQ(LexicalPath::absolute_path("/home/anon/quux", "../foo.txt"), "/home/anon/foo.txt");
+ EXPECT_EQ(LexicalPath::absolute_path("/home/anon/quux", "../test/foo.txt"), "/home/anon/test/foo.txt");
+ EXPECT_EQ(LexicalPath::absolute_path("quux", "../test/foo.txt"), "test/foo.txt");
+ EXPECT_EQ(LexicalPath::absolute_path("quux", "../../test/foo.txt"), "../test/foo.txt");
+ EXPECT_EQ(LexicalPath::absolute_path("quux/bar", "../../test/foo.txt"), "test/foo.txt");
+ EXPECT_EQ(LexicalPath::absolute_path("quux/bar/", "../../test/foo.txt"), "test/foo.txt");
+}
+
TEST_CASE(has_extension)
{
{