From cf4ed408c355ffaaca92b574108815072572b872 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Tue, 9 Apr 2019 05:16:29 -0700 Subject: Use (*testing.T).Helper to clean up test failures PiperOrigin-RevId: 242647530 Change-Id: I1bf9ac1d664f452dc47ca670d408a73538cb482f --- pkg/ilist/list_test.go | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'pkg') diff --git a/pkg/ilist/list_test.go b/pkg/ilist/list_test.go index 4bda570b6..f37946dc2 100644 --- a/pkg/ilist/list_test.go +++ b/pkg/ilist/list_test.go @@ -15,7 +15,6 @@ package ilist import ( - "runtime" "testing" ) @@ -30,20 +29,20 @@ type direct struct { } func verifyEquality(t *testing.T, entries []testEntry, l *List) { + t.Helper() + i := 0 for it := l.Front(); it != nil; it = it.Next() { e := it.(*testEntry) if e != &entries[i] { - _, file, line, _ := runtime.Caller(1) - t.Errorf("Wrong entry at index (%s:%d): %v", file, line, i) + t.Errorf("Wrong entry at index %d", i) return } i++ } if i != len(entries) { - _, file, line, _ := runtime.Caller(1) - t.Errorf("Wrong number of entries (%s:%d)", file, line) + t.Errorf("Wrong number of entries; want = %d, got = %d", len(entries), i) return } @@ -51,16 +50,14 @@ func verifyEquality(t *testing.T, entries []testEntry, l *List) { for it := l.Back(); it != nil; it = it.Prev() { e := it.(*testEntry) if e != &entries[len(entries)-1-i] { - _, file, line, _ := runtime.Caller(1) - t.Errorf("Wrong entry at index (%s:%d): %v", file, line, i) + t.Errorf("Wrong entry at index %d", i) return } i++ } if i != len(entries) { - _, file, line, _ := runtime.Caller(1) - t.Errorf("Wrong number of entries (%s:%d)", file, line) + t.Errorf("Wrong number of entries; want = %d, got = %d", len(entries), i) return } } -- cgit v1.2.3