Home | History | Annotate | Download | only in Object
      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"
     11 #include "llvm/Support/Host.h"
     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 
     27   char const *Expected;
     28 
     29   if (sizeof Data.p == sizeof(uint64_t)) {
     30     Expected = llvm::sys::IsLittleEndianHost
     31                              ? "(0xffffeeee0000 (0xeeee0000, 0x0000ffff))"
     32                              : "(0xeeee00000000ffff (0xeeee0000, 0x0000ffff))";
     33   }
     34   else {
     35     Expected = "(0xeeee0000 (0xeeee0000, 0x0000ffff))";
     36   }
     37 
     38   OS << Data;
     39   OS.flush();
     40 
     41   EXPECT_EQ(Expected, s);
     42 }
     43