-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestFile.py
More file actions
121 lines (106 loc) · 2.59 KB
/
testFile.py
File metadata and controls
121 lines (106 loc) · 2.59 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
from Card import Card
from PlayerHand import PlayerHand
def test_isEmpty():
hand = PlayerHand()
assert hand.isEmpty() == True
assert hand.getTotalCards() == 0
hand.put('D','A')
assert hand.getTotalCards() == 1
hand.put('C','7')
hand.put('S','K')
assert hand.getTotalCards() == 3
assert hand.isEmpty() == False
def test_getTotalCards():
hand = PlayerHand()
hand.put('D', '7')
hand.put('D', '4')
hand.put('D', '5')
hand.put('C', '3')
assert hand.getTotalCards() == 4
def test_deleteRoot():
hand = PlayerHand()
hand.put('D', '7')
hand.put('D', '4')
hand.put('D', '5')
hand.put('C', '3')
hand.put('C', '2')
hand.put('H', '9')
hand.put('H', '8')
hand.put('S', 'K')
assert hand.getTotalCards() == 8
hand.delete('D', '7')
assert hand.getTotalCards() == 7
assert hand.isEmpty() == False
def test_deleteLeafNode():
hand = PlayerHand()
hand.put('D', '7')
hand.put('D', '4')
hand.put('D', '5')
hand.put('C', '3')
hand.put('C', '2')
hand.put('H', '9')
hand.put('H', '8')
hand.put('S', 'K')
hand.delete('C', '2')
def test_duplicateCards():
hand = PlayerHand()
hand.put('D', 'A')
hand.put('S', '7')
assert hand.getTotalCards() == 2
assert hand.preOrder() == \
"D A | 1\n\
S 7 | 1\n"
def test_inOrder():
hand = PlayerHand()
hand.put('D', 'A')
hand.put('S', 'K')
hand.put('S', '2')
hand.put('C', 'Q')
hand.put('H', '7')
hand.put('S', 'K')
hand.put('C', 'K')
assert hand.inOrder() == \
"D A | 1\n\
S 2 | 1\n\
H 7 | 1\n\
C Q | 1\n\
C K | 1\n\
S K | 2\n"
hand.delete('D', 'A')
assert hand.getTotalCards() == 6
assert hand.isEmpty() == False
def test_getSuccessor():
hand = PlayerHand()
hand.put('D', 'A')
hand.put('S', 'K')
hand.put('S', '2')
hand.put('C', 'Q')
hand.put('H', '7')
hand.put('S', 'K')
hand.put('C', 'K')
assert hand.getTotalCards() == 7
assert hand.isEmpty() == False
hand.delete('S', '2')
assert hand.getTotalCards() == 6
assert hand.getSuccessor('H', '7') == None
assert hand.getSuccessor('S', 'K') == None
assert hand.getSuccessor('D', 'A') == 'S K | 2'
def test_delTwoChildren():
hand = PlayerHand()
hand.put('D', '8')
hand.put('D', '6')
hand.put('D', '5')
hand.put('D', '7')
hand.put('D', '9')
assert hand.inOrder() == \
"D 5 | 1\n\
D 6 | 1\n\
D 7 | 1\n\
D 8 | 1\n\
D 9 | 1\n"
hand.delete('D', '6')
assert hand.inOrder() == \
"D 5 | 1\n\
D 7 | 1\n\
D 8 | 1\n\
D 9 | 1\n"