utils
This commit is contained in:
parent
3082234dae
commit
ce6f3182a2
2 changed files with 48 additions and 1 deletions
|
@ -1 +0,0 @@
|
||||||
package utils
|
|
48
pkg/utils/strings_test.go
Normal file
48
pkg/utils/strings_test.go
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
package utils
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestContains(t *testing.T) {
|
||||||
|
type args struct {
|
||||||
|
list []string
|
||||||
|
needle string
|
||||||
|
}
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
args args
|
||||||
|
want bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
"empty list false",
|
||||||
|
args{[]string{}, "needle"},
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"list not containing false",
|
||||||
|
args{[]string{"list"}, "needle"},
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"list not containing empty needle false",
|
||||||
|
args{[]string{"list", "needle"}, ""},
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"list containing true",
|
||||||
|
args{[]string{"list", "needle"}, "needle"},
|
||||||
|
true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"list containing empty needle true",
|
||||||
|
args{[]string{"list", "needle", ""}, ""},
|
||||||
|
true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
if got := Contains(tt.args.list, tt.args.needle); got != tt.want {
|
||||||
|
t.Errorf("Contains() = %v, want %v", got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue