annotate unittests/Object/SymbolicFileTest.cpp @ 148:63bd29f05246

merged
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Wed, 14 Aug 2019 19:46:37 +0900
parents c2174574ed3a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
121
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
1 //===- SymbolicFileTest.cpp - Tests for SymbolicFile.cpp ------------------===//
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
2 //
147
c2174574ed3a LLVM 10
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 121
diff changeset
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
c2174574ed3a LLVM 10
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 121
diff changeset
4 // See https://llvm.org/LICENSE.txt for license information.
c2174574ed3a LLVM 10
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 121
diff changeset
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
121
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
6 //
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
7 //===----------------------------------------------------------------------===//
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
8
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
9 #include "llvm/Object/SymbolicFile.h"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
10 #include "llvm/Support/Host.h"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
11 #include "llvm/Support/raw_ostream.h"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
12 #include "gtest/gtest.h"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
13 #include <sstream>
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
14
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
15 TEST(Object, DataRefImplOstream) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
16 std::string s;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
17 llvm::raw_string_ostream OS(s);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
18 llvm::object::DataRefImpl Data;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
19 Data.d.a = 0xeeee0000;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
20 Data.d.b = 0x0000ffff;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
21
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
22 static_assert(sizeof Data.p == sizeof(uint64_t) ||
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
23 sizeof Data.p == sizeof(uint32_t),
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
24 "Test expected pointer type to be 32 or 64-bit.");
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
25
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
26 char const *Expected;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
27
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
28 if (sizeof Data.p == sizeof(uint64_t)) {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
29 Expected = llvm::sys::IsLittleEndianHost
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
30 ? "(0xffffeeee0000 (0xeeee0000, 0x0000ffff))"
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
31 : "(0xeeee00000000ffff (0xeeee0000, 0x0000ffff))";
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
32 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
33 else {
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
34 Expected = "(0xeeee0000 (0xeeee0000, 0x0000ffff))";
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
35 }
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
36
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
37 OS << Data;
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
38 OS.flush();
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
39
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
40 EXPECT_EQ(Expected, s);
803732b1fca8 LLVM 5.0
kono
parents:
diff changeset
41 }