1
0
mirror of https://github.com/aclindsa/ofxgo.git synced 2024-11-22 03:30:04 -05:00

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.
This commit is contained in:
Aaron Lindsay 2017-10-06 05:53:19 -04:00
parent fa05f64497
commit f408232d77

View File

@ -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</%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</%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)
}