squirrel-battle/dungeonbattle/tests/interfaces_test.py
2020-11-06 16:13:28 +01:00

34 lines
993 B
Python

import unittest
from dungeonbattle.interfaces import Map, Tile
class TestInterfaces(unittest.TestCase):
def test_map(self) -> None:
"""
Create a map and check that it is well parsed.
"""
m = Map.load_from_string(".█\n█.\n")
self.assertEqual(m.width, 2)
self.assertEqual(m.height, 2)
self.assertEqual(m.draw_string(), ".█\n█.")
def test_load_map(self) -> None:
"""
Try to load a map from a file.
"""
m = Map.load("example_map.txt")
self.assertEqual(m.width, 52)
self.assertEqual(m.height, 17)
def test_tiles(self) -> None:
"""
Test some things about tiles.
"""
self.assertFalse(Tile.FLOOR.is_wall())
self.assertTrue(Tile.WALL.is_wall())
self.assertFalse(Tile.EMPTY.is_wall())
self.assertTrue(Tile.FLOOR.can_walk())
self.assertFalse(Tile.WALL.can_walk())
self.assertTrue(Tile.EMPTY.can_walk())