Enforce type equality in test.AssertEquals (#4111)

Because it's annoying when you get `0 != 0`.
This commit is contained in:
Roland Bracewell Shoemaker 2019-03-14 11:51:57 -07:00 committed by GitHub
parent 204ff0446f
commit e165f86c65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -64,6 +64,9 @@ func AssertError(t *testing.T, err error, message string) {
// AssertEquals uses the equality operator (==) to measure one and two
func AssertEquals(t *testing.T, one interface{}, two interface{}) {
t.Helper()
if reflect.TypeOf(one) != reflect.TypeOf(two) {
t.Fatalf("cannot test equality of different types: %T != %T", one, two)
}
if one != two {
t.Fatalf("%#v != %#v", one, two)
}