SymbolicFileTest.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. #include "llvm/Object/SymbolicFile.h"
  9. #include "llvm/Support/Host.h"
  10. #include "llvm/Support/raw_ostream.h"
  11. #include "gtest/gtest.h"
  12. #include <sstream>
  13. TEST(Object, DataRefImplOstream) {
  14. std::string s;
  15. llvm::raw_string_ostream OS(s);
  16. llvm::object::DataRefImpl Data;
  17. Data.d.a = 0xeeee0000;
  18. Data.d.b = 0x0000ffff;
  19. static_assert(sizeof Data.p == sizeof(uint64_t) ||
  20. sizeof Data.p == sizeof(uint32_t),
  21. "Test expected pointer type to be 32 or 64-bit.");
  22. char const *Expected;
  23. if (sizeof Data.p == sizeof(uint64_t)) {
  24. Expected = llvm::sys::IsLittleEndianHost
  25. ? "(0xffffeeee0000 (0xeeee0000, 0x0000ffff))"
  26. : "(0xeeee00000000ffff (0xeeee0000, 0x0000ffff))";
  27. }
  28. else {
  29. Expected = "(0xeeee0000 (0xeeee0000, 0x0000ffff))";
  30. }
  31. OS << Data;
  32. OS.flush();
  33. EXPECT_EQ(Expected, s);
  34. }