Use new gofuzz features

This commit is contained in:
Tim Hockin
2015-03-07 00:04:14 -08:00
parent a68779dff9
commit fd1e49ce2f
2 changed files with 25 additions and 66 deletions

View File

@@ -29,6 +29,7 @@ import (
"time"
"github.com/golang/glog"
"github.com/google/gofuzz"
)
// For testing, bypass HandleCrash.
@@ -162,6 +163,18 @@ func (intstr IntOrString) MarshalJSON() ([]byte, error) {
}
}
func (intstr *IntOrString) Fuzz(c fuzz.Continue) {
if c.RandBool() {
intstr.Kind = IntstrInt
c.Fuzz(&intstr.IntVal)
intstr.StrVal = ""
} else {
intstr.Kind = IntstrString
intstr.IntVal = 0
c.Fuzz(&intstr.StrVal)
}
}
// Takes a list of strings and compiles them into a list of regular expressions
func CompileRegexps(regexpStrings []string) ([]*regexp.Regexp, error) {
regexps := []*regexp.Regexp{}