mirror of
https://github.com/stretchr/testify.git
synced 2025-05-31 11:42:44 +00:00
Convert actual to expected type. Fix unit tests
This commit is contained in:
parent
794aba658c
commit
88bce07c05
@ -37,11 +37,11 @@ func ObjectsAreEqual(expected, actual interface{}) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
actualType := reflect.TypeOf(actual)
|
actualType := reflect.TypeOf(actual)
|
||||||
if actualType.ConvertibleTo(reflect.TypeOf(expected)) {
|
expectedType := reflect.TypeOf(expected)
|
||||||
|
if actualType.ConvertibleTo(expectedType) {
|
||||||
expectedValue := reflect.ValueOf(expected)
|
expectedValue := reflect.ValueOf(expected)
|
||||||
actualValue := reflect.ValueOf(actual)
|
actualValue := reflect.ValueOf(actual).Convert(expectedType)
|
||||||
// Attempt comparison after type conversion
|
if actualValue == expectedValue {
|
||||||
if actualValue == expectedValue.Convert(actualType).Interface() {
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user