David Bozier | 9bb9b31 | 2017-02-15 12:58:41 +0000 | [diff] [blame] | 1 | //===- SymbolicFileTest.cpp - Tests for SymbolicFile.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/Object/SymbolicFile.h" |
David Bozier | 0a86c4c | 2017-02-15 13:40:05 +0000 | [diff] [blame] | 11 | #include "llvm/Support/Host.h" |
David Bozier | 9bb9b31 | 2017-02-15 12:58:41 +0000 | [diff] [blame] | 12 | #include "llvm/Support/raw_ostream.h" |
| 13 | #include "gtest/gtest.h" |
| 14 | #include <sstream> |
| 15 | |
| 16 | TEST(Object, DataRefImplOstream) { |
| 17 | std::string s; |
| 18 | llvm::raw_string_ostream OS(s); |
| 19 | llvm::object::DataRefImpl Data; |
| 20 | Data.d.a = 0xeeee0000; |
| 21 | Data.d.b = 0x0000ffff; |
| 22 | |
| 23 | static_assert(sizeof Data.p == sizeof(uint64_t) || |
| 24 | sizeof Data.p == sizeof(uint32_t), |
| 25 | "Test expected pointer type to be 32 or 64-bit."); |
| 26 | |
David Bozier | 0a86c4c | 2017-02-15 13:40:05 +0000 | [diff] [blame] | 27 | char const *Expected; |
| 28 | |
David Bozier | 6d61f07 | 2017-02-15 16:03:22 +0000 | [diff] [blame] | 29 | if (sizeof Data.p == sizeof(uint64_t)) { |
| 30 | Expected = llvm::sys::IsLittleEndianHost |
David Bozier | 9bb9b31 | 2017-02-15 12:58:41 +0000 | [diff] [blame] | 31 | ? "(0xffffeeee0000 (0xeeee0000, 0x0000ffff))" |
David Bozier | 6d61f07 | 2017-02-15 16:03:22 +0000 | [diff] [blame] | 32 | : "(0xeeee00000000ffff (0xeeee0000, 0x0000ffff))"; |
David Bozier | 0a86c4c | 2017-02-15 13:40:05 +0000 | [diff] [blame] | 33 | } |
| 34 | else { |
David Bozier | 6d61f07 | 2017-02-15 16:03:22 +0000 | [diff] [blame] | 35 | Expected = "(0xeeee0000 (0xeeee0000, 0x0000ffff))"; |
David Bozier | 0a86c4c | 2017-02-15 13:40:05 +0000 | [diff] [blame] | 36 | } |
David Bozier | 9bb9b31 | 2017-02-15 12:58:41 +0000 | [diff] [blame] | 37 | |
| 38 | OS << Data; |
| 39 | OS.flush(); |
| 40 | |
| 41 | EXPECT_EQ(Expected, s); |
| 42 | } |