-
Notifications
You must be signed in to change notification settings - Fork 0
/
starbattle_test.py
63 lines (53 loc) · 1.7 KB
/
starbattle_test.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
54
55
56
57
58
59
60
61
62
63
from main import parse_file
from starbattle import verify_solution
def test_get_cells():
filename = "games/beginner/beginner-2.txt"
cells, num_stars = parse_file(filename)
assert num_stars == 1
assert cells == [[0,0,1,1,1],
[0,0,1,2,2],
[3,3,1,2,2],
[3,3,3,2,4],
[3,3,4,4,4]]
def test_verify_simple():
matrix = [[0]]
solution = [[1]]
assert verify_solution(1, matrix, solution)[0]
solution2 = [[0]]
assert not verify_solution(1, matrix, solution2)[0]
def test_verify_5():
matrix = [[0,0,1,1,1],
[0,0,1,2,2],
[3,3,1,2,2],
[3,3,3,2,4],
[3,3,4,4,4]]
solution = [[0,0,0,0,1],
[0,1,0,0,0],
[0,0,0,1,0],
[1,0,0,0,0],
[0,0,1,0,0]]
assert verify_solution(1, matrix, solution)[0]
solution2 = [[0,0,0,0,1],
[0,1,0,0,0],
[0,0,0,1,0],
[1,0,0,0,0],
[0,0,0,1,0]]
assert not verify_solution(1, matrix, solution2)[0]
solution3 = [[0,1,0,0,1],
[0,0,0,0,0],
[0,0,0,1,0],
[1,0,0,0,0],
[0,0,1,0,0]]
assert not verify_solution(1, matrix, solution3)[0]
solution4 = [[0,0,0,0,1],
[0,0,1,0,0],
[1,0,0,0,0],
[0,0,0,1,0],
[0,1,0,0,0]]
assert not verify_solution(1, matrix, solution4)[0]
solution5 = [[0,0,0,0,1],
[0,1,0,0,0],
[1,0,0,0,0],
[0,0,0,1,0],
[0,0,1,0,0]]
assert not verify_solution(1, matrix, solution5)[0]