[llvm/test/Object] - Cleanup and move out the yaml2obj tests.
[llvm-complete.git] / unittests / Object / SymbolicFileTest.cpp
blob3fc5d540e21adab77174683ee7890b2f96cbe3ba
1 //===- SymbolicFileTest.cpp - Tests for SymbolicFile.cpp ------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "llvm/Object/SymbolicFile.h"
10 #include "llvm/Support/Host.h"
11 #include "llvm/Support/raw_ostream.h"
12 #include "gtest/gtest.h"
13 #include <sstream>
15 TEST(Object, DataRefImplOstream) {
16 std::string s;
17 llvm::raw_string_ostream OS(s);
18 llvm::object::DataRefImpl Data;
19 Data.d.a = 0xeeee0000;
20 Data.d.b = 0x0000ffff;
22 static_assert(sizeof Data.p == sizeof(uint64_t) ||
23 sizeof Data.p == sizeof(uint32_t),
24 "Test expected pointer type to be 32 or 64-bit.");
26 char const *Expected;
28 if (sizeof Data.p == sizeof(uint64_t)) {
29 Expected = llvm::sys::IsLittleEndianHost
30 ? "(0xffffeeee0000 (0xeeee0000, 0x0000ffff))"
31 : "(0xeeee00000000ffff (0xeeee0000, 0x0000ffff))";
33 else {
34 Expected = "(0xeeee0000 (0xeeee0000, 0x0000ffff))";
37 OS << Data;
38 OS.flush();
40 EXPECT_EQ(Expected, s);