X7ROOT File Manager
Current Path:
/opt/golang/1.19.4/src/cmd/link/internal/ld
opt
/
golang
/
1.19.4
/
src
/
cmd
/
link
/
internal
/
ld
/
📁
..
📄
ar.go
(5.38 KB)
📄
asmb.go
(5.21 KB)
📄
config.go
(7.54 KB)
📄
data.go
(89.78 KB)
📄
data_test.go
(2.32 KB)
📄
deadcode.go
(15.66 KB)
📄
deadcode_test.go
(1.34 KB)
📄
decodesym.go
(9.98 KB)
📄
dwarf.go
(72.83 KB)
📄
dwarf_test.go
(46.02 KB)
📄
elf.go
(59.18 KB)
📄
elf_test.go
(2.75 KB)
📄
errors.go
(1.91 KB)
📄
execarchive.go
(901 B)
📄
execarchive_noexec.go
(343 B)
📄
fallocate_test.go
(1.64 KB)
📄
go.go
(11.84 KB)
📄
go_test.go
(2.68 KB)
📄
heap.go
(960 B)
📄
heap_test.go
(1.87 KB)
📄
issue33808_test.go
(792 B)
📄
ld.go
(8.08 KB)
📄
ld_test.go
(8.16 KB)
📄
lib.go
(76.84 KB)
📄
link.go
(5.13 KB)
📄
macho.go
(43.02 KB)
📄
macho_combine_dwarf.go
(13.11 KB)
📄
main.go
(14.01 KB)
📄
nooptcgolink_test.go
(738 B)
📄
outbuf.go
(8.05 KB)
📄
outbuf_darwin.go
(1.48 KB)
📄
outbuf_linux.go
(304 B)
📄
outbuf_mmap.go
(1.51 KB)
📄
outbuf_nofallocate.go
(342 B)
📄
outbuf_nommap.go
(805 B)
📄
outbuf_notdarwin.go
(292 B)
📄
outbuf_test.go
(2.21 KB)
📄
outbuf_windows.go
(2.28 KB)
📄
pcln.go
(28.96 KB)
📄
pe.go
(45.98 KB)
📄
stackcheck.go
(11.86 KB)
📄
stackcheck_test.go
(2.26 KB)
📄
sym.go
(3.89 KB)
📄
symtab.go
(29.49 KB)
📄
target.go
(3.77 KB)
📁
testdata
📄
typelink.go
(1.87 KB)
📄
util.go
(2.46 KB)
📄
xcoff.go
(51.88 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