-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
57 lines (53 loc) · 1.22 KB
/
main_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
45
46
47
48
49
50
51
52
53
54
55
56
57
package main
import "testing"
func TestJoltageDiffFreq(t *testing.T) {
for n, tc := range []struct {
joltages []int
wantOne, wantTwo, wantThree int
}{
{
joltages: []int{
16, 10, 15, 5, 1, 11, 7, 19, 6, 12, 4,
},
wantOne: 7,
wantThree: 5,
},
{
joltages: []int{
28, 33, 18, 42, 31, 14, 46, 20, 48, 47, 24, 23, 49, 45, 19,
38, 39, 11, 1, 32, 25, 35, 8, 17, 7, 9, 4, 2, 34, 10, 3,
},
wantOne: 22,
wantThree: 10,
},
} {
gotOne, gotThree := joltageDiffFreq(tc.joltages)
if gotOne != tc.wantOne || gotThree != tc.wantThree {
t.Errorf("[%d] got %d, %d, want %d, %d", n, gotOne, gotThree, tc.wantOne, tc.wantThree)
}
}
}
func TestPossibleArrangements(t *testing.T) {
for n, tc := range []struct {
joltages []int
arrangements int
}{
{
joltages: []int{
16, 10, 15, 5, 1, 11, 7, 19, 6, 12, 4,
},
arrangements: 8,
},
{
joltages: []int{
28, 33, 18, 42, 31, 14, 46, 20, 48, 47, 24, 23, 49, 45, 19,
38, 39, 11, 1, 32, 25, 35, 8, 17, 7, 9, 4, 2, 34, 10, 3,
},
arrangements: 19208,
},
} {
if got, want := possibleArrangements(tc.joltages), tc.arrangements; got != want {
t.Errorf("[%d] got %d, want %d", n, got, want)
}
}
}