mirror of https://github.com/k3s-io/k3s
Merge pull request #55858 from yanxuean/unit-slice
Automatic merge from submit-queue (batch tested with PRs 55988, 53555, 55858). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. add test for slice Signed-off-by: yanxuean <yan.xuean@zte.com.cn> **What this PR does / why we need it**: **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes # **Special notes for your reviewer**: **Release note**: ```release-note NONE ```pull/6/head
commit
936bcd1361
|
@ -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