Exemple #1
0
 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)
Exemple #2
0
 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)
Exemple #3
0
 def testGetLastCellCoordinatesFromIndexInNonSquareMaze(self):
     maze = Maze(37, 17)
     c = maze.getCoordinatesFromIndex(628).toTuple()
     self.assertEqual(c, (36, 16))
Exemple #4
0
 def testGetRandomCellCoordinatesFromIndexInNonSquareMaze(self):
     maze = Maze(42, 16)
     c = maze.getCoordinatesFromIndex(488).toTuple()
     self.assertEqual(c, (26, 11))
Exemple #5
0
 def testGetFirstCellCoordinatesFromIndexInNonSquareMaze(self):
     maze = Maze(3, 55)
     c = maze.getCoordinatesFromIndex(0).toTuple()
     self.assertEqual(c, (0, 0))
Exemple #6
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))
Exemple #7
0
 def testGetCentreCellCoordinatesFromIndex(self):
     maze = Maze(3, 3)
     # getting centre cell, should be (1, 1)
     c = maze.getCoordinatesFromIndex(4).toTuple()
     self.assertEqual(c, (1, 1))
Exemple #8
0
 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))