add test for slice

Signed-off-by: yanxuean <yan.xuean@zte.com.cn>
This commit is contained in:
yanxuean 2017-11-16 16:37:29 +08:00
parent 6e950cc629
commit 68df307378

View File

@ -89,3 +89,20 @@ func TestShuffleStrings(t *testing.T) {
}
}
}
func TestContainsString(t *testing.T) {
src := []string{"aa", "bb", "cc"}
if !ContainsString(src, "bb", nil) {
t.Errorf("ContainsString didn't find the string as expected")
}
modifier := func(s string) string {
if s == "cc" {
return "ee"
}
return s
}
if !ContainsString(src, "ee", modifier) {
t.Errorf("ContainsString didn't find the string by modifier")
}
}