Created
May 4, 2020 19:39
-
-
Save plutov/ed527201345322d66d28c264ad4ba7f1 to your computer and use it in GitHub Desktop.
testable3.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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