mirror of
https://github.com/stretchr/testify.git
synced 2025-05-31 11:42:44 +00:00
fix funtion name
This commit is contained in:
parent
5c61ef97ae
commit
edff5a049b
@ -718,7 +718,7 @@ func NotEqualValues(t TestingT, expected, actual interface{}, msgAndArgs ...inte
|
|||||||
// return (false, false) if impossible.
|
// return (false, false) if impossible.
|
||||||
// return (true, false) if element was not found.
|
// return (true, false) if element was not found.
|
||||||
// return (true, true) if element was found.
|
// return (true, true) if element was found.
|
||||||
func includeElement(list interface{}, element interface{}) (ok, found bool) {
|
func containsElement(list interface{}, element interface{}) (ok, found bool) {
|
||||||
|
|
||||||
listValue := reflect.ValueOf(list)
|
listValue := reflect.ValueOf(list)
|
||||||
listType := reflect.TypeOf(list)
|
listType := reflect.TypeOf(list)
|
||||||
@ -768,7 +768,7 @@ func Contains(t TestingT, s, contains interface{}, msgAndArgs ...interface{}) bo
|
|||||||
h.Helper()
|
h.Helper()
|
||||||
}
|
}
|
||||||
|
|
||||||
ok, found := includeElement(s, contains)
|
ok, found := containsElement(s, contains)
|
||||||
if !ok {
|
if !ok {
|
||||||
return Fail(t, fmt.Sprintf("%#v could not be applied builtin len()", s), msgAndArgs...)
|
return Fail(t, fmt.Sprintf("%#v could not be applied builtin len()", s), msgAndArgs...)
|
||||||
}
|
}
|
||||||
@ -791,7 +791,7 @@ func NotContains(t TestingT, s, contains interface{}, msgAndArgs ...interface{})
|
|||||||
h.Helper()
|
h.Helper()
|
||||||
}
|
}
|
||||||
|
|
||||||
ok, found := includeElement(s, contains)
|
ok, found := containsElement(s, contains)
|
||||||
if !ok {
|
if !ok {
|
||||||
return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", s), msgAndArgs...)
|
return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", s), msgAndArgs...)
|
||||||
}
|
}
|
||||||
@ -835,7 +835,7 @@ func Subset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) (ok
|
|||||||
|
|
||||||
for i := 0; i < subsetValue.Len(); i++ {
|
for i := 0; i < subsetValue.Len(); i++ {
|
||||||
element := subsetValue.Index(i).Interface()
|
element := subsetValue.Index(i).Interface()
|
||||||
ok, found := includeElement(list, element)
|
ok, found := containsElement(list, element)
|
||||||
if !ok {
|
if !ok {
|
||||||
return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", list), msgAndArgs...)
|
return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", list), msgAndArgs...)
|
||||||
}
|
}
|
||||||
@ -879,7 +879,7 @@ func NotSubset(t TestingT, list, subset interface{}, msgAndArgs ...interface{})
|
|||||||
|
|
||||||
for i := 0; i < subsetValue.Len(); i++ {
|
for i := 0; i < subsetValue.Len(); i++ {
|
||||||
element := subsetValue.Index(i).Interface()
|
element := subsetValue.Index(i).Interface()
|
||||||
ok, found := includeElement(list, element)
|
ok, found := containsElement(list, element)
|
||||||
if !ok {
|
if !ok {
|
||||||
return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", list), msgAndArgs...)
|
return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", list), msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
@ -732,53 +732,53 @@ func TestNotSubsetNil(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_includeElement(t *testing.T) {
|
func Test_containsElement(t *testing.T) {
|
||||||
|
|
||||||
list1 := []string{"Foo", "Bar"}
|
list1 := []string{"Foo", "Bar"}
|
||||||
list2 := []int{1, 2}
|
list2 := []int{1, 2}
|
||||||
simpleMap := map[interface{}]interface{}{"Foo": "Bar"}
|
simpleMap := map[interface{}]interface{}{"Foo": "Bar"}
|
||||||
|
|
||||||
ok, found := includeElement("Hello World", "World")
|
ok, found := containsElement("Hello World", "World")
|
||||||
True(t, ok)
|
True(t, ok)
|
||||||
True(t, found)
|
True(t, found)
|
||||||
|
|
||||||
ok, found = includeElement(list1, "Foo")
|
ok, found = containsElement(list1, "Foo")
|
||||||
True(t, ok)
|
True(t, ok)
|
||||||
True(t, found)
|
True(t, found)
|
||||||
|
|
||||||
ok, found = includeElement(list1, "Bar")
|
ok, found = containsElement(list1, "Bar")
|
||||||
True(t, ok)
|
True(t, ok)
|
||||||
True(t, found)
|
True(t, found)
|
||||||
|
|
||||||
ok, found = includeElement(list2, 1)
|
ok, found = containsElement(list2, 1)
|
||||||
True(t, ok)
|
True(t, ok)
|
||||||
True(t, found)
|
True(t, found)
|
||||||
|
|
||||||
ok, found = includeElement(list2, 2)
|
ok, found = containsElement(list2, 2)
|
||||||
True(t, ok)
|
True(t, ok)
|
||||||
True(t, found)
|
True(t, found)
|
||||||
|
|
||||||
ok, found = includeElement(list1, "Foo!")
|
ok, found = containsElement(list1, "Foo!")
|
||||||
True(t, ok)
|
True(t, ok)
|
||||||
False(t, found)
|
False(t, found)
|
||||||
|
|
||||||
ok, found = includeElement(list2, 3)
|
ok, found = containsElement(list2, 3)
|
||||||
True(t, ok)
|
True(t, ok)
|
||||||
False(t, found)
|
False(t, found)
|
||||||
|
|
||||||
ok, found = includeElement(list2, "1")
|
ok, found = containsElement(list2, "1")
|
||||||
True(t, ok)
|
True(t, ok)
|
||||||
False(t, found)
|
False(t, found)
|
||||||
|
|
||||||
ok, found = includeElement(simpleMap, "Foo")
|
ok, found = containsElement(simpleMap, "Foo")
|
||||||
True(t, ok)
|
True(t, ok)
|
||||||
True(t, found)
|
True(t, found)
|
||||||
|
|
||||||
ok, found = includeElement(simpleMap, "Bar")
|
ok, found = containsElement(simpleMap, "Bar")
|
||||||
True(t, ok)
|
True(t, ok)
|
||||||
False(t, found)
|
False(t, found)
|
||||||
|
|
||||||
ok, found = includeElement(1433, "1")
|
ok, found = containsElement(1433, "1")
|
||||||
False(t, ok)
|
False(t, ok)
|
||||||
False(t, found)
|
False(t, found)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user