1
0
mirror of https://github.com/golang/go synced 2024-11-18 09:14:43 -07:00

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 <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Mark Ryan 2017-06-15 11:22:48 +01:00 committed by Brad Fitzpatrick
parent 023593d0a8
commit 34ab42111c
3 changed files with 3 additions and 0 deletions

View 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

View 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

View 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