-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_rules.py
29 lines (21 loc) · 962 Bytes
/
test_rules.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
import unittest
from rules import ConwayRules, StandardRules
class RulesTest(unittest.TestCase):
def assertSurvival(self, rules, live_neighbors):
map(lambda it: self.assertEqual(it in live_neighbors, rules.survives(it)), range(9))
def assertBirth(self, rules, live_neighbors):
map(lambda it: self.assertEqual(it in live_neighbors, rules.born(it)), range(9))
def test_ConwayRules(self):
self.assertEqual("R 23/3", ConwayRules.__str__())
self.assertSurvival(ConwayRules, {2, 3})
self.assertBirth(ConwayRules, {3})
def test_Equality(self):
rules1 = StandardRules(set(), set())
rules2 = StandardRules(set(), set())
self.assertEqual(rules1, rules2)
def test_InEquality(self):
rules1 = StandardRules(set(), set())
rules2 = StandardRules({1}, set())
self.assertNotEqual(rules1, rules2)
if __name__ == '__main__': # pragma: no cover
unittest.main()