aboutsummaryrefslogtreecommitdiff
path: root/src/bytes/bytes_test.go
diff options
context:
space:
mode:
authorhopehook <hopehook@qq.com>2023-01-03 16:23:16 +0800
committerGopher Robot <gobot@golang.org>2023-01-24 22:06:45 +0000
commit0b3f58c48e3298e49e27f80dc748f0652339d63e (patch)
treeb97cd822afb25332f99f90630c931a3d1ccc8f94 /src/bytes/bytes_test.go
parent43f9b826c322d5541ca0260f8b0c9b71db0f7ec8 (diff)
downloadgo-0b3f58c48e3298e49e27f80dc748f0652339d63e.tar.xz
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>
Diffstat (limited to 'src/bytes/bytes_test.go')
-rw-r--r--src/bytes/bytes_test.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/bytes/bytes_test.go b/src/bytes/bytes_test.go
index fc2824485a..05c0090b61 100644
--- a/src/bytes/bytes_test.go
+++ b/src/bytes/bytes_test.go
@@ -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.