Skip to content

Commit

Permalink
added more tests for AssertContains
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinJWendt committed Apr 7, 2022
1 parent 9945ef3 commit a71a0a7
Showing 1 changed file with 30 additions and 8 deletions.
38 changes: 30 additions & 8 deletions assert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -542,17 +542,39 @@ func TestAssertNotImplements_fails(t *testing.T) {
}

func TestAssertContains(t *testing.T) {
s := []string{"Hello", "World"}

AssertContains(t, s, "World")
tests := []struct {
name string
obj interface{}
contains interface{}
}{
{name: "String Slice", obj: []string{"Hello", "World", "!"}, contains: "World"},
{name: "Int Slice", obj: []int{1, 2, 3, 4, 5, 6, 7, 8}, contains: 4},
{name: "String", obj: "Hello, World!", contains: "World"},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
AssertContains(t, test.obj, test.contains)
})
}
}

func TestAssertContains_fails(t *testing.T) {
s := []string{"Hello", "World"}

AssertTestFails(t, func(t TestingPackageWithFailFunctions) {
AssertContains(t, s, "asdasd")
})
tests := []struct {
name string
obj interface{}
contains interface{}
}{
{name: "String Slice", obj: []string{"Hello", "World", "!"}, contains: "asdasdasd"},
{name: "Int Slice", obj: []int{1, 2, 3, 4, 5, 6, 7, 8}, contains: 1337},
{name: "String", obj: "Hello, World!", contains: "asdasdasd"},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
AssertTestFails(t, func(t TestingPackageWithFailFunctions) {
AssertContains(t, test.obj, test.contains)
})
})
}
}

func TestAssertNotContains(t *testing.T) {
Expand Down

0 comments on commit a71a0a7

Please sign in to comment.