...
Run Format

Source file src/debug/elf/elf_test.go

Documentation: debug/elf

     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 interface{}
    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  	{NT_FPREGSET, "NT_FPREGSET"},
    29  	{STB_GLOBAL, "STB_GLOBAL"},
    30  	{STT_COMMON, "STT_COMMON"},
    31  	{STV_HIDDEN, "STV_HIDDEN"},
    32  	{R_X86_64_PC32, "R_X86_64_PC32"},
    33  	{R_ALPHA_OP_PUSH, "R_ALPHA_OP_PUSH"},
    34  	{R_ARM_THM_ABS5, "R_ARM_THM_ABS5"},
    35  	{R_386_GOT32, "R_386_GOT32"},
    36  	{R_PPC_GOT16_HI, "R_PPC_GOT16_HI"},
    37  	{R_SPARC_GOT22, "R_SPARC_GOT22"},
    38  	{ET_LOOS + 5, "ET_LOOS+5"},
    39  	{ProgFlag(0x50), "0x50"},
    40  }
    41  
    42  func TestNames(t *testing.T) {
    43  	for i, tt := range nameTests {
    44  		s := fmt.Sprint(tt.val)
    45  		if s != tt.str {
    46  			t.Errorf("#%d: Sprint(%d) = %q, want %q", i, tt.val, s, tt.str)
    47  		}
    48  	}
    49  }
    50  

View as plain text