summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Support/Path.cpp
diff options
context:
space:
mode:
authorMike Aizatsky <aizatsky@chromium.org>2015-11-09 18:56:31 +0000
committerMike Aizatsky <aizatsky@chromium.org>2015-11-09 18:56:31 +0000
commit662b4fd325d410181d91031f0155e60c520eebe6 (patch)
tree283c6efc13f982c838ebef8a9941ed79ec6f7c73 /llvm/unittests/Support/Path.cpp
parentcee6a6a63b56c9317dd73edefa93ea35037fa2f6 (diff)
downloadbcm5719-llvm-662b4fd325d410181d91031f0155e60c520eebe6.tar.gz
bcm5719-llvm-662b4fd325d410181d91031f0155e60c520eebe6.zip
Moving FileManager::removeDotPaths to llvm::sys::path::remove_dots
Differential Revision: http://reviews.llvm.org/D14393 llvm-svn: 252499
Diffstat (limited to 'llvm/unittests/Support/Path.cpp')
-rw-r--r--llvm/unittests/Support/Path.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/llvm/unittests/Support/Path.cpp b/llvm/unittests/Support/Path.cpp
index a7a6a4add7c..07ad3fc6b63 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
OpenPOWER on IntegriCloud