From f408232d776816430081d1addb0ea93ca94a1f33 Mon Sep 17 00:00:00 2001 From: Aaron Lindsay Date: Fri, 6 Oct 2017 05:53:19 -0400 Subject: [PATCH] Mark testing helper functions with t.Helper() This makes error messages from tests report the line number of the error in the test function itself instead of the error in the helper. --- types_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/types_test.go b/types_test.go index 1162687..569f126 100644 --- a/types_test.go +++ b/types_test.go @@ -23,6 +23,7 @@ func getTypeName(i interface{}) string { } func marshalHelper(t *testing.T, expected string, i interface{}) { + t.Helper() typename := getTypeName(i) expectedstring := fmt.Sprintf("<%s>%s", typename, expected, typename) b, err := xml.Marshal(i) @@ -35,6 +36,7 @@ func marshalHelper(t *testing.T, expected string, i interface{}) { } func unmarshalHelper2(t *testing.T, input string, expected interface{}, overwritten interface{}, eq func(a, b interface{}) bool) { + t.Helper() typename := getTypeName(expected) inputstring := fmt.Sprintf("<%s>%s", typename, input, typename) err := xml.Unmarshal([]byte(inputstring), &overwritten) @@ -47,6 +49,7 @@ func unmarshalHelper2(t *testing.T, input string, expected interface{}, overwrit } func unmarshalHelper(t *testing.T, input string, expected interface{}, overwritten interface{}) { + t.Helper() eq := func(a, b interface{}) bool { return reflect.DeepEqual(a, b) }