-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_farkle.py
75 lines (51 loc) · 1.71 KB
/
test_farkle.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import pytest
from farkle import Farkle
# This fixture will be shared across the entire module.
@pytest.fixture(scope="module", autouse=True)
def farkle():
global farkle # Use a global variable to store the instance
farkle = Farkle()
# Test for a 1, Three 3s and a 5
def test_dice_combination1():
dice = [1, 2, 3, 3, 3, 5]
assert farkle.score(dice) == 450
# Test for a Three 1s and Three 2s
def test_dice_combination2():
dice = [1, 1, 1, 2, 2, 2]
assert farkle.score(dice) == 1200
# Test for Three 4s, a 6, a 1, a 5
def test_dice_combination3():
dice = [4, 4, 4, 6, 1, 5]
assert farkle.score(dice) == 550
# Test for Three 5s and Three 6s
def test_dice_combination4():
dice = [6, 6, 6, 5, 5, 5]
assert farkle.score(dice) == 1100
# Test Four-of-a-kind (triple score is multiplied by 2)
def test_four_threes():
dice = [3, 3, 3, 3, 1, 5]
assert farkle.score(dice) == 750
# Test Four-of-a-kind (triple score is multiplied by 2)
def test_four_ones():
dice = [1, 1, 1, 1, 5, 5]
assert farkle.score(dice) == 2100
# Test Five-of-a-kind (triple score is multiplied by 4)
def test_five_ones():
dice = [1, 1, 1, 1, 1, 5]
assert farkle.score(dice) == 4050
# Test Five-of-a-kind (triple score is multiplied by 4)
def test_five_six():
dice = [6, 6, 6, 6, 6, 5]
assert farkle.score(dice) == 2450
# Test Six-of-a-kind (triple score is multiplied by 8)
def test_six_six():
dice = [6, 6, 6, 6, 6, 6]
assert farkle.score(dice) == 4800
# Test 'Three Pairs'
def test_three_different_pairs():
dice = [1, 1, 5, 5, 6, 6]
assert farkle.score(dice) == 800
# Test 'Straight'
def test_straight():
dice = [1, 2, 3, 4, 5, 6]
assert farkle.score(dice) == 1200