FuzzFromStringOrNil is a fuzz testing suite that exercises the FromStringOrNil function
(f *testing.F)
| 506 | |
| 507 | // FuzzFromStringOrNil is a fuzz testing suite that exercises the FromStringOrNil function |
| 508 | func 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 | } |
nothing calls this directly
no test coverage detected