Commit 34ab4211 authored by Mark Ryan's avatar Mark Ryan Committed by Brad Fitzpatrick

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/45871Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 023593d0
...@@ -44,6 +44,7 @@ var pairs = []testpair{ ...@@ -44,6 +44,7 @@ var pairs = []testpair{
var bigtest = pairs[len(pairs)-1] var bigtest = pairs[len(pairs)-1]
func testEqual(t *testing.T, msg string, args ...interface{}) bool { func testEqual(t *testing.T, msg string, args ...interface{}) bool {
t.Helper()
if args[len(args)-2] != args[len(args)-1] { if args[len(args)-2] != args[len(args)-1] {
t.Errorf(msg, args...) t.Errorf(msg, args...)
return false return false
......
...@@ -44,6 +44,7 @@ var bigtest = testpair{ ...@@ -44,6 +44,7 @@ var bigtest = testpair{
} }
func testEqual(t *testing.T, msg string, args ...interface{}) bool { func testEqual(t *testing.T, msg string, args ...interface{}) bool {
t.Helper()
if args[len(args)-2] != args[len(args)-1] { if args[len(args)-2] != args[len(args)-1] {
t.Errorf(msg, args...) t.Errorf(msg, args...)
return false return false
......
...@@ -99,6 +99,7 @@ var bigtest = testpair{ ...@@ -99,6 +99,7 @@ var bigtest = testpair{
} }
func testEqual(t *testing.T, msg string, args ...interface{}) bool { func testEqual(t *testing.T, msg string, args ...interface{}) bool {
t.Helper()
if args[len(args)-2] != args[len(args)-1] { if args[len(args)-2] != args[len(args)-1] {
t.Errorf(msg, args...) t.Errorf(msg, args...)
return false return false
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment