fix merge conflict

pull/113/head
Tyler Bunnell 2014-12-22 10:15:32 -07:00
commit d1472b75d1
2 changed files with 11 additions and 8 deletions

View File

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

View File

@ -40,6 +40,9 @@ func TestObjectsAreEqual(t *testing.T) {
if !ObjectsAreEqual(nil, nil) {
t.Error("objectsAreEqual should return true")
}
if ObjectsAreEqual(map[int]int{5: 10}, map[int]int{10: 20}) {
t.Error("objectsAreEqual should return false")
}
}
@ -223,10 +226,10 @@ func TestContains(t *testing.T) {
mockT := new(testing.T)
list := []string{"Foo", "Bar"}
complexList := []*A{
&A{"b", "c"},
&A{"d", "e"},
&A{"g", "h"},
&A{"j", "k"},
{"b", "c"},
{"d", "e"},
{"g", "h"},
{"j", "k"},
}
if !Contains(mockT, "Hello World", "Hello") {