1 //===- BitstreamWriterTest.cpp - Tests for BitstreamWriter ----------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm/Bitcode/BitstreamWriter.h"
11 #include "llvm/ADT/STLExtras.h"
12 #include "llvm/ADT/SmallString.h"
13 #include "gtest/gtest.h"
19 TEST(BitstreamWriterTest
, emitBlob
) {
20 SmallString
<64> Buffer
;
21 BitstreamWriter
W(Buffer
);
22 W
.emitBlob("str", /* ShouldEmitSize */ false);
23 EXPECT_EQ(StringRef("str\0", 4), Buffer
);
26 TEST(BitstreamWriterTest
, emitBlobWithSize
) {
27 SmallString
<64> Buffer
;
29 BitstreamWriter
W(Buffer
);
32 SmallString
<64> Expected
;
34 BitstreamWriter
W(Expected
);
42 EXPECT_EQ(StringRef(Expected
), Buffer
);
45 TEST(BitstreamWriterTest
, emitBlobEmpty
) {
46 SmallString
<64> Buffer
;
47 BitstreamWriter
W(Buffer
);
48 W
.emitBlob("", /* ShouldEmitSize */ false);
49 EXPECT_EQ(StringRef(""), Buffer
);
52 TEST(BitstreamWriterTest
, emitBlob4ByteAligned
) {
53 SmallString
<64> Buffer
;
54 BitstreamWriter
W(Buffer
);
55 W
.emitBlob("str0", /* ShouldEmitSize */ false);
56 EXPECT_EQ(StringRef("str0"), Buffer
);