-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bowling_test.go
105 lines (94 loc) · 1.35 KB
/
Bowling_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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package bowling
import "testing"
func TestGame90(t *testing.T) {
game := Game{
frames: [12]Frame{
{9, 0},
{9, 0},
{9, 0},
{9, 0},
{9, 0},
{9, 0},
{9, 0},
{9, 0},
{9, 0},
{9, 0},
{0, 0},
{0, 0},
},
}
got := BowlingGame(game)
want := 90
if got != want {
t.Errorf("got '%d' want '%d'", got, want)
}
}
func TestGame300(t *testing.T) {
game := Game{
frames: [12]Frame{
{10, 0},
{10, 0},
{10, 0},
{10, 0},
{10, 0},
{10, 0},
{10, 0},
{10, 0},
{10, 0},
{10, 0},
{10, 0},
{10, 0},
},
}
got := BowlingGame(game)
want := 300
if got != want {
t.Errorf("got '%d' want '%d'", got, want)
}
}
func TestGame150(t *testing.T) {
game := Game{
frames: [12]Frame{
{5, 5},
{5, 5},
{5, 5},
{5, 5},
{5, 5},
{5, 5},
{5, 5},
{5, 5},
{5, 5},
{5, 5},
{5, 5},
{0, 0},
},
}
got := BowlingGame(game)
want := 150
if got != want {
t.Errorf("got '%d' want '%d'", got, want)
}
}
func TestGame123(t *testing.T) {
game := Game{
frames: [12]Frame{
{10, 0}, //20
{5, 5}, //40
{10, 0}, //70
{10, 0}, //95
{10, 0}, //114
{5, 4}, //123
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
},
}
got := BowlingGame(game)
want := 123
if got != want {
t.Errorf("got '%d' want '%d'", got, want)
}
}