-
Notifications
You must be signed in to change notification settings - Fork 0
/
deck_test.py
58 lines (42 loc) · 1.39 KB
/
deck_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
import sys
from deck import Deck, combine_decks
def get_cards():
return list(range(52))
if __name__ == '__main__':
test_failed = False
card_list = get_cards()
deck = Deck(card_list)
try:
assert(len(deck) == len(card_list))
except AssertionError:
test_failed = True
print('Initial Deck Wrong Length')
try:
assert(set(deck.get_card_list()) == set(card_list))
except AssertionError:
test_failed = True
print('Initial Deck Wrong Cards')
deck_1, deck_2 = deck.split_deck(len(card_list)//2)
try:
assert(len(deck_1) + len(deck_2) == len(deck))
except AssertionError:
test_failed = True
print('Length of Split Decks Incorrect')
try:
assert(set(deck_1.get_card_list()) | set(deck_2.get_card_list()) == set(deck.get_card_list()))
except AssertionError:
test_failed = True
print('Card list of split decks incorrect')
new_deck = combine_decks(deck_1, deck_2)
try:
assert(len(new_deck) == len(deck))
except AssertionError:
test_failed = True
print('Length of combined deck incorrect')
try:
assert(set(new_deck.get_card_list()) == set(card_list))
except AssertionError:
test_failed = True
print('card list of combined deck incorrect.')
if not test_failed:
print('Congrats -- all tests passed!')