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

Function FuzzSplitStdlib

fuzz_stdlib_test.go:579–652  ·  view source on GitHub ↗

=========================================================================== FuzzSplitStdlib - Fuzz Split ===========================================================================

(f *testing.F)

Source from the content-addressed store, hash-verified

577// ===========================================================================
578
579func FuzzSplitStdlib(f *testing.F) {
580 // Add seed corpus
581 splitPatterns := []string{
582 `,`,
583 `:`,
584 `\s+`,
585 `\d+`,
586 `[,;]+`,
587 `-`,
588 `\.`,
589 ``,
590 }
591
592 splitInputs := []string{
593 "a,b,c",
594 "foo:bar:baz",
595 "hello world test",
596 "1a2b3c",
597 "a;b,c;d",
598 "a-b-c-d",
599 "a.b.c",
600 "",
601 "abc",
602 "no delimiter here",
603 }
604
605 for _, p := range splitPatterns {
606 for _, i := range splitInputs {
607 f.Add(p, i)
608 }
609 }
610
611 f.Fuzz(func(t *testing.T, pattern, input string) {
612 // Skip known differences: empty pattern split behavior
613 if isEmptyPatternCase(pattern) {
614 return
615 }
616
617 // Skip invalid patterns
618 stdRe, err := regexp.Compile(pattern)
619 if err != nil {
620 return
621 }
622
623 cgRe, err := Compile(pattern)
624 if err != nil {
625 t.Fatalf("coregex failed to compile valid pattern %q: %v", pattern, err)
626 }
627
628 // Compare Split with n=-1 (all splits)
629 stdSplit := stdRe.Split(input, -1)
630 cgSplit := cgRe.Split(input, -1)
631 if !reflect.DeepEqual(stdSplit, cgSplit) {
632 t.Errorf("Split(%q, %q, -1):\n stdlib: %v\n coregex: %v",
633 pattern, input, stdSplit, cgSplit)
634 }
635
636 // Compare Split with n=2 (limited)

Callers

nothing calls this directly

Calls 5

isEmptyPatternCaseFunction · 0.85
AddMethod · 0.80
CompileMethod · 0.80
CompileFunction · 0.70
SplitMethod · 0.45

Tested by

no test coverage detected