pi_coder/examples/go-fibonacci/main_test.go

20 lines
284 B
Go
Raw Normal View History

package main
import "testing"
func TestFib(t *testing.T) {
cases := []struct {
n, want int
}{
{0, 0},
{1, 1},
{2, 1},
{5, 5},
{10, 55},
}
for _, c := range cases {
if got := fib(c.n); got != c.want {
t.Errorf("fib(%d) = %d, want %d", c.n, got, c.want)
}
}
}