diff options
author | Poseydon42 <vvmposeydon@gmail.com> | 2022-12-11 23:33:34 +0000 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-12-14 15:11:03 +0000 |
commit | bdd7531bf552b238a173424df4f44c9fe95c0c7a (patch) | |
tree | b137529f7fb62405f7f8cfe7eee37fb4884b107d /Tests/AK | |
parent | ac40090583cf8d26c0685028e0361d9d669c9836 (diff) | |
download | serenity-bdd7531bf552b238a173424df4f44c9fe95c0c7a.zip |
AK: Create relative path even if prefix is not an ancestor of the path
Diffstat (limited to 'Tests/AK')
-rw-r--r-- | Tests/AK/TestLexicalPath.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Tests/AK/TestLexicalPath.cpp b/Tests/AK/TestLexicalPath.cpp index 29574049b2..23875af3d9 100644 --- a/Tests/AK/TestLexicalPath.cpp +++ b/Tests/AK/TestLexicalPath.cpp @@ -15,10 +15,12 @@ TEST_CASE(relative_path) EXPECT_EQ(LexicalPath::relative_path("/tmp/abc.txt"sv, "/tmp"sv), "abc.txt"sv); EXPECT_EQ(LexicalPath::relative_path("/tmp/abc.txt"sv, "/tmp/"sv), "abc.txt"sv); EXPECT_EQ(LexicalPath::relative_path("/tmp/abc.txt"sv, "/"sv), "tmp/abc.txt"sv); - EXPECT_EQ(LexicalPath::relative_path("/tmp/abc.txt"sv, "/usr"sv), "/tmp/abc.txt"sv); + EXPECT_EQ(LexicalPath::relative_path("/tmp/abc.txt"sv, "/usr"sv), "../tmp/abc.txt"sv); EXPECT_EQ(LexicalPath::relative_path("/tmp/foo.txt"sv, "tmp"sv), ""sv); EXPECT_EQ(LexicalPath::relative_path("tmp/foo.txt"sv, "/tmp"sv), ""sv); + + EXPECT_EQ(LexicalPath::relative_path("/tmp/foo/bar/baz.txt"sv, "/tmp/bar/foo/"sv), "../../foo/bar/baz.txt"sv); } TEST_CASE(regular_absolute_path) |