-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathproblem23_test.go
More file actions
44 lines (38 loc) · 808 Bytes
/
problem23_test.go
File metadata and controls
44 lines (38 loc) · 808 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
// 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 TestProblem23(t *testing.T) {
const want = 4179871
got := Problem23()
if got != want {
t.Errorf("Problem23() = %d; want %d", got, want)
}
}
var isAbundantTests = []struct {
in int
want bool
}{
{0, false},
{10, false},
{12, true},
{50, false},
{54, true},
{81, false},
{100, true},
{105, false},
{120, true},
}
func TestIsAbundant(t *testing.T) {
for _, tt := range isAbundantTests {
if isAbundant(tt.in) != tt.want {
t.Errorf("isAbundant(%d) = %t; want %t", tt.in, !tt.want, tt.want)
}
}
}
func BenchmarkProblem23(b *testing.B) {
for i := 0; i < b.N; i++ {
Problem23()
}
}