def test_matching_col(self): board1 = tic_tac_toe.Board() board1.boardArr[0] = 'X' board1.boardArr[3] = 'X' board1.boardArr[6] = 'X' self.assertTrue(board1.matching_col('X')) board_no_match = tic_tac_toe.Board() self.assertFalse(board_no_match.matching_col('X')) self.assertFalse(board_no_match.matching_col('O'))
def test_matching_row(self): board1 = tic_tac_toe.Board() board1.boardArr[0] = '0' board1.boardArr[1] = '0' board1.boardArr[2] = '0' self.assertTrue(board1.matching_row('0')) board_no_match = tic_tac_toe.Board() self.assertFalse(board_no_match.matching_row('X')) self.assertFalse(board_no_match.matching_row('O'))
def test_matching_diag(self): board1 = tic_tac_toe.Board() board1.boardArr[0] = 'X' board1.boardArr[4] = 'X' board1.boardArr[8] = 'X' self.assertTrue(board1.matching_diag('X')) board2 = tic_tac_toe.Board() board2.boardArr[2] = 'X' board2.boardArr[4] = 'X' board2.boardArr[6] = 'X' self.assertTrue(board2.matching_diag('X')) board_no_match = tic_tac_toe.Board() self.assertFalse(board_no_match.matching_diag('X')) self.assertFalse(board_no_match.matching_diag('O'))
def test_check_if_marked(self): board = tic_tac_toe.Board() board.index = 0 board.boardArr[0] = 'X' self.assertTrue(board.check_if_marked()) board.index = 8 self.assertFalse(board.check_if_marked())
def test_mark_square(self): board = tic_tac_toe.Board() board.index = 0 board.current_player = 'X' board.mark_square() self.assertEqual(board.boardArr[0], 'X')
def test_check_if_full(self): board = tic_tac_toe.Board() board.print_board() self.assertFalse(board.check_if_full()) for x in range(9): board.boardArr[x] = '0' self.assertTrue(board.check_if_full())