blob: eabd1f2c3b9a8b44578fd33f6c7df8f3f046198e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
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)
}
}
}
|