diff options
author | Gunnar Beutner <gbeutner@serenityos.org> | 2021-05-18 01:59:13 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-18 08:11:21 +0200 |
commit | c99fd217e230fbeef07e8bbda2c0a21fb3b0169d (patch) | |
tree | 5ea16f71de63872ce0356f2ec40b399cf3ce9a82 /Tests/AK | |
parent | ebb1d9740e063baa5d22bcdca58d08354141aa1c (diff) | |
download | serenity-c99fd217e230fbeef07e8bbda2c0a21fb3b0169d.zip |
AK: Make LexicalPath handle relative paths correctly
Previously LexicalPath would consider "." and ".." as equivalent to
"/". This is not true though.
Diffstat (limited to 'Tests/AK')
-rw-r--r-- | Tests/AK/TestLexicalPath.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Tests/AK/TestLexicalPath.cpp b/Tests/AK/TestLexicalPath.cpp index 044f5f157a..0aa9986c9c 100644 --- a/Tests/AK/TestLexicalPath.cpp +++ b/Tests/AK/TestLexicalPath.cpp @@ -24,12 +24,16 @@ TEST_CASE(basic) EXPECT_EQ(path.parts().size(), 3u); EXPECT_EQ(path.parts(), Vector<String>({ "abc", "def", "ghi.txt" })); EXPECT_EQ(path.string(), "/abc/def/ghi.txt"); + EXPECT_EQ(LexicalPath(".").string(), "."); + EXPECT_EQ(LexicalPath("..").string(), ".."); } TEST_CASE(dotdot_coalescing) { EXPECT_EQ(LexicalPath("/home/user/../../not/home").string(), "/not/home"); EXPECT_EQ(LexicalPath("/../../../../").string(), "/"); + EXPECT_EQ(LexicalPath("./../../../../").string(), "../../../.."); + EXPECT_EQ(LexicalPath("../../../../../").string(), "../../../../.."); } TEST_CASE(has_extension) |