-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathproblem19_test.go
More file actions
48 lines (42 loc) · 873 Bytes
/
problem19_test.go
File metadata and controls
48 lines (42 loc) · 873 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright 2015 Peter Mrekaj. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE.txt file.
package euler
import "testing"
func TestProblem19(t *testing.T) {
const want = 171
got := Problem19()
if got != want {
t.Errorf("Problem19() = %d; want %d", got, want)
}
}
var isLeapYearTests = []struct {
in int
want bool
}{
{1904, true},
{1910, false},
{1920, true},
{1930, false},
{1932, true},
{1950, false},
{1955, false},
{1960, true},
{1970, false},
{1980, true},
{1990, false},
{2000, true},
}
func TestIsLapYear(t *testing.T) {
for _, tt := range isLeapYearTests {
got := isLeapYear(tt.in)
if got != tt.want {
t.Errorf("isLeapYear(%d) = %t; want %t", tt.in, got, tt.want)
}
}
}
func BenchmarkProblem19(b *testing.B) {
for i := 0; i < b.N; i++ {
Problem19()
}
}