Fix an inconsistency in treatment of trailing / in path::const_iterator

When using a //net/ path, we were transforming the trailing / into a '.'
when the path was just the root path and we were iterating backwards.
Forwards iteration and other kinds of root path (C:\, /) were already
correct.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202999 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Ben Langmuir
2014-03-05 19:56:30 +00:00
parent 4d36f91c08
commit 82d372e12b
2 changed files with 34 additions and 8 deletions

View File

@@ -210,6 +210,35 @@ TEST(Support, AbsolutePathIteratorWin32) {
}
#endif // LLVM_ON_WIN32
TEST(Support, AbsolutePathIteratorEnd) {
// Trailing slashes are converted to '.' unless they are part of the root path.
SmallVector<StringRef, 4> Paths;
Paths.push_back("/foo/");
Paths.push_back("/foo//");
Paths.push_back("//net//");
#ifdef LLVM_ON_WIN32
Paths.push_back("c:\\\\");
#endif
for (StringRef Path : Paths) {
StringRef LastComponent = *--path::end(Path);
EXPECT_EQ(".", LastComponent);
}
SmallVector<StringRef, 3> RootPaths;
RootPaths.push_back("/");
RootPaths.push_back("//net/");
#ifdef LLVM_ON_WIN32
RootPaths.push_back("c:\\");
#endif
for (StringRef Path : RootPaths) {
StringRef LastComponent = *--path::end(Path);
EXPECT_EQ(1u, LastComponent.size());
EXPECT_TRUE(path::is_separator(LastComponent[0]));
}
}
TEST(Support, HomeDirectory) {
#ifdef LLVM_ON_UNIX
// This test only makes sense on Unix if $HOME is set.