def test_can_tie_on_empty_square_board(self): """Test whether _can_tie function returns that a player can tie on an empty square board.""" # Create empty tic-tac-toe game board board = TicTacToeBoard() # A perfect player is guaranteed to tie on an empty board self.assertTrue(board._can_tie(1)) self.assertTrue(board._can_tie(2))
def test_can_tie_on_non_empty_square_board_you_lost(self): """Test whether _can_tie function returns that a player cannot tie a non-empty square board that they lost.""" # Create non-empty tic-tac-toe game board that player 1 has won board = TicTacToeBoard() board.matrix[0] = [1, 0, 0] board.matrix[1] = [2, 1, 0] board.matrix[2] = [0, 2, 1] self.assertFalse(board._can_tie(2)) # Test another similar board board = TicTacToeBoard() board.matrix[0] = [1, 0, 0] board.matrix[1] = [1, 2, 0] board.matrix[2] = [1, 2, 0] self.assertFalse(board._can_tie(2)) # Test another similar board board = TicTacToeBoard() board.matrix[0] = [1, 1, 1] board.matrix[1] = [0, 2, 0] board.matrix[2] = [0, 2, 0] self.assertFalse(board._can_tie(2)) # Test another similar board board = TicTacToeBoard() board.matrix[0] = [0, 2, 1] board.matrix[1] = [0, 1, 0] board.matrix[2] = [1, 2, 0] self.assertFalse(board._can_tie(2)) # Create non-empty tic-tac-toe game board that player 2 has won board = TicTacToeBoard() board.matrix[0] = [2, 0, 0] board.matrix[1] = [1, 2, 0] board.matrix[2] = [0, 1, 2] self.assertFalse(board._can_tie(1)) # Test another similar board board = TicTacToeBoard() board.matrix[0] = [2, 0, 0] board.matrix[1] = [2, 1, 0] board.matrix[2] = [2, 1, 0] self.assertFalse(board._can_tie(1)) # Test another similar board board = TicTacToeBoard() board.matrix[0] = [2, 2, 2] board.matrix[1] = [0, 1, 0] board.matrix[2] = [0, 1, 0] self.assertFalse(board._can_tie(1)) # Test another similar board board = TicTacToeBoard() board.matrix[0] = [0, 1, 2] board.matrix[1] = [0, 2, 0] board.matrix[2] = [2, 1, 0] self.assertFalse(board._can_tie(1))