aboutsummaryrefslogtreecommitdiffstats
path: root/unittests
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-07-19 14:41:25 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-07-19 14:41:25 +0000
commitc9c9825c93791e0b1c0055e1d47ad2e6a703931e (patch)
treecd353148be736cf69d0ae3bc4fbf4708962ccf48 /unittests
parent47042bcc266285676f8ff284e5d46a2c196c367b (diff)
downloadexternal_llvm-c9c9825c93791e0b1c0055e1d47ad2e6a703931e.zip
external_llvm-c9c9825c93791e0b1c0055e1d47ad2e6a703931e.tar.gz
external_llvm-c9c9825c93791e0b1c0055e1d47ad2e6a703931e.tar.bz2
Add a unit test for checking that we respect the F_Binary flag.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186676 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/Support/Path.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/unittests/Support/Path.cpp b/unittests/Support/Path.cpp
index 0bbaa2f..b6c1dd8 100644
--- a/unittests/Support/Path.cpp
+++ b/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;