def test_checkUpUp(self): board = tictactoe.CheckerBox(3) board.board = ["", "X", "O", "", "X", "O", "", "X", ""] board.count = 5 #Should fail because there are no grids above grid 2 result = board.checkUpUp(2) self.assertEqual(result, False) #Should fail because there is only 1 grid above grid 5 result = board.checkUpUp(5) self.assertEqual(result, False) # Should pass because there are 2 grids and there is a match result = board.checkUpUp(8) self.assertEqual(result, True) board.board = ["", "X", "O", "", "X", "O", "X", "", ""] # Should fail because there is no match along grid 8 result = board.checkUpUp(8) self.assertEqual(result, False)
def test_checkDiagRightUpRightUp(self): board = tictactoe.CheckerBox(3) board.board = ["", "O", "X", "", "X", "", "X", "O", ""] board.count = 5 #Should fail because there are no grids up or right result = board.checkDiagRightUpRightUp(3) self.assertEqual(result, False) #Should fail because there is only 1 grid up and 1 grid to the right result = board.checkDiagRightUpRightUp(5) self.assertEqual(result, False) # Should pass because there are at least 2 grids up and 2 grids to the right result = board.checkDiagRightUpRightUp(7) self.assertEqual(result, True) board.board = ["", "O", "X", "O", "X", "", "", "O", "X"] # Should fail because there is no match along grid 9 to the left diagonal result = board.checkDiagRightUpRightUp(5) self.assertEqual(result, False)
def test_checkDiagLeftDownLeftDown(self): board = tictactoe.CheckerBox(3) board.board = ["", "O", "X", "", "X", "", "X", "O", ""] board.count = 5 #Should pass because there are at least 2 grids left and 2 grids down result = board.checkDiagLeftDownLeftDown(3) self.assertEqual(result, True) #Should fail because there is only 1 grid left and 1 grid down result = board.checkDiagLeftDownLeftDown(5) self.assertEqual(result, False) # Should fail because there are no grids down or no grids left result = board.checkDiagRightUpLeftDown(7) self.assertEqual(result, False) board.board = ["", "O", "X", "O", "X", "", "", "O", "X"] # Should fail because there is no match along grid 5 to the right diagonal result = board.checkDiagRightUpLeftDown(5) self.assertEqual(result, False)
def test_checkDiagRightDownRightDown(self): board = tictactoe.CheckerBox(3) board.board = ["X", "O", "", "", "X", "", "", "O", "X"] board.count = 5 #Should pass because there is at least 2 grids to the right, 2 grids down result = board.checkDiagRightDownRightDown(1) self.assertEqual(result, True) #Should fail because there is only 1 grid down and 1 grid right result = board.checkDiagRightDownRightDown(5) self.assertEqual(result, False) # Should fail because there are no grids to the right or down result = board.checkDiagRightDownRightDown(9) self.assertEqual(result, False) board.board = ["", "O", "X", "O", "X", "", "", "O", "X"] # Should fail because there is no match along grid 1 to the right result = board.checkDiagRightDownRightDown(1) self.assertEqual(result, False)
def test_checkDiagLeftUpRightDown(self): board = tictactoe.CheckerBox(3) board.board = ["X", "O", "", "", "X", "", "", "O", "X"] board.count = 5 #Should fail because there are no grids up or left result = board.checkDiagLeftUpRightDown(1) self.assertEqual(result, False) #Should pass because there is at least 1 grid up, 1 grid left, 1 grid down, 1 grid right result = board.checkDiagLeftUpRightDown(5) self.assertEqual(result, True) # Should fail because there are no grids to the right or down result = board.checkDiagLeftUpRightDown(9) self.assertEqual(result, False) board.board = ["", "O", "X", "O", "X", "", "", "O", "X"] # Should fail because there is no match along grid 9 to the left diagonal result = board.checkDiagLeftUpLeftUp(5) self.assertEqual(result, False)
def test_checkRightRight(self): board = tictactoe.CheckerBox(3) board.board = ["", "O", "", "X", "X", "X", "", "O", ""] board.count = 5 #Should pass because there are 2 grids to the right on grid 4 result = board.checkRightRight(4) self.assertEqual(result, True) #Should fail because there is only 1 grid to the right of grid 5 result = board.checkRightRight(5) self.assertEqual(result, False) # Should fail because there are no grids to the right on grid 6 result = board.checkRightRight(6) self.assertEqual(result, False) board.board = ["", "O", "X", "O", "X", "X", "", "O", ""] # Should fail because there is no match along grid 4 to the left and right result = board.checkRightRight(4) self.assertEqual(result, False)
def test_GridChecker(self): board = tictactoe.CheckerBox(3) result = board.isGridValid(9) self.assertEqual(result, True)
def test_checkTie(self): board = tictactoe.CheckerBox(3) board.board = ["X", "X", "O", "O", "O", "X", "X", "O", "X"] board.count = 9 result = board.isThereAMatch(5) self.assertEqual(result, False)
def test_checkMatch(self): board = tictactoe.CheckerBox(3) board.board = ["X", "X", "X", "O", "O", "O", "", "", ""] board.count = 6 result = board.isThereAMatch(1) self.assertEqual(result, True)
def test_addValidSymbolPlayer2(self): board = tictactoe.CheckerBox(3) board.placeGrid(1) board.count = 1 board.placeGrid(1) self.assertEqual(["X", "", "", "", "", "", "", "", ""], board.board)
def test_addSymbolPlayer1(self): board = tictactoe.CheckerBox(3) board.placeGrid(0) self.assertEqual(["", "", "", "", "", "", "", "", ""], board.board)
def test_validUserInput(self, input): board = tictactoe.CheckerBox(3) result = board.playRound() self.assertEqual(result, True) self.assertEqual(board.count, 1) self.assertEqual(["X", "", "", "", "", "", "", "", ""], board.board)
def test_invalidInputMax(self, input): board = tictactoe.CheckerBox(3) result = board.playRound() self.assertEqual(result, False)