-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_get_hand_value.py
79 lines (53 loc) · 2.24 KB
/
test_get_hand_value.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
76
77
"""Test blackjack.get_hand_value"""
import cards
import blackjack
def test_get_hand_value_when_two_cards():
hand = []
twoClubs = cards.Card(cards.CLUBS, cards.TWO)
hand.append(twoClubs)
tenSpades = cards.Card(cards.SPADES, cards.TEN)
hand.append(tenSpades)
assert blackjack.get_hand_value(hand) == 12
def test_get_hand_value_when_one_ace_causes_bust():
hand = []
hand.append(cards.Card(cards.DIAMONDS, cards.TWO))
hand.append(cards.Card(cards.SPADES, cards.ACE))
hand.append(cards.Card(cards.HEARTS, cards.ACE))
assert blackjack.get_hand_value(hand) == 14
def test_get_hand_value_when_ace_does_not_bust():
hand = []
hand.append(cards.Card(cards.DIAMONDS, cards.TWO))
hand.append(cards.Card(cards.SPADES, cards.ACE))
assert blackjack.get_hand_value(hand) == 13
def test_get_hand_value_when_ace_would_bust():
hand = []
hand.append(cards.Card(cards.SPADES, cards.THREE))
hand.append(cards.Card(cards.DIAMONDS, cards.ACE))
hand.append(cards.Card(cards.SPADES, cards.JACK))
assert blackjack.get_hand_value(hand) == 14
def test_get_hand_value_when_four_aces_would_bust():
hand = []
hand.append(cards.Card(cards.SPADES, cards.ACE))
hand.append(cards.Card(cards.DIAMONDS, cards.ACE))
hand.append(cards.Card(cards.HEARTS, cards.ACE))
hand.append(cards.Card(cards.HEARTS, cards.TWO))
hand.append(cards.Card(cards.SPADES, cards.JACK))
hand.append(cards.Card(cards.CLUBS, cards.ACE))
assert blackjack.get_hand_value(hand) == 16
def test_get_hand_value_when_ace_jack():
hand = []
hand.append(cards.Card(cards.DIAMONDS, cards.ACE))
hand.append(cards.Card(cards.SPADES, cards.JACK))
assert blackjack.get_hand_value(hand) == 21
def test_get_hand_value_when_ace_ten():
hand = []
hand.append(cards.Card(cards.DIAMONDS, cards.ACE))
hand.append(cards.Card(cards.SPADES, cards.TEN))
assert blackjack.get_hand_value(hand) == 21
def test_get_hand_value_that_busted():
hand = []
hand.append(cards.Card(cards.DIAMONDS, cards.EIGHT))
hand.append(cards.Card(cards.SPADES, cards.THREE))
hand.append(cards.Card(cards.SPADES, cards.NINE))
hand.append(cards.Card(cards.SPADES, cards.TWO))
assert blackjack.get_hand_value(hand) == 22