diff options
author | Michael J. Spencer <bigcheesegs@gmail.com> | 2011-12-12 06:04:01 +0000 |
---|---|---|
committer | Michael J. Spencer <bigcheesegs@gmail.com> | 2011-12-12 06:04:01 +0000 |
commit | c3b00e80400d27d5d6152374d87c0ad5866c780c (patch) | |
tree | 3adf92cdfd9478aae132d0d0d2ab5f25b57a79ed /unittests | |
parent | 1dd2ee7bf4d848e368829cb01033f297afb674ab (diff) |
Support/FileSystem: Implement canonicalize.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146363 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r-- | unittests/Support/Path.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/unittests/Support/Path.cpp b/unittests/Support/Path.cpp index c791184c83..4982ed0940 100644 --- a/unittests/Support/Path.cpp +++ b/unittests/Support/Path.cpp @@ -304,4 +304,32 @@ TEST_F(FileSystemTest, Magic) { } } +TEST_F(FileSystemTest, Canonicalize) { + SmallString<128> file_pathname(TestDirectory); + path::append(file_pathname, "canonicalize", "a0", "aa1"); + + bool existed; + ASSERT_NO_ERROR(fs::create_directories(Twine(TestDirectory) + + "/canonicalize/a0/aa1", existed)); + + { + path::append(file_pathname, "file.txt"); + std::string ErrMsg; + raw_fd_ostream file(file_pathname.c_str(), ErrMsg); + file << "hello\n"; + } + + SmallString<0> res; + ASSERT_NO_ERROR(fs::canonicalize(Twine(TestDirectory) + + "/cAnOnIcAlIzE/A0/aA1/fIlE.TxT", res)); + // Only check if we actually found the file. As we won't find it on case + // sensitive file systems. + if (fs::exists(res.str())) { + ASSERT_TRUE(res.str().find("canonicalize") != StringRef::npos); + ASSERT_TRUE(res.str().find("a0") != StringRef::npos); + ASSERT_TRUE(res.str().find("aa1") != StringRef::npos); + ASSERT_TRUE(res.str().find("file.txt") != StringRef::npos); + } +} + } // anonymous namespace |