Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
2
2425 - AICE1003 - Coursework Tests
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tsh2n14
2425 - AICE1003 - Coursework Tests
Commits
5aceda09
Commit
5aceda09
authored
5 months ago
by
tsh2n14
Browse files
Options
Downloads
Patches
Plain Diff
Added test Part 2
parent
57bed375
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.md
+2
-0
2 additions, 0 deletions
README.md
test_maze.py
+79
-0
79 additions, 0 deletions
test_maze.py
test_runner.py
+43
-3
43 additions, 3 deletions
test_runner.py
with
124 additions
and
3 deletions
README.md
+
2
−
0
View file @
5aceda09
...
...
@@ -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.
...
...
This diff is collapsed.
Click to expand it.
test_maze.py
0 → 100644
+
79
−
0
View file @
5aceda09
"""
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
)
This diff is collapsed.
Click to expand it.
test_runner.py
+
43
−
3
View file @
5aceda09
"""
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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment