-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathproblem24_test.go
More file actions
42 lines (36 loc) · 781 Bytes
/
problem24_test.go
File metadata and controls
42 lines (36 loc) · 781 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
// 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 TestProblem24(t *testing.T) {
const want = 2783915460
got, err := Problem24()
if got != want || err != nil {
t.Errorf("Problem24() = %d, %v; want %d, <nil>", got, err, want)
}
}
var factorialTests = []struct {
in int
want int
}{
{0, 1},
{1, 1},
{2, 2},
{3, 6},
{4, 24},
{5, 120},
}
func TestFactorial(t *testing.T) {
for _, tt := range factorialTests {
got := factorial(tt.in)
if got != tt.want {
t.Errorf("factorial(%d) = %v; want %d", tt.in, got, tt.want)
}
}
}
func BenchmarkProblem24(b *testing.B) {
for i := 0; i < b.N; i++ {
Problem24()
}
}