mirror of https://github.com/stretchr/testify.git
Consider empty/nil arrays as matching elements
parent
6f306a68e1
commit
51464dae67
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue