Skip to content

Instantly share code, notes, and snippets.

@plutov
Created May 4, 2020 19:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save plutov/ed527201345322d66d28c264ad4ba7f1 to your computer and use it in GitHub Desktop.
Save plutov/ed527201345322d66d28c264ad4ba7f1 to your computer and use it in GitHub Desktop.
testable3.go
func TestStrInSlice(t *testing.T) {
var tests = []struct{
slice []string
find string
want bool
}{
{[]string{"a", "b"}, "c", false},
{[]string{"a", "b"}, "a", true},
}
for _, tt := range tests {
t.Run(tt.find, func(t *testing.T) {
got := StrInSlice(tt.slice, tt.find)
if got != tt.want {
t.Errorf("expecting %t, got %t", tt.want, got)
}
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment