MCPcopy
hub / github.com/gofrs/uuid / FuzzFromStringOrNilFunc

Function FuzzFromStringOrNilFunc

codec_test.go:508–525  ·  view source on GitHub ↗

FuzzFromStringOrNil is a fuzz testing suite that exercises the FromStringOrNil function

(f *testing.F)

Source from the content-addressed store, hash-verified

506
507// FuzzFromStringOrNil is a fuzz testing suite that exercises the FromStringOrNil function
508func FuzzFromStringOrNilFunc(f *testing.F) {
509 for _, seed := range fromStringCorpus {
510 f.Add(seed)
511 }
512 uuidRegexp, err := regexp.Compile(uuidPattern)
513 if err != nil {
514 f.Error("uuid regexp failed to compile")
515 }
516 f.Fuzz(func(t *testing.T, payload string) {
517 u := FromStringOrNil(payload)
518 if u != Nil {
519 if !uuidRegexp.MatchString(u.String()) {
520 t.Errorf("%s resulted in invalid uuid %s", payload, u.String())
521 }
522 }
523 // otherwise, allow to pass if no panic
524 })
525}

Callers

nothing calls this directly

Calls 3

FromStringOrNilFunction · 0.85
ErrorMethod · 0.80
StringMethod · 0.80

Tested by

no test coverage detected