[llvm] r186676 - Add a unit test for checking that we respect the F_Binary flag.

Rafael Espindola rafael.espindola at gmail.com
Fri Jul 19 07:41:25 PDT 2013


Author: rafael
Date: Fri Jul 19 09:41:25 2013
New Revision: 186676

URL: http://llvm.org/viewvc/llvm-project?rev=186676&view=rev
Log:
Add a unit test for checking that we respect the F_Binary flag.

Modified:
    llvm/trunk/unittests/Support/Path.cpp

Modified: llvm/trunk/unittests/Support/Path.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/Path.cpp?rev=186676&r1=186675&r2=186676&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/Path.cpp (original)
+++ llvm/trunk/unittests/Support/Path.cpp Fri Jul 19 09:41:25 2013
@@ -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;





More information about the llvm-commits mailing list