diff --git a/assert/assertions.go b/assert/assertions.go index 3a80032..3f1f6f7 100644 --- a/assert/assertions.go +++ b/assert/assertions.go @@ -736,10 +736,7 @@ func NotSubset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) // // Returns whether the assertion was successful (true) or not (false). func ElementsMatch(t TestingT, listA, listB interface{}, msgAndArgs ...interface{}) (ok bool) { - if listA == nil || listB == nil { - if listA != listB { - return Fail(t, fmt.Sprintf("only one value is nil"), msgAndArgs...) - } + if isEmpty(listA) && isEmpty(listB) { return true } diff --git a/assert/assertions_test.go b/assert/assertions_test.go index ca56a57..8c64edf 100644 --- a/assert/assertions_test.go +++ b/assert/assertions_test.go @@ -648,10 +648,10 @@ func TestElementsMatch(t *testing.T) { if !ElementsMatch(mockT, [3]string{"hello", "hello", "world"}, [3]string{"hello", "world", "hello"}) { t.Error("ElementsMatch should return true") } - - if ElementsMatch(mockT, []int{}, nil) { - t.Error("ElementsMatch should return false") + if !ElementsMatch(mockT, []int{}, nil) { + t.Error("ElementsMatch should return true") } + if ElementsMatch(mockT, []int{1}, []int{1, 1}) { t.Error("ElementsMatch should return false") }