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
12using namespace llvm;
13using namespace llvm::object;
14
15TEST(Object, SymbolSizeSort) {
16 auto it = symbol_iterator(SymbolRef());
17 std::vector<SymEntry> Syms{
18 SymEntry{.I: it, .Address: 0xffffffff00000000ull, .Number: 1, .SectionID: 0},
19 SymEntry{.I: it, .Address: 0x00ffffff00000000ull, .Number: 2, .SectionID: 0},
20 SymEntry{.I: it, .Address: 0x00ffffff000000ffull, .Number: 3, .SectionID: 0},
21 SymEntry{.I: it, .Address: 0x0000000100000000ull, .Number: 4, .SectionID: 0},
22 SymEntry{.I: it, .Address: 0x00000000000000ffull, .Number: 5, .SectionID: 0},
23 SymEntry{.I: it, .Address: 0x00000001000000ffull, .Number: 6, .SectionID: 0},
24 SymEntry{.I: it, .Address: 0x000000010000ffffull, .Number: 7, .SectionID: 0},
25 };
26
27 array_pod_sort(Start: Syms.begin(), End: Syms.end(), Compare: 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

source code of llvm/unittests/Object/SymbolSizeTest.cpp