-
Notifications
You must be signed in to change notification settings - Fork 3
/
problem21_test.go
44 lines (38 loc) · 829 Bytes
/
problem21_test.go
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
// 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 TestProblem21(t *testing.T) {
const want = 31626
got := Problem21()
if got != want {
t.Errorf("Problem21() = %d; want %d", got, want)
}
}
var isAmicableTests = []struct {
in int
want bool
}{
{1, false},
{220, true},
{284, true},
{300, false},
{1328470, true},
{1483850, true},
{2000000, false},
{8619765, true},
{9627915, true},
}
func TestIsAmicable(t *testing.T) {
for _, tt := range isAmicableTests {
if isAmicable(tt.in) != tt.want {
t.Errorf("isAmicable(%d) = %t; want %t", tt.in, !tt.want, tt.want)
}
}
}
func BenchmarkProblem21(b *testing.B) {
for i := 0; i < b.N; i++ {
Problem21()
}
}