Skip to content

Instantly share code, notes, and snippets.

@vporoshok
Last active June 11, 2018 17:35
Show Gist options
  • Save vporoshok/4b5ed8fe303307cafd7146d8c32654ce to your computer and use it in GitHub Desktop.
Save vporoshok/4b5ed8fe303307cafd7146d8c32654ce to your computer and use it in GitHub Desktop.
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