]> Cypherpunks repositories - gostls13.git/commitdiff
encoding: report correct line numbers in tests
authorMark Ryan <mark.d.ryan@intel.com>
Thu, 15 Jun 2017 10:22:48 +0000 (11:22 +0100)
committerBrad Fitzpatrick <bradfitz@golang.org>
Thu, 15 Jun 2017 16:11:28 +0000 (16:11 +0000)
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 <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/encoding/ascii85/ascii85_test.go
src/encoding/base32/base32_test.go
src/encoding/base64/base64_test.go

index aad199b4fad56be2fe05d8f089a5e0dfb002ac54..ba85b64156c7ee3a7d5937b0ba48634fe85f9c78 100644 (file)
@@ -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
index bd101b5b04f3d5892ba0dbe3613f1aea44956994..12256d08ee8b56f4f624e0c3122a6e5d915e88a2 100644 (file)
@@ -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
index 8ebf2b155339223e2dd8ef228e6487def4b7ec9a..59818d3775735d1d875f9a698170f2ced2f98fe9 100644 (file)
@@ -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