Skip to content

Commit

Permalink
fix funtion name
Browse files Browse the repository at this point in the history
  • Loading branch information
mvrahden authored and boyan-soubachov committed Aug 24, 2021
1 parent 5c61ef9 commit edff5a0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
10 changes: 5 additions & 5 deletions assert/assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ func NotEqualValues(t TestingT, expected, actual interface{}, msgAndArgs ...inte
// return (false, false) if impossible.
// return (true, false) if element was not 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)
listType := reflect.TypeOf(list)
Expand Down Expand Up @@ -768,7 +768,7 @@ func Contains(t TestingT, s, contains interface{}, msgAndArgs ...interface{}) bo
h.Helper()
}

ok, found := includeElement(s, contains)
ok, found := containsElement(s, contains)
if !ok {
return Fail(t, fmt.Sprintf("%#v could not be applied builtin len()", s), msgAndArgs...)
}
Expand All @@ -791,7 +791,7 @@ func NotContains(t TestingT, s, contains interface{}, msgAndArgs ...interface{})
h.Helper()
}

ok, found := includeElement(s, contains)
ok, found := containsElement(s, contains)
if !ok {
return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", s), msgAndArgs...)
}
Expand Down Expand Up @@ -835,7 +835,7 @@ func Subset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) (ok

for i := 0; i < subsetValue.Len(); i++ {
element := subsetValue.Index(i).Interface()
ok, found := includeElement(list, element)
ok, found := containsElement(list, element)
if !ok {
return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", list), msgAndArgs...)
}
Expand Down Expand Up @@ -879,7 +879,7 @@ func NotSubset(t TestingT, list, subset interface{}, msgAndArgs ...interface{})

for i := 0; i < subsetValue.Len(); i++ {
element := subsetValue.Index(i).Interface()
ok, found := includeElement(list, element)
ok, found := containsElement(list, element)
if !ok {
return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", list), msgAndArgs...)
}
Expand Down
24 changes: 12 additions & 12 deletions assert/assertions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
list2 := []int{1, 2}
simpleMap := map[interface{}]interface{}{"Foo": "Bar"}

ok, found := includeElement("Hello World", "World")
ok, found := containsElement("Hello World", "World")
True(t, ok)
True(t, found)

ok, found = includeElement(list1, "Foo")
ok, found = containsElement(list1, "Foo")
True(t, ok)
True(t, found)

ok, found = includeElement(list1, "Bar")
ok, found = containsElement(list1, "Bar")
True(t, ok)
True(t, found)

ok, found = includeElement(list2, 1)
ok, found = containsElement(list2, 1)
True(t, ok)
True(t, found)

ok, found = includeElement(list2, 2)
ok, found = containsElement(list2, 2)
True(t, ok)
True(t, found)

ok, found = includeElement(list1, "Foo!")
ok, found = containsElement(list1, "Foo!")
True(t, ok)
False(t, found)

ok, found = includeElement(list2, 3)
ok, found = containsElement(list2, 3)
True(t, ok)
False(t, found)

ok, found = includeElement(list2, "1")
ok, found = containsElement(list2, "1")
True(t, ok)
False(t, found)

ok, found = includeElement(simpleMap, "Foo")
ok, found = containsElement(simpleMap, "Foo")
True(t, ok)
True(t, found)

ok, found = includeElement(simpleMap, "Bar")
ok, found = containsElement(simpleMap, "Bar")
True(t, ok)
False(t, found)

ok, found = includeElement(1433, "1")
ok, found = containsElement(1433, "1")
False(t, ok)
False(t, found)
}
Expand Down

0 comments on commit edff5a0

Please sign in to comment.