diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-07-19 14:41:25 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-07-19 14:41:25 +0000 |
commit | 84ab9b3b8fcf4a2ac671050959f43950a108a19b (patch) | |
tree | 1adde3487db66066e417a51983632d609663fe35 /llvm/unittests/Support/Path.cpp | |
parent | b809dfcf3ab6664b755034ec27f3106bec69d6a9 (diff) | |
download | llvm-84ab9b3b8fcf4a2ac671050959f43950a108a19b.zip llvm-84ab9b3b8fcf4a2ac671050959f43950a108a19b.tar.gz llvm-84ab9b3b8fcf4a2ac671050959f43950a108a19b.tar.bz2 |
Add a unit test for checking that we respect the F_Binary flag.
llvm-svn: 186676
Diffstat (limited to 'llvm/unittests/Support/Path.cpp')
-rw-r--r-- | llvm/unittests/Support/Path.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/llvm/unittests/Support/Path.cpp b/llvm/unittests/Support/Path.cpp index 0bbaa2f..b6c1dd8 100644 --- a/llvm/unittests/Support/Path.cpp +++ b/llvm/unittests/Support/Path.cpp @@ -10,6 +10,7 @@ #include "llvm/Support/Path.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FileSystem.h" +#include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/raw_ostream.h" #include "gtest/gtest.h" @@ -356,6 +357,36 @@ TEST_F(FileSystemTest, Magic) { } } +#ifdef LLVM_ON_WIN32 +TEST_F(FileSystemTest, CarriageReturn) { + SmallString<128> FilePathname(TestDirectory); + std::string ErrMsg; + path::append(FilePathname, "test"); + + { + raw_fd_ostream File(FilePathname.c_str(), ErrMsg); + EXPECT_EQ(ErrMsg, ""); + File << '\n'; + } + { + OwningPtr<MemoryBuffer> Buf; + MemoryBuffer::getFile(FilePathname, Buf); + EXPECT_EQ(Buf->getBuffer(), "\r\n"); + } + + { + raw_fd_ostream File(FilePathname.c_str(), ErrMsg, sys::fs::F_Binary); + EXPECT_EQ(ErrMsg, ""); + File << '\n'; + } + { + OwningPtr<MemoryBuffer> Buf; + MemoryBuffer::getFile(FilePathname, Buf); + EXPECT_EQ(Buf->getBuffer(), "\n"); + } +} +#endif + TEST_F(FileSystemTest, FileMapping) { // Create a temp file. int FileDescriptor; |