Add a test case for non connex maps in distance computation

This commit is contained in:
Charles Peyrat 2021-01-10 21:32:58 +01:00
parent 26e66a5796
commit 96bbc5088f
1 changed files with 3 additions and 4 deletions

View File

@ -20,6 +20,9 @@ class TestBroguelike(unittest.TestCase):
m = self.stom(".. ..\n ... ") m = self.stom(".. ..\n ... ")
distance = broguelike.dist(m.tiles, 0, 0, 0, 4) distance = broguelike.dist(m.tiles, 0, 0, 0, 4)
self.assertEqual(distance, 6) self.assertEqual(distance, 6)
m = self.stom(". .")
distance = broguelike.dist(m.tiles, 0, 0, 0, 2)
self.assertEqual(distance, -1)
def is_connex(self, grid: List[List[Tile]]) -> bool: def is_connex(self, grid: List[List[Tile]]) -> bool:
h, w = len(grid), len(grid[0]) h, w = len(grid), len(grid[0])
@ -38,10 +41,6 @@ class TestBroguelike(unittest.TestCase):
m = self.generator.run() m = self.generator.run()
self.assertTrue(self.is_connex(m.tiles)) self.assertTrue(self.is_connex(m.tiles))
def test_doors(self) -> None:
# corridors shouldn't loop back into the room
pass
def test_loops(self) -> None: def test_loops(self) -> None:
m = self.stom(3*".. ..\n") m = self.stom(3*".. ..\n")
self.generator.add_loop(m.tiles, 1, 3) self.generator.add_loop(m.tiles, 1, 3)