Ejemplo n.º 1
0
    def test_get_winner_computer_top_row_O_returns_1(self):
        self.grid[0] = "O"
        self.grid[1] = "O"
        self.grid[2] = "O"

        winner = tictactoe.get_winner(self.grid, "O")

        self.assertEqual(winner, 1)
Ejemplo n.º 2
0
    def test_get_winner_player_top_row_O_returns_neg_1(self):
        self.grid[0] = "O"
        self.grid[1] = "O"
        self.grid[2] = "O"

        winner = tictactoe.get_winner(self.grid, "X")

        self.assertEqual(winner, -1)
Ejemplo n.º 3
0
    def test_get_winner_with_empty_cells_returns_none(self):
        grid = tictactoe.create_grid()

        winner = tictactoe.get_winner(grid, "X")

        self.assertIsNone(winner)
Ejemplo n.º 4
0
    def test_get_winner_with_full_grid_and_no_combo_returns_0(self):
        winner = tictactoe.get_winner(self.grid, "X")

        self.assertEqual(winner, 0)
Ejemplo n.º 5
0
def test_get_winner():
    """Test get_winner"""

    assert get_winner('XXX......') == 'X'
    assert get_winner('O..O..O..') == 'O'
    assert get_winner('...O..X..') == ''