def testAddWallToNonExistentCell(self): maze = Maze(2, 2) with self.assertRaises( IndexError, msg="`cellIndex` out of range (55 not between 0 and 3).", ): maze.addWallBetween(2, 55)
def testAddWallBetweenNonAdjacentCells(self): maze = Maze(3, 3) # add invalid wall between top left and bottom right cells with self.assertRaises( ValueError, msg="Cell at index 0 is not adjacent to cell at 8.", ): maze.addWallBetween(0, 8)
def testAddWallAgain(self): maze = Maze(4, 4, False) # add a wall from first cell maze.addWallBetween(0, 1) self.assertCountEqual(maze.getConnectionsOfCellAtIndex(0), [4]) # add another wall from first cell maze.addWallBetween(0, 4) self.assertCountEqual(maze.getConnectionsOfCellAtIndex(0), [])
def testAddWallBetweenSelf(self): maze = Maze(2, 2) # add a wall between `x` and `x`, i.e., to itself with self.assertRaises( Exception, msg= "Node index 0 already does not exist in node at index 0's connections.", ): maze.addWallBetween(0, 0)
def testAddExistentWall(self): maze = Maze(3, 3, True) # add a wall that already exists with self.assertRaises( Exception, msg= "Node index 1 already does not exist in node at index 0's connections.", ): maze.addWallBetween(0, 1)