mirror of
https://github.com/stretchr/testify.git
synced 2025-05-31 11:42:44 +00:00
Revert "Fixes #13"
This reverts commit 9b28fe8965cd21633adaf91ee714e93532b0ec6e.
This commit is contained in:
parent
9b28fe8965
commit
841b040dd7
@ -173,14 +173,9 @@ func NotNil(t *testing.T, object interface{}, msgAndArgs ...interface{}) bool {
|
|||||||
|
|
||||||
if object == nil {
|
if object == nil {
|
||||||
success = false
|
success = false
|
||||||
}
|
} else if reflect.ValueOf(object).IsNil() {
|
||||||
|
|
||||||
val := reflect.ValueOf(object)
|
|
||||||
if val.CanAddr() {
|
|
||||||
if reflect.ValueOf(object).IsNil() {
|
|
||||||
success = false
|
success = false
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if !success {
|
if !success {
|
||||||
|
|
||||||
@ -206,14 +201,9 @@ func Nil(t *testing.T, object interface{}, msgAndArgs ...interface{}) bool {
|
|||||||
|
|
||||||
if object == nil {
|
if object == nil {
|
||||||
return true
|
return true
|
||||||
}
|
} else if reflect.ValueOf(object).IsNil() {
|
||||||
|
|
||||||
val := reflect.ValueOf(object)
|
|
||||||
if val.CanAddr() {
|
|
||||||
if reflect.ValueOf(object).IsNil() {
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if len(message) > 0 {
|
if len(message) > 0 {
|
||||||
t.Errorf("\r%s\r\tLocation:\t%s\n\r\tError:\t\tExpected nil, but got: %#v\n\r\tMessages:\t%s\n\r", getWhitespaceString(), CallerInfo(), object, message)
|
t.Errorf("\r%s\r\tLocation:\t%s\n\r\tError:\t\tExpected nil, but got: %#v\n\r\tMessages:\t%s\n\r", getWhitespaceString(), CallerInfo(), object, message)
|
||||||
|
@ -5,10 +5,6 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CustomError struct{}
|
|
||||||
|
|
||||||
func (c CustomError) Error() string { return "Error" }
|
|
||||||
|
|
||||||
// AssertionTesterInterface defines an interface to be used for testing assertion methods
|
// AssertionTesterInterface defines an interface to be used for testing assertion methods
|
||||||
type AssertionTesterInterface interface {
|
type AssertionTesterInterface interface {
|
||||||
TestMethod()
|
TestMethod()
|
||||||
@ -119,54 +115,6 @@ func TestNil(t *testing.T) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNil_ValueType(t *testing.T) {
|
|
||||||
|
|
||||||
f := func() AssertionTesterConformingObject {
|
|
||||||
return AssertionTesterConformingObject{}
|
|
||||||
}
|
|
||||||
|
|
||||||
mockT := new(testing.T)
|
|
||||||
obj := f()
|
|
||||||
False(t, Nil(mockT, obj))
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNil_ValueType_IsNil(t *testing.T) {
|
|
||||||
|
|
||||||
f := func() AssertionTesterInterface {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
mockT := new(testing.T)
|
|
||||||
obj := f()
|
|
||||||
True(t, Nil(mockT, obj))
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNil_ValueError(t *testing.T) {
|
|
||||||
|
|
||||||
f := func() error {
|
|
||||||
return CustomError{}
|
|
||||||
}
|
|
||||||
|
|
||||||
mockT := new(testing.T)
|
|
||||||
obj := f()
|
|
||||||
False(t, Nil(mockT, obj))
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNotNil_ValueError(t *testing.T) {
|
|
||||||
|
|
||||||
f := func() error {
|
|
||||||
return CustomError{}
|
|
||||||
}
|
|
||||||
|
|
||||||
mockT := new(testing.T)
|
|
||||||
obj := f()
|
|
||||||
True(t, NotNil(mockT, obj))
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestTrue(t *testing.T) {
|
func TestTrue(t *testing.T) {
|
||||||
|
|
||||||
mockT := new(testing.T)
|
mockT := new(testing.T)
|
||||||
@ -385,15 +333,3 @@ func TestNotEmpty(t *testing.T) {
|
|||||||
True(t, NotEmpty(mockT, true), "True value is not empty")
|
True(t, NotEmpty(mockT, true), "True value is not empty")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEmpty_Value(t *testing.T) {
|
|
||||||
|
|
||||||
f := func() error {
|
|
||||||
return CustomError{}
|
|
||||||
}
|
|
||||||
|
|
||||||
mockT := new(testing.T)
|
|
||||||
obj := f()
|
|
||||||
False(t, Empty(mockT, obj))
|
|
||||||
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user