=========================================================================== FuzzFindStdlib - Fuzz Find/FindString/FindIndex ===========================================================================
(f *testing.F)
| 249 | // =========================================================================== |
| 250 | |
| 251 | func FuzzFindStdlib(f *testing.F) { |
| 252 | // Add seed corpus |
| 253 | for _, p := range seedPatterns { |
| 254 | for _, i := range seedInputs { |
| 255 | f.Add(p, i) |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | f.Fuzz(func(t *testing.T, pattern, input string) { |
| 260 | // Skip known differences: UTF-8 codepoint vs byte matching |
| 261 | if hasUTF8CodepointDifference(pattern, input) { |
| 262 | return |
| 263 | } |
| 264 | |
| 265 | // Skip invalid patterns |
| 266 | stdRe, err := regexp.Compile(pattern) |
| 267 | if err != nil { |
| 268 | return |
| 269 | } |
| 270 | |
| 271 | cgRe, err := Compile(pattern) |
| 272 | if err != nil { |
| 273 | t.Fatalf("coregex failed to compile valid pattern %q: %v", pattern, err) |
| 274 | } |
| 275 | |
| 276 | // Compare Find |
| 277 | stdFind := stdRe.Find([]byte(input)) |
| 278 | cgFind := cgRe.Find([]byte(input)) |
| 279 | if !bytes.Equal(stdFind, cgFind) { |
| 280 | t.Errorf("Find(%q, %q):\n stdlib: %q\n coregex: %q", |
| 281 | pattern, input, stdFind, cgFind) |
| 282 | } |
| 283 | |
| 284 | // Compare FindString |
| 285 | stdFindStr := stdRe.FindString(input) |
| 286 | cgFindStr := cgRe.FindString(input) |
| 287 | if stdFindStr != cgFindStr { |
| 288 | t.Errorf("FindString(%q, %q):\n stdlib: %q\n coregex: %q", |
| 289 | pattern, input, stdFindStr, cgFindStr) |
| 290 | } |
| 291 | |
| 292 | // Compare FindStringIndex |
| 293 | stdStrIdx := stdRe.FindStringIndex(input) |
| 294 | cgStrIdx := cgRe.FindStringIndex(input) |
| 295 | if !reflect.DeepEqual(stdStrIdx, cgStrIdx) { |
| 296 | t.Errorf("FindStringIndex(%q, %q):\n stdlib: %v\n coregex: %v", |
| 297 | pattern, input, stdStrIdx, cgStrIdx) |
| 298 | } |
| 299 | }) |
| 300 | } |
| 301 | |
| 302 | // =========================================================================== |
| 303 | // FuzzFindAllStdlib - Fuzz FindAll/FindAllString/FindAllIndex |
nothing calls this directly
no test coverage detected