From 96b39fbeea3a20d61648ff2ca9e005148ac15930 Mon Sep 17 00:00:00 2001 From: David GAILLETON Date: Thu, 19 Mar 2026 17:30:18 +0100 Subject: [PATCH] Maze tester --- src/amaz_lib/Maze.py | 4 ---- tests/test_Maze.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 tests/test_Maze.py diff --git a/src/amaz_lib/Maze.py b/src/amaz_lib/Maze.py index fc01270..4dcf016 100644 --- a/src/amaz_lib/Maze.py +++ b/src/amaz_lib/Maze.py @@ -25,10 +25,6 @@ class Maze: res += "\n" return res - def export_maze(self, file_name: str) -> None: - with open(file_name, "w") as file: - file.write(self.__str__()) - def ascii_print(self) -> None: for line in self.maze: if line is self.maze[0]: diff --git a/tests/test_Maze.py b/tests/test_Maze.py new file mode 100644 index 0000000..7bdf580 --- /dev/null +++ b/tests/test_Maze.py @@ -0,0 +1,31 @@ +import numpy +from amaz_lib.Cell import Cell +from amaz_lib.Maze import Maze + + +def test_maze_setter_getter() -> None: + maze = Maze(numpy.array([])) + + test = numpy.array( + [ + [Cell(value=6), Cell(value=8), Cell(value=11)], + [Cell(value=6), Cell(value=8), Cell(value=11)], + [Cell(value=6), Cell(value=8), Cell(value=11)], + ] + ) + + maze.set_maze(test) + assert numpy.array_equal(maze.get_maze(), test) == True + + +def test_maze_str() -> None: + test = numpy.array( + [ + [Cell(value=6), Cell(value=8), Cell(value=11)], + [Cell(value=6), Cell(value=8), Cell(value=11)], + [Cell(value=6), Cell(value=8), Cell(value=11)], + ] + ) + maze = Maze(test) + + assert maze.__str__() == "68B\n68B\n68B\n"