Debian Codegraph @

pkg/strings/strings_test.go

raw
1 package strings
2
3 import "testing"
4
5 func TestContains(t *testing.T) {
6 type args struct {
7 list []string
8 needle string
9 }
10 tests := []struct {
11 name string
12 args args
13 want bool
14 }{
15 {
16 "empty list false",
17 args{[]string{}, "needle"},
18 false,
19 },
20 {
21 "list not containing false",
22 args{[]string{"list"}, "needle"},
23 false,
24 },
25 {
26 "list not containing empty needle false",
27 args{[]string{"list", "needle"}, ""},
28 false,
29 },
30 {
31 "list containing true",
32 args{[]string{"list", "needle"}, "needle"},
33 true,
34 },
35 {
36 "list containing empty needle true",
37 args{[]string{"list", "needle", ""}, ""},
38 true,
39 },
40 }
41 for _, tt := range tests {
42 t.Run(tt.name, func(t *testing.T) {
43 if got := Contains(tt.args.list, tt.args.needle); got != tt.want {
44 t.Errorf("Contains() = %v, want %v", got, tt.want)
45 }
46 })
47 }
48 }