-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_solver.py
38 lines (34 loc) · 1.2 KB
/
test_solver.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
import unittest
from solver import flood_fill
class TestSolver(unittest.TestCase):
def test_flood_fill_simple(self):
self.assertEqual(flood_fill([[1,2,1]] , 1, 3, 0, 1, 3), [[1,3,1]] )
self.assertEqual(flood_fill([[2,2,2]] , 1, 3, 0, 1, 3), [[3,3,3]] )
self.assertEqual(flood_fill([[1],[2],[1]], 3, 1, 1, 0, 3), [[1],[3],[1]])
self.assertEqual(flood_fill([[2],[2],[2]], 3, 1, 1, 0, 3), [[3],[3],[3]])
#@unittest.skip("")
def test_flood_fill_complete(self):
lines, columns, x, y, k = 8, 8, 4, 4, 3
screen = [
[1, 1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 0, 0],
[1, 0, 0, 1, 1, 0, 1, 1],
[1, 2, 2, 2, 2, 0, 1, 0],
[1, 1, 1, 2, 2, 0, 1, 0],
[1, 1, 1, 2, 2, 2, 2, 0],
[1, 1, 1, 1, 1, 2, 1, 1],
[1, 1, 1, 1, 1, 2, 2, 1]
]
expected_output = [
[1, 1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 0, 0],
[1, 0, 0, 1, 1, 0, 1, 1],
[1, 3, 3, 3, 3, 0, 1, 0],
[1, 1, 1, 3, 3, 0, 1, 0],
[1, 1, 1, 3, 3, 3, 3, 0],
[1, 1, 1, 1, 1, 3, 1, 1],
[1, 1, 1, 1, 1, 3, 3, 1]
]
self.assertEqual(flood_fill(screen, lines, columns, x, y, k), expected_output)
if __name__ == "__main__":
unittest.main()