diff --git a/src/regexp/all_test.go b/src/regexp/all_test.go index ead184d286..bc3278db9d 100644 --- a/src/regexp/all_test.go +++ b/src/regexp/all_test.go @@ -5,6 +5,7 @@ package regexp import ( + "bytes" "reflect" "regexp/syntax" "slices" @@ -613,6 +614,19 @@ func BenchmarkFindAllNoMatches(b *testing.B) { } } +func BenchmarkFindAllTenMatches(b *testing.B) { + re := MustCompile("a+b+") + s := bytes.Repeat([]byte("acddeeabbax"), 10) + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + all := re.FindAll(s, -1) + if len(all) != 10 { + b.Fatalf("FindAll(%q) = %q; want 10 matches", s, all) + } + } +} + func BenchmarkFindString(b *testing.B) { b.StopTimer() re := MustCompile("a+b+")