1
0
mirror of https://github.com/golang/go synced 2024-11-21 23:44:39 -07:00

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>
This commit is contained in:
Cuong Manh Le 2024-09-14 06:37:33 +07:00 committed by Gopher Robot
parent f117d1c9b5
commit 9bd34ebb7e

View File

@ -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