Пример #1
0
    def test_board_with_no_lines(self):
        board1 = visual_to_board("""
            * * *

            * * *

            * * *
        """)
        self.assertEqual(squares(board1), {1: 0, 2: 0})

        board2 = visual_to_board("""
            *
        """)
        self.assertEqual(squares(board2), {})
Пример #2
0
    def test_board_with_no_lines_forming_squares(self):
        board1 = visual_to_board("""
            *-*
            |
            * *
        """)
        self.assertEqual(squares(board1), {1: 0})

        board2 = visual_to_board("""
            *-*-*-*
            |   |
            * * *-*
              | |
            * *-*-*
            | |   |
            * * *-*
        """)
        self.assertEqual(squares(board2), {1: 0, 2: 0, 3: 0})
Пример #3
0
    def test_identifies_squares_of_size_1(self):
        board1 = visual_to_board("""
            *-*-*
            |
            *-*-*
            | | |
            * *-*
        """)
        self.assertEqual(squares(board1), {1: 1, 2: 0})

        board2 = visual_to_board("""
            * * * *
            | | |
            * *-*-*
              | | |
            *-*-*-*
            | |   |
            *-* * *
        """)
        self.assertEqual(squares(board2), {1: 3, 2: 0, 3: 0})
Пример #4
0
    def test_idenfities_full_board_squares(self):
        board1 = visual_to_board("""
            *-*-*-*
            |     |
            * * * *
            |     |
            * * * *
            |     |
            *-*-*-*
        """)
        self.assertEqual(squares(board1), {1: 0, 2: 0, 3: 1})

        board2 = visual_to_board("""
            *-*-*
            |   |
            * * *
            |   |
            *-*-*
        """)
        self.assertEqual(squares(board2), {1: 0, 2: 1})