Skip to content
Snippets Groups Projects
Commit 5aceda09 authored by tsh2n14's avatar tsh2n14
Browse files

Added test Part 2

parent 57bed375
No related branches found
No related tags found
No related merge requests found
......@@ -20,6 +20,8 @@ the test suit with more tests of your own.
- `test_runner.py`: Some unit tests for testing the functionality of
`runner.py` including creating a runner, turn, and move the runner forward.
- `test_maze.py`: Some unit tests for testing the functionality of the `Maze`
class, including creating a maze, add horizontal and vertical walls.
- More tests will be added as the coursework specification evolves.
......
"""
Created on Tue Nov 12 16:20:23 2024
"""
__author__ = "Son Hoang"
__copyright__ = "Copyright (c) 2024, University of Southampton"
__credits__ = ["Son Hoang"]
__licence__ = "MIT"
__version__ = "1.0"
__maintainer__ = "Son Hoang"
__email__ = "T.S.Hoang@soton.ac.uk"
__status__ = "Prototype"
from maze import Maze
def test_constructor_get_dimensions() -> None:
"""A Unit test for :py:func:`~maze.__init__` and
accessing the width and height properties.
Below is the test sequence:
1. Create a maze of size (11, 5).
2. Assert the width (11) and height (5) of the newly created maze.
created runner.
"""
maze = Maze(11, 5)
assert maze.width == 11
assert maze.height == 5
def test_constructor_get_walls() -> None:
"""A Unit test for :py:func:`~Maze.__init__` and
:py:func:`~Maze.get_walls`
Below is the test sequence:
1. Create a maze of size (11, 5).
2. Assert that there are no walls at the (4, 2)-coordinate.
"""
maze = Maze(11, 5)
assert maze.get_walls(4, 2) == (False, False, False, False)
def test_add_horizontal_wall() -> None:
"""A Unit test for :py:func:`~Maze.add_horizontal_wall` and
:py:func:`~Maze.get_walls`
Below is the test sequence:
1. Create a maze of size (11, 5).
2. Add a horizontal wall at (5, 2).
4. Assert that there are no walls at the (5, 2)-coordinate, except the South.
"""
maze = Maze(11, 5)
maze.add_horizontal_wall(5, 2)
assert maze.get_walls(5, 2) == (False, False, True, False)
def test_add_vertical_wall() -> None:
"""A Unit test for :py:func:`~Maze.add_vertical_wall` and
:py:func:`~Maze.get_walls`
Below is the test sequence:
1. Create a maze of size (11, 5).
2. Add a vertical wall at (2, 4).
3. Assert that there are no walls at the (4, 2)-coordinate, except the West.
"""
maze = Maze(11, 5)
maze.add_vertical_wall(2, 4)
assert maze.get_walls(4, 2) == (False, False, False, True)
"""
Created on Fri Oct 25 12:07:22 2024
"""
__author__ = "Son Hoang"
__copyright__ = "Copyright (c) 2024, University of Southampton"
__credits__ = ["Son Hoang"]
__licence__ = "MIT"
__version__ = "1.0"
__maintainer__ = "Son Hoang"
__email__ = "T.S.Hoang@soton.ac.uk"
__status__ = "Prototype"
from runner import ( # type: ignore
create_runner,
get_orientation,
......@@ -9,7 +23,15 @@ from runner import ( # type: ignore
def test_create_runner() -> None:
"""A Unit test for :func:runner.create_runner function"""
"""A Unit test for :py:func:`~runner.create_runner`
Below is the test sequence:
1. Create a runner at position (1,2), facing South.
2. Assert the x, y positions (1, 2), and the orientation ("S") of the newly
created runner.
"""
runner = create_runner(1, 2, "S")
assert get_x(runner) == 1
assert get_y(runner) == 2
......@@ -17,7 +39,16 @@ def test_create_runner() -> None:
def test_turn() -> None:
"""A Unit test for :func:runner.turn function"""
"""A Unit test for :py:func:`~runner.turn`
Below is the test sequence:
1. Create a runner at position (1,2), facing South.
2. Let the runner turn to the Left.
3. Assert the x, y positions (1, 2), and the orientation ("E") of the runner.
"""
runner = create_runner(1, 2, "S")
runner = turn(runner, "Left")
assert get_x(runner) == 1
......@@ -26,7 +57,16 @@ def test_turn() -> None:
def test_forward() -> None:
"""A Unit test for :func:runner.forward function"""
"""A Unit test for :py:func:`~runner.forward`
Below is the test sequence:
1. Create a runner at position (1,2), facing South.
2. Let the runner more forward.
3. Assert the x, y positions (1, 1), and the orientation ("S") of the runner.
"""
runner = create_runner(1, 2, "S")
runner = forward(runner)
assert get_x(runner) == 1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment