-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtests.py
50 lines (35 loc) · 4.07 KB
/
tests.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
from datetime import datetime
import unittest
from lib import *
class MyTest(unittest.TestCase):
def test(self):
start = datetime.now()
lines = []
cols = []
grids = []
# 5
lines.append([ [1, 2], [1, 1, 1], [3], [1, 1], [3] ])
cols.append([ [2, 1], [1], [3, 1], [1, 1, 1], [3] ])
grids.append([[1, 0, 1, 1, 0], [1, 0, 1, 0, 1], [0, 0, 1, 1, 1], [1, 0, 0, 0, 1], [0, 1, 1, 1, 0]])
# 10
lines.append([ [6], [3, 1], [1, 2], [2, 3], [6], [4], [5], [2, 4], [2, 4, 1], [3, 6] ])
cols.append([ [1], [1, 3, 3], [2, 7], [2, 3], [2, 7], [1, 8], [5, 4], [3], [1], [2] ])
grids.append([[0, 1, 1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 0, 1, 0, 0, 0], [0, 1, 0, 0, 0, 1, 1, 0, 0, 0], [0, 1, 1, 0, 1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0, 0], [0, 1, 1, 0, 1, 1, 1, 1, 0, 0], [0, 1, 1, 0, 1, 1, 1, 1, 0, 1], [1, 1, 1, 0, 1, 1, 1, 1, 1, 1]])
# 15
lines.append([ [7], [9], [2, 4, 2], [2, 2], [2, 1, 1, 2], [3, 2], [2, 2], [3, 3, 1], [9, 1], [9, 1], [11, 2], [15], [14], [2, 3, 2], [1, 1, 1, 1, 1, 1, 1] ])
cols.append([ [4], [6, 4], [12, 1], [2, 1, 6], [2, 5, 1], [3, 1, 6], [3, 7], [3, 6], [3, 1, 5, 1], [2, 6], [12, 1], [6, 4], [4], [3], [5] ])
grids.append([[0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0], [0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0], [0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0], [0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1], [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1], [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0]])
# 20
lines.append([ [5], [4], [3, 3], [7, 2], [8, 2], [2, 3, 5], [10], [9, 5], [11, 3], [3, 3, 3, 3], [2, 5, 3, 2], [2, 2, 5, 1], [1, 2, 2, 3], [2, 3, 3], [3, 2, 2], [2, 2, 2], [2, 1], [3], [3], [3] ])
cols.append([ [1], [3], [2, 3], [3, 5], [3, 3, 3], [1, 3, 2, 6], [1, 2, 2, 8], [2, 3, 2, 5], [2, 8], [3, 6, 1], [4, 5, 3], [7, 5], [5, 3], [2, 4], [3, 5, 2], [3, 6], [3, 3], [4], [5], [2] ])
grids.append([[0, 0, 0, 0, 0, 1, 1, 1, 1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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]])
for i in range(len(lines)):
n = len(lines[i])
grid, count = solve_grid(n, lines[i], cols[i])
# print(grid)
# print('Tabela convergiu em {} iterações!'.format(count))
self.assertEqual(grid, grids[i])
end = datetime.now()
print(end-start)
if __name__ == '__main__':
unittest.main()