Пример #1
0
class test_Board(TestCase):

    def setUp(self):
        self.board = Board()

    def tearDown(self):
        pass

    def test_expand_blanks(self):
        expanded = self.board.expand_blanks("rk4q3")
        self.assertEqual(expanded, 'rk    q   ')
        expanded = self.board.expand_blanks("rkq")
        self.assertEqual(expanded, 'rkq')
        expanded = self.board.expand_blanks("3")
        self.assertEqual(expanded, '   ')

    def test_outer_join(self):
        joined = self.board.outer_join('|', ['1', '2', '3'])
        self.assertEqual(joined, '|1|2|3|')

    def test_draw_chess_board(self):
        fen = "r2q1rk1/pp2ppbp/1np2np1/2Q3B1/3PP1b1/2N2N2/PP3PPP/3RKB1R"
        printable_string = "+-+-+-+-+-+-+-+-+-+\n"\
            "|8|r| | |q| |r|k| |\n"\
            "+-+-+-+-+-+-+-+-+-+\n"\
            "|7|p|p| | |p|p|b|p|\n"\
            "+-+-+-+-+-+-+-+-+-+\n"\
            "|6| |n|p| | |n|p| |\n"\
            "+-+-+-+-+-+-+-+-+-+\n"\
            "|5| | |Q| | | |B| |\n"\
            "+-+-+-+-+-+-+-+-+-+\n"\
            "|4| | | |P|P| |b| |\n"\
            "+-+-+-+-+-+-+-+-+-+\n"\
            "|3| | |N| | |N| | |\n"\
            "+-+-+-+-+-+-+-+-+-+\n"\
            "|2|P|P| | | |P|P|P|\n"\
            "+-+-+-+-+-+-+-+-+-+\n"\
            "|1| | | |R|K|B| |R|\n"\
            "+-+-+-+-+-+-+-+-+-+\n"\
            "|+|A|B|C|D|E|F|G|H|\n"\
            "+-+-+-+-+-+-+-+-+-+\n"
        self.assertEqual(self.board.draw_chess_board(fen), printable_string)
Пример #2
0
 def setUp(self):
     self.board = Board()