def testGetInvalidCellCoordinatesFromIndexInNonSquareMaze(self): maze = Maze(12, 1) with self.assertRaises( IndexError, msg= "`cellIndex` out of range (761263748 not between 0 and 11).", ): _ = maze.getCoordinatesFromIndex(761263748)
def testGetOutOfRangeTooHighCellCoordinatesFromIndex(self): maze = Maze(1, 1) # get too high cell index coordinates with self.assertRaises( IndexError, msg="`cellIndex` out of range (55 not between 0 and 0).", ): _ = maze.getCoordinatesFromIndex(55)
def testGetLastCellCoordinatesFromIndexInNonSquareMaze(self): maze = Maze(37, 17) c = maze.getCoordinatesFromIndex(628).toTuple() self.assertEqual(c, (36, 16))
def testGetRandomCellCoordinatesFromIndexInNonSquareMaze(self): maze = Maze(42, 16) c = maze.getCoordinatesFromIndex(488).toTuple() self.assertEqual(c, (26, 11))
def testGetFirstCellCoordinatesFromIndexInNonSquareMaze(self): maze = Maze(3, 55) c = maze.getCoordinatesFromIndex(0).toTuple() self.assertEqual(c, (0, 0))
def testGetLastCellCoordinatesFromIndex(self): maze = Maze(3, 3) # getting last cell in maze, should be (2, 2) c = maze.getCoordinatesFromIndex(8).toTuple() self.assertEqual(c, (2, 2))
def testGetCentreCellCoordinatesFromIndex(self): maze = Maze(3, 3) # getting centre cell, should be (1, 1) c = maze.getCoordinatesFromIndex(4).toTuple() self.assertEqual(c, (1, 1))
def testGetFirstCellCoordinatesFromIndex(self): maze = Maze(2, 2) # first cell in maze should be (0, 0) c = maze.getCoordinatesFromIndex(0).toTuple() self.assertEqual(c, (0, 0))