(t *testing.T)
| 225 | } |
| 226 | |
| 227 | func TestStringProcessingAllocations(t *testing.T) { |
| 228 | skipIfAllocsUnreliable(t) |
| 229 | re := MustCompile(`needle`) |
| 230 | input := "needle" + strings.Repeat("界", 21845) |
| 231 | if allocs := testing.AllocsPerRun(100, func() { |
| 232 | if _, err := re.FindAllStringIndex(input, 1); err != nil { |
| 233 | panic(err) |
| 234 | } |
| 235 | }); allocs > 5 { |
| 236 | t.Fatalf("FindAllStringIndex allocations=%v; want <=5", allocs) |
| 237 | } |
| 238 | split := MustCompile(`(,)`) |
| 239 | input = strings.Repeat("abc,", 1000) + "abc" |
| 240 | if allocs := testing.AllocsPerRun(100, func() { |
| 241 | if _, err := split.Split(input, -1); err != nil { |
| 242 | panic(err) |
| 243 | } |
| 244 | }); allocs > 30 { |
| 245 | t.Fatalf("Split allocations=%v; want <=30", allocs) |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | func TestSplitConcurrentPoolUse(t *testing.T) { |
| 250 | re := MustCompile(`(needle)`) |
nothing calls this directly
no test coverage detected