From fa97136038a2f848b6d9c1820757a3762882263b Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sat, 14 Mar 2015 18:50:18 -0400 Subject: [PATCH] cmd/internal/obj: add basic test of line history Change-Id: Ic22e004b43bd98e712befb30684be16d8214c94a Reviewed-on: https://go-review.googlesource.com/7622 Reviewed-by: Rob Pike --- src/cmd/internal/obj/line_test.go | 50 +++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/cmd/internal/obj/line_test.go diff --git a/src/cmd/internal/obj/line_test.go b/src/cmd/internal/obj/line_test.go new file mode 100644 index 0000000000..6e6cc33912 --- /dev/null +++ b/src/cmd/internal/obj/line_test.go @@ -0,0 +1,50 @@ +// Copyright 2015 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 obj + +import ( + "fmt" + "testing" +) + +func TestLineHist(t *testing.T) { + ctxt := new(Link) + + Linklinehist(ctxt, 1, "a.c", 0) + Linklinehist(ctxt, 3, "a.h", 0) + Linklinehist(ctxt, 5, "", 0) + Linklinehist(ctxt, 7, "linedir", 2) + Linklinehist(ctxt, 9, "", 0) + Linklinehist(ctxt, 11, "b.c", 0) + Linklinehist(ctxt, 13, "", 0) + + var expect = []string{ + 0: "??:0", + 1: "/a.c:1", + 2: "/a.c:2", + 3: "/a.h:1", + 4: "/a.h:2", + 5: "/a.c:3", + 6: "/a.c:4", + 7: "/linedir:2", + 8: "/linedir:3", + 9: "??:0", + 10: "??:0", + 11: "/b.c:1", + 12: "/b.c:2", + 13: "??:0", + 14: "??:0", + } + + for i, want := range expect { + var f *LSym + var l int32 + linkgetline(ctxt, int32(i), &f, &l) + have := fmt.Sprintf("%s:%d", f.Name, l) + if have != want { + t.Errorf("linkgetline(%d) = %q, want %q", i, have, want) + } + } +} -- 2.48.1