[x86] Enable Broadwell target.
[oota-llvm.git] / unittests / MC / StringTableBuilderTest.cpp
1 //===----------- StringTableBuilderTest.cpp -------------------------------===//
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 "llvm/MC/StringTableBuilder.h"
11 #include "gtest/gtest.h"
12 #include <string>
13
14 using namespace llvm;
15
16 namespace {
17
18 TEST(StringTableBuilderTest, Basic) {
19   StringTableBuilder B;
20
21   B.add("foo");
22   B.add("bar");
23   B.add("foobar");
24
25   B.finalize();
26
27   std::string Expected;
28   Expected += '\x00';
29   Expected += "foobar";
30   Expected += '\x00';
31   Expected += "foo";
32   Expected += '\x00';
33
34   EXPECT_EQ(Expected, B.data());
35   EXPECT_EQ(1U, B.getOffset("foobar"));
36   EXPECT_EQ(4U, B.getOffset("bar"));
37   EXPECT_EQ(8U, B.getOffset("foo"));
38 }
39
40 }