aboutsummaryrefslogtreecommitdiff
path: root/src/unicode/utf8
diff options
context:
space:
mode:
authorCuong Manh Le <cuong.manhle.vn@gmail.com>2024-09-14 06:37:33 +0700
committerGopher Robot <gobot@golang.org>2024-09-15 02:04:55 +0000
commit9bd34ebb7e820922458929c9a1146fb0a5b0ca4d (patch)
tree6206ed17e5a956a86598075ada79b0e59869f8f2 /src/unicode/utf8
parentf117d1c9b5951ab2456c1e512ac0423fcf3d7ada (diff)
downloadgo-9bd34ebb7e820922458929c9a1146fb0a5b0ca4d.tar.xz
unicode/utf8: add test that RuneCount does zero allocations
See disccusion in CL 612955. Change-Id: I2de582321648f1798929ffb80d2f087e41146ead Reviewed-on: https://go-review.googlesource.com/c/go/+/613315 Commit-Queue: Ian Lance Taylor <iant@google.com> Reviewed-by: Tim King <taking@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Diffstat (limited to 'src/unicode/utf8')
-rw-r--r--src/unicode/utf8/utf8_test.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/unicode/utf8/utf8_test.go b/src/unicode/utf8/utf8_test.go
index 2adec97541..69362d2cf1 100644
--- a/src/unicode/utf8/utf8_test.go
+++ b/src/unicode/utf8/utf8_test.go
@@ -438,6 +438,15 @@ func TestRuneCount(t *testing.T) {
}
}
+func TestRuneCountNonASCIIAllocation(t *testing.T) {
+ if n := testing.AllocsPerRun(10, func() {
+ s := []byte("日本語日本語日本語日")
+ _ = RuneCount(s)
+ }); n > 0 {
+ t.Errorf("unexpected RuneCount allocation, got %v, want 0", n)
+ }
+}
+
type RuneLenTest struct {
r rune
size int