OSDN Git Service

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