From: Mark Ryan Date: Thu, 15 Jun 2017 10:22:48 +0000 (+0100) Subject: encoding: report correct line numbers in tests X-Git-Tag: go1.9beta2~76 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=34ab42111cc989a2951134ef12c0e71888d41270;p=gostls13.git encoding: report correct line numbers in tests Some of the _test.go files in the encoding packages contain a private function called testEqual that calls testing.Errorf if the arguments passed to it are unequal. The line numbers output by such calls to Errorf identify the failure as being in testEqual itself which is not very useful. This commit fixes the problem by adding a call to the new t.Helper method in each of the testEqual functions. The line numbers output when errors do occur now identify the real source of the error. Change-Id: I582d1934f40ef2b788116c3811074c67ea882021 Reviewed-on: https://go-review.googlesource.com/45871 Reviewed-by: Brad Fitzpatrick Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- diff --git a/src/encoding/ascii85/ascii85_test.go b/src/encoding/ascii85/ascii85_test.go index aad199b4fa..ba85b64156 100644 --- a/src/encoding/ascii85/ascii85_test.go +++ b/src/encoding/ascii85/ascii85_test.go @@ -44,6 +44,7 @@ var pairs = []testpair{ var bigtest = pairs[len(pairs)-1] func testEqual(t *testing.T, msg string, args ...interface{}) bool { + t.Helper() if args[len(args)-2] != args[len(args)-1] { t.Errorf(msg, args...) return false diff --git a/src/encoding/base32/base32_test.go b/src/encoding/base32/base32_test.go index bd101b5b04..12256d08ee 100644 --- a/src/encoding/base32/base32_test.go +++ b/src/encoding/base32/base32_test.go @@ -44,6 +44,7 @@ var bigtest = testpair{ } func testEqual(t *testing.T, msg string, args ...interface{}) bool { + t.Helper() if args[len(args)-2] != args[len(args)-1] { t.Errorf(msg, args...) return false diff --git a/src/encoding/base64/base64_test.go b/src/encoding/base64/base64_test.go index 8ebf2b1553..59818d3775 100644 --- a/src/encoding/base64/base64_test.go +++ b/src/encoding/base64/base64_test.go @@ -99,6 +99,7 @@ var bigtest = testpair{ } func testEqual(t *testing.T, msg string, args ...interface{}) bool { + t.Helper() if args[len(args)-2] != args[len(args)-1] { t.Errorf(msg, args...) return false