mirror of https://github.com/stretchr/testify.git
Make NotSubset actually fail the test on nil subset
The assertion function was simply returning false, which doesn't actually fail a test. An example test that should have failed but doesn't: func TestNotSubset(t *testing.T) { assert.NotSubset(t, []string{"x"}, nil) }pull/532/head
parent
8ccf48a064
commit
9fb9de17de
|
@ -693,7 +693,7 @@ func Subset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) (ok
|
|||
// Returns whether the assertion was successful (true) or not (false).
|
||||
func NotSubset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) (ok bool) {
|
||||
if subset == nil {
|
||||
return false // we consider nil to be equal to the nil set
|
||||
return Fail(t, fmt.Sprintf("nil is the empty set which is a subset of every set"), msgAndArgs...)
|
||||
}
|
||||
|
||||
subsetValue := reflect.ValueOf(subset)
|
||||
|
|
|
@ -553,6 +553,14 @@ func TestNotSubset(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestNotSubsetNil(t *testing.T) {
|
||||
mockT := new(testing.T)
|
||||
NotSubset(mockT, []string{"foo"}, nil)
|
||||
if !mockT.Failed() {
|
||||
t.Error("NotSubset on nil set should have failed the test")
|
||||
}
|
||||
}
|
||||
|
||||
func Test_includeElement(t *testing.T) {
|
||||
|
||||
list1 := []string{"Foo", "Bar"}
|
||||
|
|
Loading…
Reference in New Issue