-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.py
43 lines (29 loc) · 1.24 KB
/
tests.py
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
######################
######## Tests #######
######################
import unittest
import random
from bowling import Scoreboard, Frame
class Test(unittest.TestCase):
def setUp(self):
self.scoreboard = Scoreboard(frames=[], shots=[], score=0)
def test_eights(self):
for pins in [8, 0, 8, 0, 8, 0, 8, 0, 8, 0, 8, 0, 8, 0, 8, 0, 8, 0, 8, 0]:
self.scoreboard.throw(pins)
self.assertEqual(80, self.scoreboard.get_final_score())
def test_strikes(self):
for pins in [10,10,10,10,10,10,10,10,10,10,10,10]:
self.scoreboard.throw(pins)
self.assertEqual(300, self.scoreboard.get_final_score())
def test_spares(self):
for pins in [1,9,2,8,3,7,4,6,5,5,6,4,7,3,8,2,9,1,9,1,8]:
self.scoreboard.throw(pins)
self.assertEqual(161, self.scoreboard.get_final_score())
def test_zeroes(self):
for pins in [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]:
self.scoreboard.throw(pins)
self.assertEqual(0, self.scoreboard.get_final_score())
def test_ones(self):
for pins in [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]:
self.scoreboard.throw(pins)
self.assertEqual(20, self.scoreboard.get_final_score())