-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestCell_numberOfMatesInSpecificState.py
141 lines (110 loc) · 7.03 KB
/
TestCell_numberOfMatesInSpecificState.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
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
import unittest
# from classes.Cell import *
from classes.World import *
from classes.Cell import *
class TestCell_numberOfMatesInSpecificState(unittest.TestCase):
def setUp(self):
self.healthy = 0
self.infected1 = 1
self.infected2 = 2
self.dead = 3
self.cell = Cell()
self.listOfStates = [self.healthy, self.infected1, self.infected2, self.dead]
def mySetUp(self, listOfStates, listOfNumberOfCellInEachState):
listOfCells = []
for i in range(0, len(listOfStates)):
tmp = [Cell(myState = listOfStates[i])] * listOfNumberOfCellInEachState[i]
listOfCells = listOfCells + tmp
return listOfCells
########## -------- FIRST TEST CASES -------- ##########
def testPart1_numberOfMatesInOneState(self):
listOfNumberOfCellInEachState = [2, 0, 0, 0]
listOfCells = self.mySetUp(self.listOfStates, listOfNumberOfCellInEachState)
healthyMates = self.cell.numberOfMatesInSpecificState(listOfCells, self.healthy)
infected1Mates = self.cell.numberOfMatesInSpecificState(listOfCells, self.infected1)
infected2Mates = self.cell.numberOfMatesInSpecificState(listOfCells, self.infected2)
deadMates = self.cell.numberOfMatesInSpecificState(listOfCells, self.dead)
self.assertEqual(healthyMates, listOfNumberOfCellInEachState[0])
self.assertEqual(infected1Mates, listOfNumberOfCellInEachState[1])
self.assertEqual(infected2Mates, listOfNumberOfCellInEachState[2])
self.assertEqual(deadMates, listOfNumberOfCellInEachState[3])
def testPart1_numberOfMatesInTwoStates(self):
listOfNumberOfCellInEachState = [2, 3, 0, 0]
listOfCells = self.mySetUp(self.listOfStates, listOfNumberOfCellInEachState)
healthyMates = self.cell.numberOfMatesInSpecificState(listOfCells, self.healthy)
infected1Mates = self.cell.numberOfMatesInSpecificState(listOfCells, self.infected1)
infected2Mates = self.cell.numberOfMatesInSpecificState(listOfCells, self.infected2)
deadMates = self.cell.numberOfMatesInSpecificState(listOfCells, self.dead)
self.assertEqual(healthyMates, listOfNumberOfCellInEachState[0])
self.assertEqual(infected1Mates, listOfNumberOfCellInEachState[1])
self.assertEqual(infected2Mates, listOfNumberOfCellInEachState[2])
self.assertEqual(deadMates, listOfNumberOfCellInEachState[3])
def testPart1_numberOfMatesInThreeStates(self):
listOfNumberOfCellInEachState = [2, 3, 4, 0]
listOfCells = self.mySetUp(self.listOfStates, listOfNumberOfCellInEachState)
healthyMates = self.cell.numberOfMatesInSpecificState(listOfCells, self.healthy)
infected1Mates = self.cell.numberOfMatesInSpecificState(listOfCells, self.infected1)
infected2Mates = self.cell.numberOfMatesInSpecificState(listOfCells, self.infected2)
deadMates = self.cell.numberOfMatesInSpecificState(listOfCells, self.dead)
self.assertEqual(healthyMates, listOfNumberOfCellInEachState[0])
self.assertEqual(infected1Mates, listOfNumberOfCellInEachState[1])
self.assertEqual(infected2Mates, listOfNumberOfCellInEachState[2])
self.assertEqual(deadMates, listOfNumberOfCellInEachState[3])
def testPart1_numberOfMatesInFourStates(self):
listOfNumberOfCellInEachState = [2, 3, 4, 5]
listOfCells = self.mySetUp(self.listOfStates, listOfNumberOfCellInEachState)
healthyMates = self.cell.numberOfMatesInSpecificState(listOfCells, self.healthy)
infected1Mates = self.cell.numberOfMatesInSpecificState(listOfCells, self.infected1)
infected2Mates = self.cell.numberOfMatesInSpecificState(listOfCells, self.infected2)
deadMates = self.cell.numberOfMatesInSpecificState(listOfCells, self.dead)
self.assertEqual(healthyMates, listOfNumberOfCellInEachState[0])
self.assertEqual(infected1Mates, listOfNumberOfCellInEachState[1])
self.assertEqual(infected2Mates, listOfNumberOfCellInEachState[2])
self.assertEqual(deadMates, listOfNumberOfCellInEachState[3])
########## -------- SECOND TEST CASES -------- ##########
def testPart2_numberOfMatesInOneState(self):
listOfNumberOfCellInEachState = [8, 0, 0, 0]
listOfCells = self.mySetUp(self.listOfStates, listOfNumberOfCellInEachState)
healthyMates = self.cell.numberOfMatesInSpecificState(listOfCells, self.healthy)
infected1Mates = self.cell.numberOfMatesInSpecificState(listOfCells, self.infected1)
infected2Mates = self.cell.numberOfMatesInSpecificState(listOfCells, self.infected2)
deadMates = self.cell.numberOfMatesInSpecificState(listOfCells, self.dead)
self.assertEqual(healthyMates, listOfNumberOfCellInEachState[0])
self.assertEqual(infected1Mates, listOfNumberOfCellInEachState[1])
self.assertEqual(infected2Mates, listOfNumberOfCellInEachState[2])
self.assertEqual(deadMates, listOfNumberOfCellInEachState[3])
def testPart2_numberOfMatesInTwoStates(self):
listOfNumberOfCellInEachState = [7, 6, 0, 0]
listOfCells = self.mySetUp(self.listOfStates, listOfNumberOfCellInEachState)
healthyMates = self.cell.numberOfMatesInSpecificState(listOfCells, self.healthy)
infected1Mates = self.cell.numberOfMatesInSpecificState(listOfCells, self.infected1)
infected2Mates = self.cell.numberOfMatesInSpecificState(listOfCells, self.infected2)
deadMates = self.cell.numberOfMatesInSpecificState(listOfCells, self.dead)
self.assertEqual(healthyMates, listOfNumberOfCellInEachState[0])
self.assertEqual(infected1Mates, listOfNumberOfCellInEachState[1])
self.assertEqual(infected2Mates, listOfNumberOfCellInEachState[2])
self.assertEqual(deadMates, listOfNumberOfCellInEachState[3])
def testPart2_numberOfMatesInThreeStates(self):
listOfNumberOfCellInEachState = [11, 25, 33, 0]
listOfCells = self.mySetUp(self.listOfStates, listOfNumberOfCellInEachState)
healthyMates = self.cell.numberOfMatesInSpecificState(listOfCells, self.healthy)
infected1Mates = self.cell.numberOfMatesInSpecificState(listOfCells, self.infected1)
infected2Mates = self.cell.numberOfMatesInSpecificState(listOfCells, self.infected2)
deadMates = self.cell.numberOfMatesInSpecificState(listOfCells, self.dead)
self.assertEqual(healthyMates, listOfNumberOfCellInEachState[0])
self.assertEqual(infected1Mates, listOfNumberOfCellInEachState[1])
self.assertEqual(infected2Mates, listOfNumberOfCellInEachState[2])
self.assertEqual(deadMates, listOfNumberOfCellInEachState[3])
def testPart2_numberOfMatesInFourStates(self):
listOfNumberOfCellInEachState = [155, 478, 1125, 44]
listOfCells = self.mySetUp(self.listOfStates, listOfNumberOfCellInEachState)
healthyMates = self.cell.numberOfMatesInSpecificState(listOfCells, self.healthy)
infected1Mates = self.cell.numberOfMatesInSpecificState(listOfCells, self.infected1)
infected2Mates = self.cell.numberOfMatesInSpecificState(listOfCells, self.infected2)
deadMates = self.cell.numberOfMatesInSpecificState(listOfCells, self.dead)
self.assertEqual(healthyMates, listOfNumberOfCellInEachState[0])
self.assertEqual(infected1Mates, listOfNumberOfCellInEachState[1])
self.assertEqual(infected2Mates, listOfNumberOfCellInEachState[2])
self.assertEqual(deadMates, listOfNumberOfCellInEachState[3])
if __name__ == '__main__':
unittest.main()