MCPcopy Create free account
hub / github.com/coregx/coregex / FuzzMatchStdlib

Function FuzzMatchStdlib

fuzz_stdlib_test.go:217–245  ·  view source on GitHub ↗

=========================================================================== FuzzMatchStdlib - Fuzz Match/MatchString ===========================================================================

(f *testing.F)

Source from the content-addressed store, hash-verified

215// ===========================================================================
216
217func FuzzMatchStdlib(f *testing.F) {
218 // Add seed corpus
219 for _, p := range seedPatterns {
220 for _, i := range seedInputs {
221 f.Add(p, i)
222 }
223 }
224
225 f.Fuzz(func(t *testing.T, pattern, input string) {
226 // Skip invalid patterns
227 stdRe, err := regexp.Compile(pattern)
228 if err != nil {
229 return
230 }
231
232 cgRe, err := Compile(pattern)
233 if err != nil {
234 t.Fatalf("coregex failed to compile valid pattern %q: %v", pattern, err)
235 }
236
237 // Compare MatchString
238 stdMatchStr := stdRe.MatchString(input)
239 cgMatchStr := cgRe.MatchString(input)
240 if stdMatchStr != cgMatchStr {
241 t.Errorf("MatchString(%q, %q):\n stdlib: %v\n coregex: %v",
242 pattern, input, stdMatchStr, cgMatchStr)
243 }
244 })
245}
246
247// ===========================================================================
248// FuzzFindStdlib - Fuzz Find/FindString/FindIndex

Callers

nothing calls this directly

Calls 4

AddMethod · 0.80
CompileMethod · 0.80
MatchStringMethod · 0.80
CompileFunction · 0.70

Tested by

no test coverage detected