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 //===----------------------------------------------------------------------===// 8 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> 14 TEST(Object,DataRefImplOstream)15TEST(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; 21 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."); 25 26 char const *Expected; 27 28 if (sizeof Data.p == sizeof(uint64_t)) { 29 Expected = llvm::sys::IsLittleEndianHost 30 ? "(0xffffeeee0000 (0xeeee0000, 0x0000ffff))" 31 : "(0xeeee00000000ffff (0xeeee0000, 0x0000ffff))"; 32 } 33 else { 34 Expected = "(0xeeee0000 (0xeeee0000, 0x0000ffff))"; 35 } 36 37 OS << Data; 38 OS.flush(); 39 40 EXPECT_EQ(Expected, s); 41 } 42