1 //===- raw_pwrite_stream_test.cpp - raw_pwrite_stream tests ---------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #include "gtest/gtest.h"
11 #include "llvm/ADT/SmallString.h"
12 #include "llvm/Support/raw_ostream.h"
13 
14 using namespace llvm;
15 
16 namespace {
17 
18 TEST(raw_pwrite_ostreamTest, TestSVector) {
19   SmallVector<char, 0> Buffer;
20   raw_svector_ostream OS(Buffer);
21   OS << "abcd";
22   StringRef Test = "test";
23   OS.pwrite(Test.data(), Test.size(), 0);
24   EXPECT_EQ(Test, OS.str());
25 
26 #ifdef GTEST_HAS_DEATH_TEST
27 #ifndef NDEBUG
28   EXPECT_DEATH(OS.pwrite("12345", 5, 0),
29                "We don't support extending the stream");
30 #endif
31 #endif
32 }
33 }
34