Last active
June 11, 2018 17:35
-
-
Save vporoshok/4b5ed8fe303307cafd7146d8c32654ce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package fizzbuzz | |
import ( | |
"strconv" | |
"testing" | |
) | |
func TestFizzBuzzCases(t *testing.T) { | |
cases := []struct { | |
input int | |
output string | |
}{ | |
{ | |
input: 2, | |
output: "2", | |
}, | |
{ | |
input: 12, | |
output: "Fizz", | |
}, | |
{ | |
input: 25, | |
output: "Buzz", | |
}, | |
{ | |
input: 60, | |
output: "FizzBuzz", | |
}, | |
} | |
for _, c := range cases { | |
t.Run(strconv.Itoa(c.input), func(t *testing.T) { | |
t.Parallel() | |
res := FizzBuzz(c.input) | |
if res != c.output { | |
t.Errorf("expected %q but got %q", c.output, res) | |
} | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment