Exercism: Go version of the 'Leap' exercise.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
481 B

package leap
import "testing"
func TestLeapYears(t *testing.T) {
for _, test := range testCases {
observed := IsLeapYear(test.year)
if observed != test.expected {
t.Fatalf("IsLeapYear(%d) = %t, want %t (%s)",
test.year, observed, test.expected, test.description)
}
}
}
// Benchmark 400 year interval to get fair weighting of different years.
func Benchmark400(b *testing.B) {
for i := 0; i < b.N; i++ {
for y := 1600; y < 2000; y++ {
IsLeapYear(y)
}
}
}