mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
bytes, strings: add ContainsFunc
Fixes #54386. Change-Id: I78747da337ed6129e4f7426dd0483a644bed82e3 Reviewed-on: https://go-review.googlesource.com/c/go/+/460216 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: hopehook <hopehook@golangcn.org> Auto-Submit: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
43f9b826c3
commit
0b3f58c48e
5 changed files with 34 additions and 0 deletions
|
|
@ -1847,6 +1847,17 @@ func TestContainsRune(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestContainsFunc(t *testing.T) {
|
||||
for _, ct := range ContainsRuneTests {
|
||||
if ContainsFunc(ct.b, func(r rune) bool {
|
||||
return ct.r == r
|
||||
}) != ct.expected {
|
||||
t.Errorf("ContainsFunc(%q, func(%q)) = %v, want %v",
|
||||
ct.b, ct.r, !ct.expected, ct.expected)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var makeFieldsInput = func() []byte {
|
||||
x := make([]byte, 1<<20)
|
||||
// Input is ~10% space, ~10% 2-byte UTF-8, rest ASCII non-space.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue