| 1 |
// Copyright 2009 The Go Authors. All rights reserved. |
| 2 |
// Use of this source code is governed by a BSD-style |
| 3 |
// license that can be found in the LICENSE file. |
| 4 |
|
| 5 |
package elf |
| 6 |
|
| 7 |
import ( |
| 8 |
"fmt" |
| 9 |
"testing" |
| 10 |
) |
| 11 |
|
| 12 |
type nameTest struct { |
| 13 |
val any |
| 14 |
str string |
| 15 |
} |
| 16 |
|
| 17 |
var nameTests = []nameTest{ |
| 18 |
{ELFOSABI_LINUX, "ELFOSABI_LINUX"}, |
| 19 |
{ET_EXEC, "ET_EXEC"}, |
| 20 |
{EM_860, "EM_860"}, |
| 21 |
{SHN_LOPROC, "SHN_LOPROC"}, |
| 22 |
{SHT_PROGBITS, "SHT_PROGBITS"}, |
| 23 |
{SHF_MERGE + SHF_TLS, "SHF_MERGE+SHF_TLS"}, |
| 24 |
{PT_LOAD, "PT_LOAD"}, |
| 25 |
{PF_W + PF_R + 0x50, "PF_W+PF_R+0x50"}, |
| 26 |
{DT_SYMBOLIC, "DT_SYMBOLIC"}, |
| 27 |
{DF_BIND_NOW, "DF_BIND_NOW"}, |
| 28 |
{DF_1_PIE, "DF_1_PIE"}, |
| 29 |
{NT_FPREGSET, "NT_FPREGSET"}, |
| 30 |
{STB_GLOBAL, "STB_GLOBAL"}, |
| 31 |
{STT_COMMON, "STT_COMMON"}, |
| 32 |
{STV_HIDDEN, "STV_HIDDEN"}, |
| 33 |
{R_X86_64_PC32, "R_X86_64_PC32"}, |
| 34 |
{R_ALPHA_OP_PUSH, "R_ALPHA_OP_PUSH"}, |
| 35 |
{R_ARM_THM_ABS5, "R_ARM_THM_ABS5"}, |
| 36 |
{R_386_GOT32, "R_386_GOT32"}, |
| 37 |
{R_PPC_GOT16_HI, "R_PPC_GOT16_HI"}, |
| 38 |
{R_SPARC_GOT22, "R_SPARC_GOT22"}, |
| 39 |
{ET_LOOS + 5, "ET_LOOS+5"}, |
| 40 |
{ProgFlag(0x50), "0x50"}, |
| 41 |
{COMPRESS_ZLIB + 2, "COMPRESS_ZSTD+1"}, |
| 42 |
} |
| 43 |
|
| 44 |
func TestNames(t *testing.T) { |
| 45 |
for i, tt := range nameTests { |
| 46 |
s := fmt.Sprint(tt.val) |
| 47 |
if s != tt.str { |
| 48 |
t.Errorf("#%d: Sprint(%d) = %q, want %q", i, tt.val, s, tt.str) |
| 49 |
} |
| 50 |
} |
| 51 |
} |