• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===- SymbolSizeTest.cpp - Tests for SymbolSize.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/SymbolSize.h"
10 #include "gtest/gtest.h"
11 
12 using namespace llvm;
13 using namespace llvm::object;
14 
TEST(Object,SymbolSizeSort)15 TEST(Object, SymbolSizeSort) {
16   auto it = symbol_iterator(SymbolRef());
17   std::vector<SymEntry> Syms{
18       SymEntry{it, 0xffffffff00000000ull, 1, 0},
19       SymEntry{it, 0x00ffffff00000000ull, 2, 0},
20       SymEntry{it, 0x00ffffff000000ffull, 3, 0},
21       SymEntry{it, 0x0000000100000000ull, 4, 0},
22       SymEntry{it, 0x00000000000000ffull, 5, 0},
23       SymEntry{it, 0x00000001000000ffull, 6, 0},
24       SymEntry{it, 0x000000010000ffffull, 7, 0},
25   };
26 
27   array_pod_sort(Syms.begin(), Syms.end(), compareAddress);
28 
29   for (unsigned I = 0, N = Syms.size(); I < N - 1; ++I) {
30     EXPECT_LE(Syms[I].Address, Syms[I + 1].Address);
31   }
32 }
33