Skip to content

Commit

Permalink
add test for slice
Browse files Browse the repository at this point in the history
Signed-off-by: yanxuean <yan.xuean@zte.com.cn>
  • Loading branch information
yanxuean committed Nov 16, 2017
1 parent fe4da33 commit 562cacc
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions slice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}

0 comments on commit 562cacc

Please sign in to comment.