X7ROOT File Manager
Current Path:
/opt/golang/1.22.0/src/cmd/link/internal/ld
opt
/
golang
/
1.22.0
/
src
/
cmd
/
link
/
internal
/
ld
/
📁
..
📄
ar.go
(7.15 KB)
📄
asmb.go
(5.44 KB)
📄
config.go
(5.64 KB)
📄
data.go
(99.49 KB)
📄
data_test.go
(2.27 KB)
📄
deadcode.go
(18.8 KB)
📄
deadcode_test.go
(1.69 KB)
📄
decodesym.go
(10.12 KB)
📄
dwarf.go
(72.42 KB)
📄
dwarf_test.go
(48.49 KB)
📄
elf.go
(63.2 KB)
📄
elf_test.go
(4.18 KB)
📄
errors.go
(1.89 KB)
📄
execarchive.go
(876 B)
📄
execarchive_noexec.go
(320 B)
📄
fallocate_test.go
(1.69 KB)
📄
go.go
(11.17 KB)
📄
go_test.go
(2.67 KB)
📄
heap.go
(1.89 KB)
📄
heap_test.go
(1.87 KB)
📄
inittask.go
(6.18 KB)
📄
issue33808_test.go
(792 B)
📄
ld.go
(7.98 KB)
📄
ld_test.go
(10.34 KB)
📄
lib.go
(86.45 KB)
📄
link.go
(5.13 KB)
📄
macho.go
(43.68 KB)
📄
macho_combine_dwarf.go
(13.1 KB)
📄
main.go
(15.99 KB)
📄
msync_darwin_libc.go
(307 B)
📄
nooptcgolink_test.go
(733 B)
📄
outbuf.go
(8.05 KB)
📄
outbuf_darwin.go
(1.35 KB)
📄
outbuf_freebsd.go
(515 B)
📄
outbuf_linux.go
(304 B)
📄
outbuf_mmap.go
(1.46 KB)
📄
outbuf_nofallocate.go
(301 B)
📄
outbuf_nommap.go
(741 B)
📄
outbuf_notdarwin.go
(236 B)
📄
outbuf_test.go
(2.21 KB)
📄
outbuf_windows.go
(2.31 KB)
📄
pcln.go
(29.75 KB)
📄
pe.go
(48.82 KB)
📄
seh.go
(2.05 KB)
📄
stackcheck.go
(11.88 KB)
📄
stackcheck_test.go
(2.25 KB)
📄
sym.go
(3.91 KB)
📄
symtab.go
(29.17 KB)
📄
target.go
(3.86 KB)
📁
testdata
📄
typelink.go
(1.87 KB)
📄
util.go
(2.5 KB)
📄
xcoff.go
(51.76 KB)
Editing: heap_test.go
// Copyright 2020 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package ld import ( "cmd/link/internal/loader" "testing" ) func TestHeap(t *testing.T) { tests := [][]loader.Sym{ {10, 20, 30, 40, 50, 60, 70, 80, 90, 100}, {100, 90, 80, 70, 60, 50, 40, 30, 20, 10}, {30, 50, 80, 20, 60, 70, 10, 100, 90, 40}, } for _, s := range tests { h := heap{} for _, i := range s { h.push(i) if !verify(&h, 0) { t.Errorf("heap invariant violated: %v", h) } } for j := 0; j < len(s); j++ { x := h.pop() if !verify(&h, 0) { t.Errorf("heap invariant violated: %v", h) } // pop should return elements in ascending order. if want := loader.Sym((j + 1) * 10); x != want { t.Errorf("pop returns wrong element: want %d, got %d", want, x) } } if !h.empty() { t.Errorf("heap is not empty after all pops") } } // Also check that mixed pushes and pops work correctly. for _, s := range tests { h := heap{} for i := 0; i < len(s)/2; i++ { // two pushes, one pop h.push(s[2*i]) if !verify(&h, 0) { t.Errorf("heap invariant violated: %v", h) } h.push(s[2*i+1]) if !verify(&h, 0) { t.Errorf("heap invariant violated: %v", h) } h.pop() if !verify(&h, 0) { t.Errorf("heap invariant violated: %v", h) } } for !h.empty() { // pop remaining elements h.pop() if !verify(&h, 0) { t.Errorf("heap invariant violated: %v", h) } } } } // recursively verify heap-ness, starting at element i. func verify(h *heap, i int) bool { n := len(*h) c1 := 2*i + 1 // left child c2 := 2*i + 2 // right child if c1 < n { if (*h)[c1] < (*h)[i] { return false } if !verify(h, c1) { return false } } if c2 < n { if (*h)[c2] < (*h)[i] { return false } if !verify(h, c2) { return false } } return true }
Upload File
Create Folder