[llvm-exegesis] Fix missing std::move.
[llvm-complete.git] / unittests / Bitcode / BitstreamWriterTest.cpp
blob79143c8e7a63d184f640a24b30eff4f52bfd5de4
1 //===- BitstreamWriterTest.cpp - Tests for BitstreamWriter ----------------===//
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 //===----------------------------------------------------------------------===//
10 #include "llvm/Bitcode/BitstreamWriter.h"
11 #include "llvm/ADT/STLExtras.h"
12 #include "llvm/ADT/SmallString.h"
13 #include "gtest/gtest.h"
15 using namespace llvm;
17 namespace {
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);
30 W.emitBlob("str");
32 SmallString<64> Expected;
34 BitstreamWriter W(Expected);
35 W.EmitVBR(3, 6);
36 W.FlushToWord();
37 W.Emit('s', 8);
38 W.Emit('t', 8);
39 W.Emit('r', 8);
40 W.Emit(0, 8);
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);
59 } // end namespace