Slide 42
Slide 42 text
digitalocean.com
func TestSquare(t *testing.T) {
cases := []struct {
arg int
expected int
}{
{5, 25},
{0, 0},
{-1, 1},
}
for i, c := range cases {
got := square(c.arg)
if got != c.expected {
t.Errorf("case %d: expected %d, got %d",
i, c.expected, got)
}
}
}