mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-17 18:31:04 +00:00
f30ac8f5ec
The current implementations could exhibit some behavior differences: raw_fd_ostream: Whatever the underlying fd does with seek+write. In a normal file, the write position would be back to the old offset. raw_svector_ostream: The write position is always the end of the stream, so after pwrite the write position would be the new end. This matches what OS_X (all BSD?) do with a pwrite in a O_APPEND fd. Given that we don't need that feature and don't use O_APPEND a lot in LLVM, just disallow it. I am open to suggestions on renaming pwrite to something else, but this fixes the issue for now. Thanks to Yaron Keren for reporting it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235303 91177308-0d34-0410-b5e6-96231b3b80d8
34 lines
859 B
C++
34 lines
859 B
C++
//===- raw_pwrite_stream_test.cpp - raw_pwrite_stream tests ---------------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "gtest/gtest.h"
|
|
#include "llvm/ADT/SmallString.h"
|
|
#include "llvm/Support/raw_ostream.h"
|
|
|
|
using namespace llvm;
|
|
|
|
namespace {
|
|
|
|
TEST(raw_pwrite_ostreamTest, TestSVector) {
|
|
SmallVector<char, 0> Buffer;
|
|
raw_svector_ostream OS(Buffer);
|
|
OS << "abcd";
|
|
StringRef Test = "test";
|
|
OS.pwrite(Test.data(), Test.size(), 0);
|
|
EXPECT_EQ(Test, OS.str());
|
|
|
|
#ifdef GTEST_HAS_DEATH_TEST
|
|
#ifndef NDEBUG
|
|
EXPECT_DEATH(OS.pwrite("12345", 5, 0),
|
|
"We don't support extending the stream");
|
|
#endif
|
|
#endif
|
|
}
|
|
}
|