-
Notifications
You must be signed in to change notification settings - Fork 0
/
Day11-Unittest.py
53 lines (42 loc) · 1.46 KB
/
Day11-Unittest.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
from Day11 import *
from unittest import TestSuite, makeSuite, TextTestRunner, TestCase
class Day11UnitTests(TestCase):
def setUp(self):
self._sut = AdventDayEleven()
def test_IsValidFindsValidStringsProperly(self):
valid_strings = [
'abcdffaa',
'ghjaabcc'
]
for one_string in valid_strings:
self.assertTrue(self._sut.is_valid(one_string))
def test_IsValidFindsBadStringsProperly(self):
invalid_strings = [
'hijklmmn',
'abbceffg',
'abbcegjk'
]
for one_string in invalid_strings:
self.assertFalse(self._sut.is_valid(one_string))
def test_IncrementWorksProperly(self):
test_cases = {
'a': 'b',
'az': 'ba',
'azzz': 'baaa',
'zzzzzzzz': 'aaaaaaaa'
}
for one_string, one_result in test_cases.items():
result = self._sut.increment_string(one_string)
self.assertEqual(one_result, result)
def test_get_next_valid_string_works(self):
test_cases = {
'abcdefgh': 'abcdffaa',
# 'ghijklmn': 'ghjaabcc'
}
for one_string, one_result in test_cases.items():
result = self._sut.get_next_valid_string(one_string)
self.assertEqual(one_result, result)
testSuite = TestSuite()
testSuite.addTest(makeSuite(Day11UnitTests))
runner = TextTestRunner(verbosity=2)
runner.run(testSuite)