-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest_gol.py
32 lines (21 loc) · 1.16 KB
/
test_gol.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
import unittest
from gol import get_next_round_players
class TestGetNextRoundPlayers(unittest.TestCase):
def test_all_dead(self):
self._assert([[0,0,0], [0,0,0], [0,0,0]], [[0,0,0], [0,0,0], [0,0,0]])
def test_one_live(self):
self._assert([[0,0,0], [0,1,0], [0,0,0]], [[0,0,0], [0,0,0], [0,0,0]])
def test_one_live_with_2_lives_neighbours(self):
self._assert([[1,0,0], [0,1,0], [0,0,1]], [[0,0,0], [0,1,0], [0,0,0]])
def test_one_dead_with_3_lives_become_live(self):
self._assert([[0,1,0], [1,1,0], [0,0,0]], [[1,1,0], [1,1,0], [0,0,0]])
def test_one_live_with_4_lives_neighbours(self):
self._assert([[1,1,1], [0,1,0], [0,1,0]], [[1,1,1], [0,0,0], [0,0,0]])
def test_with_4_multi_4_boards(self):
self._assert([[1,1,1,1], [0,1,0,1], [0,1,0,0], [0,0,0,0]],[[1,1,0,1], [0,0,0,1], [0,0,1,0], [0,0,0,0]])
def test_with_4_multi_3_boards(self):
self._assert([[1,1,1,1], [0,1,0,1], [0,1,0,0]],[[1,1,0,1], [0,0,0,1], [0,0,1,0]])
def _assert(self, cur_players, next_players):
self.assertEqual(get_next_round_players(cur_players), next_players)
if __name__ == '__main__':
unittest.main()