Use valueOf to fix issue with []byte

pull/106/head
Raphael Meyer 2014-11-29 18:23:40 +01:00
parent faedd6eb63
commit 794aba658c
1 changed files with 3 additions and 2 deletions

View File

@ -37,10 +37,11 @@ func ObjectsAreEqual(expected, actual interface{}) bool {
}
actualType := reflect.TypeOf(actual)
if reflect.TypeOf(actual).ConvertibleTo(reflect.TypeOf(expected)) {
if actualType.ConvertibleTo(reflect.TypeOf(expected)) {
expectedValue := reflect.ValueOf(expected)
actualValue := reflect.ValueOf(actual)
// Attempt comparison after type conversion
if actual == expectedValue.Convert(actualType).Interface() {
if actualValue == expectedValue.Convert(actualType).Interface() {
return true
}
}