mirror of https://github.com/stretchr/testify.git
Allow assert.Equal on string type alias without panicking on failure
parent
14d66a7ab5
commit
f2347ac6c9
|
@ -1345,7 +1345,7 @@ func diff(expected interface{}, actual interface{}) string {
|
|||
}
|
||||
|
||||
var e, a string
|
||||
if ek != reflect.String {
|
||||
if et != reflect.TypeOf("") {
|
||||
e = spewConfig.Sdump(expected)
|
||||
a = spewConfig.Sdump(actual)
|
||||
} else {
|
||||
|
|
|
@ -175,6 +175,8 @@ func TestIsType(t *testing.T) {
|
|||
|
||||
}
|
||||
|
||||
type myType string
|
||||
|
||||
func TestEqual(t *testing.T) {
|
||||
|
||||
mockT := new(testing.T)
|
||||
|
@ -200,6 +202,9 @@ func TestEqual(t *testing.T) {
|
|||
if !Equal(mockT, uint64(123), uint64(123)) {
|
||||
t.Error("Equal should return true")
|
||||
}
|
||||
if !Equal(mockT, myType("1"), myType("1")) {
|
||||
t.Error("Equal should return true")
|
||||
}
|
||||
if !Equal(mockT, &struct{}{}, &struct{}{}) {
|
||||
t.Error("Equal should return true (pointer equality is based on equality of underlying value)")
|
||||
}
|
||||
|
@ -207,6 +212,9 @@ func TestEqual(t *testing.T) {
|
|||
if Equal(mockT, m["bar"], "something") {
|
||||
t.Error("Equal should return false")
|
||||
}
|
||||
if Equal(mockT, myType("1"), myType("2")) {
|
||||
t.Error("Equal should return false")
|
||||
}
|
||||
}
|
||||
|
||||
// bufferT implements TestingT. Its implementation of Errorf writes the output that would be produced by
|
||||
|
|
Loading…
Reference in New Issue