mirror of https://github.com/stretchr/testify.git
Add Equal test comparing nil with non-nil
parent
2402e8e7a0
commit
332ae0e18f
|
@ -199,6 +199,10 @@ func TestEqual(t *testing.T) {
|
|||
if !Equal(mockT, &struct{}{}, &struct{}{}) {
|
||||
t.Error("Equal should return true (pointer equality is based on equality of underlying value)")
|
||||
}
|
||||
var m map[string]interface{}
|
||||
if Equal(mockT, m["bar"], "something") {
|
||||
t.Error("Equal should return false")
|
||||
}
|
||||
}
|
||||
|
||||
// bufferT implements TestingT. Its implementation of Errorf writes the output that would be produced by
|
||||
|
@ -250,8 +254,8 @@ func TestEqualFormatting(t *testing.T) {
|
|||
msgAndArgs []interface{}
|
||||
want string
|
||||
}{
|
||||
{equalWant:"want", equalGot: "got", want: "\tassertions.go:[0-9]+: \r \r\tError Trace:\t\n\t\t\r\tError: \tNot equal: \n\t\t\r\t \texpected: \"want\"\n\t\t\r\t \treceived: \"got\"\n"},
|
||||
{equalWant:"want", equalGot: "got", msgAndArgs: []interface{}{"hello, %v!", "world"}, want: "\tassertions.go:[0-9]+: \r \r\tError Trace:\t\n\t\t\r\tError: \tNot equal: \n\t\t\r\t \texpected: \"want\"\n\t\t\r\t \treceived: \"got\"\n\t\t\r\tMessages: \thello, world!\n"},
|
||||
{equalWant: "want", equalGot: "got", want: "\tassertions.go:[0-9]+: \r \r\tError Trace:\t\n\t\t\r\tError: \tNot equal: \n\t\t\r\t \texpected: \"want\"\n\t\t\r\t \treceived: \"got\"\n"},
|
||||
{equalWant: "want", equalGot: "got", msgAndArgs: []interface{}{"hello, %v!", "world"}, want: "\tassertions.go:[0-9]+: \r \r\tError Trace:\t\n\t\t\r\tError: \tNot equal: \n\t\t\r\t \texpected: \"want\"\n\t\t\r\t \treceived: \"got\"\n\t\t\r\tMessages: \thello, world!\n"},
|
||||
} {
|
||||
mockT := &bufferT{}
|
||||
Equal(mockT, currCase.equalWant, currCase.equalGot, currCase.msgAndArgs...)
|
||||
|
|
Loading…
Reference in New Issue