-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_board.py
More file actions
executable file
·38 lines (25 loc) · 1.08 KB
/
test_board.py
File metadata and controls
executable file
·38 lines (25 loc) · 1.08 KB
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 board import Board
class TestBoard(unittest.TestCase):
def setUp(self):
self.board = Board()
self.emptyBoard = Board()
## this is bs - why is it only able to use a single board?
def test_new_board_has_empties(self):
self.assertTrue(self.emptyBoard.hasEmpties())
def test_new_board_fully_empty(self):
self.board = Board()
print "number of empties = " + `len(self.emptyBoard.empties())`
self.assertTrue(len(self.emptyBoard.empties()) == 9)
def test_three_in_a_row_wins(self):
self.assertTrue(self.board.win(['X', 'X', 'X']))
def test_unmatched_three_in_a_row_doesnt_win(self):
self.assertFalse(self.board.win(['X', 'O', 'X']))
def test_incomplete_three_doesnt_win(self):
self.assertFalse(self.board.win([' ', 'O', 'X']))
def test_indexes_win_game(self):
for i in self.board.row[0]:
self.board.squares[i] = 'k'
self.assertTrue(self.board.trio_wins(self.board.squares, self.board.row[0]))
if __name__ == '__main__':
unittest.main()