Esempio n. 1
0
 def test_game_won_with_no_win(self):
     """
     If the game has not been won by a player yet, the function should return false.
     """
     board = Board()
     board.set_square(7, 'O')
     board.set_square(5, 'X')
     board.set_square(3, 'O')
     self.assertFalse(board.game_won())
Esempio n. 2
0
 def test_game_won_with_win(self):
     """
     If a player has 3 pieces in a line, the game should be won and the function should return true. The board's
     winner_piece variable should also be set to the winner's piece.
     """
     board = Board()
     # make sure board's winner_piece variable is initially None
     self.assertIsNone(board.winner_piece)
     board.set_square(7, 'O')
     board.set_square(5, 'X')
     board.set_square(3, 'O')
     board.set_square(8, 'X')
     board.set_square(1, 'O')
     board.set_square(4, 'X')
     board.set_square(2, 'O')
     self.assertTrue(board.game_won())
     self.assertEqual('O', board.winner_piece)