Show types in Eq if types don't match

This commit is contained in:
Nise Void 2019-05-02 13:55:46 +02:00
parent 4d3d17dd62
commit 66ad00ea84
Signed by: NiseVoid
GPG Key ID: FBA14AC83EA602F3

View File

@ -99,6 +99,12 @@ func (a Assert) NoError(actual error, msg ...interface{}) {
// Eq asserts the given values match
func (a Assert) Eq(expected, actual interface{}, msg ...interface{}) {
t(a).Helper()
if reflect.TypeOf(expected) != reflect.TypeOf(actual) {
msg = prepMsg(msg, `Expected %T(%#v), but got %T(%#v)`, expected, expected, actual, actual)
a(false, msg...)
return
}
msg = prepMsg(msg, `Expected %#v, but got %#v`, expected, actual)
a(expected == actual, msg...)
}