def test_load_fen_restores_correct_moves_and_clock(self): game = ChessGame() game.load_fen("8/8/8/8/8/8/8/8 w KQkq - 0 1") self.assertEqual(game.half_move_clock, 0) self.assertEqual(game.full_move_clock, 1) self.assertEqual(game.count, 0) game.load_fen("8/8/8/8/8/8/8/8 b KQkq - 10 15") self.assertEqual(game.half_move_clock, 10) self.assertEqual(game.full_move_clock, 15) self.assertEqual(game.count, 29) game.load_fen("8/8/8/8/8/8/8/8 w - - 20 14") self.assertEqual(game.half_move_clock, 20) self.assertEqual(game.full_move_clock, 14) self.assertEqual(game.count, 26)
def test_load_fen_gives_correct_board(self): game = ChessGame() game.load_fen("8/8/8/8/8/8/8/8 w KQkq - 0 1") for row in range(8): for col in range(8): self.assertEqual(type(game.board[row][col]), Empty) game.load_fen("8/8/1r1R4/8/8/8/8/8 w KQkq - 0 1") self.assertEqual(type(game.board[5][1]), Rook) self.assertEqual(game.board[5][1].color, Color.BLACK) self.assertEqual(type(game.board[5][3]), Rook) self.assertEqual(game.board[5][3].color, Color.WHITE) game.load_fen("8/8/8/8/8/8/8/k7 w KQkq - 0 1") self.assertEqual(type(game.board[0][0]), King) self.assertEqual(game.board[0][0].color, Color.BLACK)