Beispiel #1
0
class test_smtg_test(unittest.TestCase):
    """Testing the unit"""

    def setUp(self):
        self.filename = 'test_dng_map.txt'
        f = open(self.filename, "w")
        content_map = 'S.##......\n#.##..###.\n#.###.###.\n#.....###.\n###.#####S'
        f.write(content_map)
        f.close()

        self.new_map = Dungeon(self.filename)

    def test_load_map(self):
        expected = 'S.##......\n#.##..###.\n#.###.###.\n#.....###.\n###.#####S'
        self.assertEqual(expected, self.new_map.load_map())

    def test_map_to_matrix(self):
        expected = [['S', '.', '#', '#', '.', '.', '.', '.', '.', '.'], ['#', '.', '#', '#', '.', '.', '#', '#', '#', '.'], ['#', '.', '#', '#', '#', '.', '#', '#', '#', '.'], ['#', '.', '.', '.', '.', '.', '#', '#', '#', '.'], ['#', '#', '#', '.', '#', '#', '#', '#', '#', 'S']]

        self.assertEqual(expected, self.new_map.map_to_matrix())

    def tearDown(self):
        # fpath = os.getcwd()
        try:
            os.remove(self.filename)
        except OSError:
            print('No such file')
Beispiel #2
0
class test_smtg_test(unittest.TestCase):
    """Testing the unit"""
    def setUp(self):
        self.new_map = Dungeon(1)

    def test_load_map(self):

        expected = 'S.IP..........PPI###############\nI#########.#####################\n.....P.........................A\n.####.##.###.###################\nP####.##.###.#####.....#########\n.####.##.###.#####.###.##IIIIII#\nP####.I..###.#####.###.##P....I#\n.####P##P###.......###.##P######\nP####.##.############.........A.\nI####A...######################G'

        self.assertEqual(expected, self.new_map.load_map())

    def test_map_to_matrix(self):
        expected = [['S', '.', 'I', 'P', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', 'P', 'P', 'I', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#'], ['I', '#', '#', '#', '#', '#', '#', '#', '#', '#', '.', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#'], ['.', '.', '.', '.', '.', 'P', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', 'A'], ['.', '#', '#', '#', '#', '.', '#', '#', '.', '#', '#', '#', '.', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#'], ['P', '#', '#', '#', '#', '.', '#', '#', '.', '#', '#', '#', '.', '#', '#', '#', '#', '#', '.', '.', '.', '.', '.', '#', '#', '#', '#', '#', '#', '#', '#', '#'], ['.', '#', '#', '#', '#', '.', '#', '#', '.', '#', '#', '#', '.', '#', '#', '#', '#', '#', '.', '#', '#', '#', '.', '#', '#', 'I', 'I', 'I', 'I', 'I', 'I', '#'], ['P', '#', '#', '#', '#', '.', 'I', '.', '.', '#', '#', '#', '.', '#', '#', '#', '#', '#', '.', '#', '#', '#', '.', '#', '#', 'P', '.', '.', '.', '.', 'I', '#'], ['.', '#', '#', '#', '#', 'P', '#', '#', 'P', '#', '#', '#', '.', '.', '.', '.', '.', '.', '.', '#', '#', '#', '.', '#', '#', 'P', '#', '#', '#', '#', '#', '#'], ['P', '#', '#', '#', '#', '.', '#', '#', '.', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '.', '.', '.', '.', '.', '.', '.', '.', '.', 'A', '.'], ['I', '#', '#', '#', '#', 'A', '.', '.', '.', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', 'G']]

        self.assertEqual(expected, self.new_map.map_to_matrix())