-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
60 lines (44 loc) · 1.61 KB
/
test.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import unittest
from ScoreCalculator import singles,three_of_a_kind,four_of_a_kind,yahtzee,fullhouse,long_straight,short_straight,chance
class TestScoreCalculator(unittest.TestCase):
def test_singles_ones(self):
dice_set = [1, 2, 3, 1, 5]
self.assertEqual(singles(dice_set,1), 2)
def test_singles_twos(self):
dice_set = [2, 2, 4, 3, 2]
self.assertEqual(singles(dice_set,2), 6)
def test_triples(self):
dice_set = [2, 2, 5, 3, 2]
self.assertEqual(three_of_a_kind(dice_set), 14)
dice_set = [1, 2, 5, 3, 2]
self.assertEqual(three_of_a_kind(dice_set), 0)
def test_quadruples(self):
dice_set = [2, 6, 6, 6, 6]
self.assertEqual(four_of_a_kind(dice_set), 26)
dice_set = [2, 6, 6, 6, 2]
self.assertEqual(four_of_a_kind(dice_set), 0)
def test_yahtzee(self):
dice_set = [6, 6, 6, 6, 6]
self.assertEqual(yahtzee(dice_set), 50)
dice_set = [6, 6, 6, 6, 2]
self.assertEqual(yahtzee(dice_set), 0)
def test_fullhouse(self):
dice_set = [1, 1, 6, 6, 6]
self.assertEqual(fullhouse(dice_set), 25)
dice_set = [1, 6, 6, 6, 2]
self.assertEqual(fullhouse(dice_set), 0)
def test_long_straight(self):
dice_set = [2, 5, 4, 6, 3]
self.assertEqual(long_straight(dice_set), 40)
dice_set = [1, 1, 3, 4, 5]
self.assertEqual(long_straight(dice_set), 0)
def test_short_straight(self):
dice_set = [1, 5, 4, 6, 3]
self.assertEqual(short_straight(dice_set), 30)
dice_set = [1, 1, 3, 4, 5]
self.assertEqual(short_straight(dice_set), 0)
dice_set = [6, 4, 2, 3, 5]
self.assertEqual(short_straight(dice_set), 30)
def test_chance(self):
dice_set = [4, 6, 6, 2, 2]
self.assertEqual(chance(dice_set), 12)