12345678910111213141516171819202122232425262728 |
- package domain
- import (
- "regexp"
- "strings"
- "testing"
- )
- func FuzzFizzBuzz(f *testing.F) {
- rx := regexp.MustCompile(strings.Join([]string{
- "invalid modulo parameters: ",
- "invalid string parameter: empty",
- "contains a RFC-3986 reserved character",
- }, "|"))
- target := func(t *testing.T, int1, int2, limit int, str1, str2 string) {
- fbs, err := FizzBuzz(int1, int2, limit, str1, str2)
- if err != nil && !rx.MatchString(err.Error()) {
- t.Fatalf("Unexpected error: %s", err)
- }
- if fbs == nil && err == nil {
- t.Fatalf("unexpected nil result")
- }
- if len(fbs) == 0 && err == nil {
- t.Fatal("unexpected empty result")
- }
- }
- f.Fuzz(target)
- }
|