File: strings_test.go

package info (click to toggle)
golang-github-zitadel-oidc 3.37.0-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, sid, trixie
  • size: 1,484 kB
  • sloc: makefile: 5
file content (48 lines) | stat: -rw-r--r-- 859 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package strings

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)
			}
		})
	}
}