예제 #1
0
    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'))
예제 #2
0
    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'))
예제 #3
0
    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'))
예제 #4
0
 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())
예제 #5
0
    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')
예제 #6
0
    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())