diff --git a/assert/assertions.go b/assert/assertions.go index 1e55fbf54..85b17c65d 100644 --- a/assert/assertions.go +++ b/assert/assertions.go @@ -576,14 +576,6 @@ func EqualExportedValues(t TestingT, expected, actual interface{}, msgAndArgs .. return Fail(t, fmt.Sprintf("Types expected to match exactly\n\t%v != %v", aType, bType), msgAndArgs...) } - if aType.Kind() != reflect.Struct { - return Fail(t, fmt.Sprintf("Types expected to both be struct \n\t%v != %v", aType.Kind(), reflect.Struct), msgAndArgs...) - } - - if bType.Kind() != reflect.Struct { - return Fail(t, fmt.Sprintf("Types expected to both be struct \n\t%v != %v", bType.Kind(), reflect.Struct), msgAndArgs...) - } - expected = copyExportedFields(expected) actual = copyExportedFields(actual) diff --git a/assert/assertions_test.go b/assert/assertions_test.go index 9a44f95eb..fb157078c 100644 --- a/assert/assertions_test.go +++ b/assert/assertions_test.go @@ -190,7 +190,7 @@ type S6 struct { unexported string } -func TestObjectsExportedFieldsAreEqual(t *testing.T) { +func TestEqualExportedValues(t *testing.T) { intValue := 1 @@ -225,6 +225,8 @@ func TestObjectsExportedFieldsAreEqual(t *testing.T) { {Nested{&intValue, 2}, Nested{&intValue, 2}, true}, {Nested{&Nested{1, 2}, 3}, Nested{&Nested{1, "b"}, 3}, true}, {Nested{&Nested{1, 2}, 3}, Nested{nil, 3}, false}, + {&Nested{1, 2}, &Nested{1, "b"}, true}, + {&Nested{1, 2}, &Nested{"a", 2}, false}, { Nested{map[interface{}]*Nested{nil: nil}, 2}, @@ -254,11 +256,12 @@ func TestObjectsExportedFieldsAreEqual(t *testing.T) { } for _, c := range cases { - t.Run(fmt.Sprintf("ObjectsExportedFieldsAreEqual(%#v, %#v)", c.expected, c.actual), func(t *testing.T) { - res := ObjectsExportedFieldsAreEqual(c.expected, c.actual) + t.Run(fmt.Sprintf("EqualExportedValues(%#v, %#v)", c.expected, c.actual), func(t *testing.T) { + mockT := new(testing.T) + res := EqualExportedValues(mockT, c.expected, c.actual) if res != c.result { - t.Errorf("ObjectsExportedFieldsAreEqual(%#v, %#v) should return %#v", c.expected, c.actual, c.result) + t.Errorf("EqualExportedValues(%#v, %#v) should return %#v", c.expected, c.actual, c.result) } }) @@ -348,7 +351,7 @@ func TestCopyExportedFields(t *testing.T) { } } -func TestEqualExportedValues(t *testing.T) { +func TestEqualExportedValuesDiffs(t *testing.T) { cases := []struct { value1 interface{} value2 interface{}