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
Kubernetes Submit Queue 2017-11-18 20:31:26 -08:00 committed by GitHub
commit 936bcd1361
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 0 deletions

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")
}
}