-
Notifications
You must be signed in to change notification settings - Fork 1
/
GameTest.py
39 lines (31 loc) · 1004 Bytes
/
GameTest.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
import unittest
from Game import Game
class TicTacToeTest(unittest.TestCase):
def test_game_draw(self):
game = Game()
board = [['x', 'o', 'x'],
['o', 'x', 'o'],
['o', 'x', 'o']]
game.board = board
self.assertEqual(game.game_state(), 'd')
def test_game_won(self):
game = Game()
board = [['x', 'x', 'o'],
['o', 'o', 'o'],
['o', 'x', 'x']]
game.board = board
self.assertEqual(game.game_state(), 'w')
board = [['x', 'x', 'o'],
['o', 'x', 'o'],
['o', 'o', 'x']]
game.board = board
self.assertEqual(game.game_state(), 'w')
def test_game_ongoing(self):
game = Game()
board = [['x', 'x', 'o'],
['o', '-', 'o'],
['o', 'x', 'x']]
game.board = board
self.assertEqual(game.game_state(), None)
if __name__ == '__main__':
unittest.main()