Convert actual to expected type. Fix unit tests

pull/106/head
Raphael Meyer 2014-11-29 18:51:34 +01:00
parent 794aba658c
commit 88bce07c05
1 changed files with 4 additions and 4 deletions

View File

@ -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
}
}