Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check skipped fields if fail through #1

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions fuzz.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,11 @@ func (fc *fuzzerContext) doFuzz(v reflect.Value, flags uint64) {
case reflect.Interface:
fallthrough
default:
for _, pattern := range fc.fuzzer.skipFieldPatterns {
if pattern.MatchString(v.Type().Name()) {
return
}
}
panic(fmt.Sprintf("Can't handle %#v", v.Interface()))
}
}
Expand Down
7 changes: 3 additions & 4 deletions fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ func TestFuzz_Maxdepth(t *testing.T) {
}

func TestFuzz_SkipPattern(t *testing.T) {
obj := &struct {
obj := struct {
S1 string
S2 string
XXX_S string
Expand All @@ -492,12 +492,11 @@ func TestFuzz_SkipPattern(t *testing.T) {
XXX_S1 string
S2_XXX string
}
XXX_ERR error
}{}

f := New().NilChance(0).SkipFieldsWithPattern(regexp.MustCompile(`^XXX_`))
f.Fuzz(obj)

tryFuzz(t, f, obj, func() (int, bool) {
tryFuzz(t, f, &obj, func() (int, bool) {
if obj.XXX_S != "" {
return 1, false
}
Expand Down