mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 15:58:37 +00:00
add test for slice
Signed-off-by: yanxuean <yan.xuean@zte.com.cn>
This commit is contained in:
parent
6e950cc629
commit
68df307378
@ -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")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user