-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscore_test.go
50 lines (44 loc) · 1.33 KB
/
score_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
package bowling_test
import (
"bowling"
"github.com/stretchr/testify/assert"
"testing"
)
func TestGutterBallGame(t *testing.T) {
assert.Equal(t, 0, bowling.Score("-- -- -- -- -- -- -- -- -- --"))
}
func TestFirstPinNumericPoints(t *testing.T) {
tests := []struct {
name string
game string
expectedScore int
}{
{"Single pin first frame", "1- -- -- -- -- -- -- -- -- --", 1},
{"Single pin first two frames", "1- 1- -- -- -- -- -- -- -- --", 2},
{"Single pin first three frames", "1- 1- 1- -- -- -- -- -- -- --", 3},
{"First ball simple scores", "-- 1- 2- 3- 4- 5- 6- 7- 8- 9-", 45},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
assert.Equal(t, test.expectedScore, bowling.Score(test.game))
})
}
}
func TestSecondBallNumericPoints(t *testing.T) {
tests := []struct {
name string
game string
expectedScore int
}{
{"Single pin first frame", "-1 -- -- -- -- -- -- -- -- --", 1},
{"Single pin first two frames", "-1 -1 -- -- -- -- -- -- -- --", 2},
{"Single pin first three frames", "-1 -1 -1 -- -- -- -- -- -- --", 3},
// TODO add second ball simple score tests
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
assert.Equal(t, test.expectedScore, bowling.Score(test.game))
})
}
// TODO start to cover spares and strikes
}