diff options
Diffstat (limited to 'llvm/unittests/Support/Path.cpp')
| -rw-r--r-- | llvm/unittests/Support/Path.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/llvm/unittests/Support/Path.cpp b/llvm/unittests/Support/Path.cpp index a7a6a4a..07ad3fc 100644 --- a/llvm/unittests/Support/Path.cpp +++ b/llvm/unittests/Support/Path.cpp @@ -844,4 +844,24 @@ TEST(Support, RemoveLeadingDotSlash) { Path2 = path::remove_leading_dotslash(Path2); EXPECT_EQ(Path2, ""); } + +static std::string remove_dots(StringRef path, + bool remove_dot_dot) { + SmallString<256> buffer(path); + path::remove_dots(buffer, remove_dot_dot); + return buffer.str(); +} + +TEST(Support, RemoveDots) { + EXPECT_EQ("foolz/wat", remove_dots("././/foolz/wat", false)); + EXPECT_EQ("", remove_dots("./////", false)); + + EXPECT_EQ("a/../b/c", remove_dots("./a/../b/c", false)); + EXPECT_EQ("b/c", remove_dots("./a/../b/c", true)); + EXPECT_EQ("c", remove_dots("././c", true)); + + SmallString<64> Path1("././c"); + EXPECT_TRUE(path::remove_dots(Path1, true)); + EXPECT_EQ("c", Path1); +} } // anonymous namespace |
