Exemple #1
0
    def test_is_walls_between(self):
        """Test the Cell::is_walls_between method

            Note that cells are constructed with neighbors on each side.
            We'll need to remove some walls to get full coverage.
        """

        # We should have walls on all sides of a new cell
        cell = Cell (0, 0)
        self.assertEqual(cell.walls, {"top": True, "right": True, "bottom": True, "left": True})

        # Remove the wall to the right
        cell2 = Cell(1, 0)
        cell2.remove_walls(1, 2)
        self.assertEqual(cell.walls, {"top": True, "right": False, "bottom": True, "left": True})

        # Remove the wall to the left
        cell3 = Cell(0, 2)
        cell3.remove_walls(0, 1)
        self.assertEqual(cell.walls, {"top": True, "right": True, "bottom": True, "left": False})

        # Remove the wall on the top
        cell4 = Cell(1, 2)
        cell4.remove_walls(0, 2)
        self.assertEqual(cell.walls, {"top": False, "right": True, "bottom": True, "left": True})

        # Remove the wall on the bottom
        cell5 = Cell(2, 2)
        cell5.remove_walls(3, 2)
        self.assertEqual(cell.walls, {"top": True, "right": True, "bottom": False, "left": True})
Exemple #2
0
    def test_remove_walls(self):
        """Test the Cell::remove_walls method"""
        # Remove the cell to the right
        cell = Cell(0, 0)
        cell.remove_walls(0,1)
        self.assertEqual(cell.walls["right"], False)

        # Remove the cell to the left
        cell = Cell(0, 1)
        cell.remove_walls(1, 0)
        self.assertEqual(cell.walls["left"], False)

        # Remove the cell above
        cell = Cell(1, 1)
        cell.remove_walls(0, 1)
        self.assertEqual(cell.walls["top"], False)

        # Remove the cell below
        cell = Cell(1, 1)
        cell.remove_walls(2, 1)
        self.assertEqual(cell.walls["bottom"], False)