-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_board.py
50 lines (36 loc) · 842 Bytes
/
test_board.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
from board import Board
import unittest
class TestBoard(unittest.TestCase):
def test_is_a_winner(self):
#test for winner
height=6
width=10
b=Board(height,width,2)
mines=[3,11,15,28]
b.fixed_mines(mines)
for mine in mines:
i=(mine-1)/width
j=(mine-1)%width
b.init_mark_cell(i,j)
self.assertTrue(b.is_a_winner())
#test more marks than real mines
b=Board(height,width,2)
mines=[3,11,15,28]
b.fixed_mines(mines)
mines.append(56)
for mine in mines:
i=(mine-1)/width
j=(mine-1)%width
b.init_mark_cell(i,j)
self.assertFalse(b.is_a_winner())
def test_is_a_loser(self):
height=6
width=10
b=Board(height,width,2)
mines=[3,11,15,28]
b.fixed_mines(mines)
mine=mines[0]
i=(mine-1)/width
j=(mine-1)%width
b.init_uncover_cell(i,j)
self.assertTrue(b.is_a_loser(i,j))