Exemplo n.º 1
0
    def test_flip_pieces(self):
        r = Reversi('''
            - - - - - - - -
            - - - - - - - -
            - - w - w - - -
            - - w w w w - -
            - - w b b b b b
            - - - b b w - -
            - - - w b - - -
            - - w - b - - -
            ''')
        r.flip_pieces('south', 'b', 'D3')
        expected_board = '''
            - - - - - - - -
            - - - - - - - -
            - - w - w - - -
            - - w b w w - -
            - - w b b b b b
            - - - b b w - -
            - - - w b - - -
            - - w - b - - -
           '''
        expected_board = self.strip_leading_spaces(expected_board)
        self.assertEqual(
            expected_board, r.board_string(), "\nExpected: \n" +
            expected_board + "\nActual board: \n" + r.board_string())

        r = Reversi('''
            - - - - - - - -
            - - - - - - - -
            - b b b - - - -
            - - b b b - - -
            - - w w w - - -
            - - - w - - - -
            - - - w - - - -
            - - - - - - - -
            ''')
        r.flip_pieces('south_east', 'w', 'B2')
        expected_board = '''
            - - - - - - - -
            - - - - - - - -
            - b w b - - - -
            - - b w b - - -
            - - w w w - - -
            - - - w - - - -
            - - - w - - - -
            - - - - - - - -
            '''
        expected_board = self.strip_leading_spaces(expected_board)
        self.assertEqual(
            expected_board, r.board_string(), "\nExpected: \n" +
            expected_board + "\nActual board: \n" + r.board_string())

        r = Reversi('''
            - - - b - - - -
            - - b b - - - -
            - b b b - - - -
            - b b w w w w -
            w w w w w w w w
            w b w w w - - -
            - - - w - - - -
            - - - b b b - -
            ''')
        r.flip_pieces('north_west', 'b', 'F6')
        r.flip_pieces('west', 'b', 'F6')
        expected_board = '''
            - - - b - - - -
            - - b b - - - -
            - b b b - - - -
            - b b b w w w -
            w w w w b w w w
            w b b b b - - -
            - - - w - - - -
            - - - b b b - -
            '''
        expected_board = self.strip_leading_spaces(expected_board)
        self.assertEqual(
            expected_board, r.board_string(), "\nExpected: \n" +
            expected_board + "\nActual board: \n" + r.board_string())