Skip to content

Instantly share code, notes, and snippets.

@8Observer8
Created March 30, 2020 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 8Observer8/80e6655538d5c16f5926f7969c7184bd to your computer and use it in GitHub Desktop.
Save 8Observer8/80e6655538d5c16f5926f7969c7184bd to your computer and use it in GitHub Desktop.
import unittest
from grid import grid, is_winner
# python -m unittest discover tests
class TestGridWinner(unittest.TestCase):
def test_first_row_is_winner(self):
grid[0][0] = "x"
grid[0][1] = "x"
grid[0][2] = "x"
self.assertTrue(is_winner("x"))
def test_second_row_is_winner(self):
grid[1][0] = "x"
grid[1][1] = "x"
grid[1][2] = "x"
self.assertTrue(is_winner("x"))
def test_third_row_is_winner(self):
grid[2][0] = "x"
grid[2][1] = "x"
grid[2][2] = "x"
self.assertTrue(is_winner("x"))
def test_first_column_is_winner(self):
grid[0][0] = "x"
grid[1][0] = "x"
grid[2][0] = "x"
self.assertTrue(is_winner("x"))
def test_second_column_is_winner(self):
grid[0][1] = "x"
grid[1][1] = "x"
grid[2][1] = "x"
self.assertTrue(is_winner("x"))
def test_third_column_is_winner(self):
grid[0][2] = "x"
grid[1][2] = "x"
grid[2][2] = "x"
self.assertTrue(is_winner("x"))
def test_fisrt_diagonal_is_winner(self):
grid[0][0] = "x"
grid[1][1] = "x"
grid[2][2] = "x"
self.assertTrue(is_winner("x"))
def test_second_diagonal_is_winner(self):
grid[0][2] = "x"
grid[1][1] = "x"
grid[2][0] = "x"
self.assertTrue(is_winner("x"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment