From 88bce07c0592c5edb45ce1414df6aee00f9f3f3f Mon Sep 17 00:00:00 2001 From: Raphael Meyer Date: Sat, 29 Nov 2014 18:51:34 +0100 Subject: [PATCH] Convert actual to expected type. Fix unit tests --- assert/assertions.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/assert/assertions.go b/assert/assertions.go index 9c93e69..95c4420 100644 --- a/assert/assertions.go +++ b/assert/assertions.go @@ -37,11 +37,11 @@ func ObjectsAreEqual(expected, actual interface{}) bool { } actualType := reflect.TypeOf(actual) - if actualType.ConvertibleTo(reflect.TypeOf(expected)) { + expectedType := reflect.TypeOf(expected) + if actualType.ConvertibleTo(expectedType) { expectedValue := reflect.ValueOf(expected) - actualValue := reflect.ValueOf(actual) - // Attempt comparison after type conversion - if actualValue == expectedValue.Convert(actualType).Interface() { + actualValue := reflect.ValueOf(actual).Convert(expectedType) + if actualValue == expectedValue { return true } }