コード例 #1
0
ファイル: test_game.py プロジェクト: mrdavidoneill/chess
 def test_whose_move(self):
     """ Test for whose_move """
     game = Game()
     game.move_count = 0
     self.assertEqual(game.whose_move(), WHITE)
     game.move_count = 1
     self.assertEqual(game.whose_move(), BLACK)
コード例 #2
0
ファイル: test_game.py プロジェクト: mrdavidoneill/chess
    def test_in_check(self):
        """ Test for in_check() """
        game = Game()
        game.board.clear_board()
        game.castling_rights = ["", "", "", ""]
        game.board.place_piece("K", "B1")
        game.board.place_piece("q", "B2")
        game.board.place_piece("k", "B3")
        self.assertEqual(game.in_check(WHITE), True)
        self.assertEqual(game.in_check(BLACK), False)

        game.board.clear_board()
        game.board.place_piece("K", "E1")
        game.board.place_piece("p", "D2")
        self.assertEqual(game.in_check(WHITE), True)

        game.board.clear_board()
        game.board.place_piece("K", "E3")
        game.board.place_piece("p", "D2")
        self.assertEqual(game.in_check(WHITE), False)

        game.board.clear_board()
        game.board.place_piece("K", "E1")
        game.board.place_piece("p", "D2")
        self.assertEqual(game.in_check(WHITE), True)

        game.board.clear_board()
        game.board.place_piece("k", "E3")
        game.board.place_piece("P", "D2")
        game.move_count = 1
        self.assertEqual(game.in_check(BLACK), True)
        game.move_count = 0

        game.board.clear_board()
        game.board.place_piece("k", "E3")
        game.board.place_piece("P", "D4")
        self.assertEqual(game.in_check(BLACK), False)

        game.board.clear_board()
        game.board.place_piece("k", "E3")
        game.board.place_piece("P", "E2")
        self.assertEqual(game.in_check(BLACK), False)

        game.board.clear_board()
        game.board.place_piece("k", "B1")
        game.board.place_piece("K", "B3")
        self.assertEqual(game.in_check(WHITE), False)