Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MarsRover
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Muhamed Alici
MarsRover
Commits
26363e32
Commit
26363e32
authored
1 month ago
by
Muhamed (aider)
Browse files
Options
Downloads
Patches
Plain Diff
feat: Füge einen neuen Test für das Singleton-Pattern der Mars-Klasse hinzu.
parent
ebe21aa1
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Unittest.py
+19
-0
19 additions, 0 deletions
Unittest.py
with
19 additions
and
0 deletions
Unittest.py
+
19
−
0
View file @
26363e32
...
@@ -318,6 +318,25 @@ class TestRoverMovment(unittest.TestCase):
...
@@ -318,6 +318,25 @@ class TestRoverMovment(unittest.TestCase):
self
.
assertEqual
(
observed_grid
,
[])
self
.
assertEqual
(
observed_grid
,
[])
print
(
"
Test observe_returns_empty_list erfolgreich!
"
)
print
(
"
Test observe_returns_empty_list erfolgreich!
"
)
def
test_mars_singleton
(
self
):
"""
Test ob Mars wirklich als Singleton implementiert ist.
Überprüft ob mehrere Instanziierungen die gleiche Instanz zurückgeben.
"""
plateau1
=
Plateau
(
5
,
5
)
plateau2
=
Plateau
(
3
,
3
)
# Erstelle zwei Mars-Instanzen
mars1
=
Mars
(
plateau1
)
mars2
=
Mars
(
plateau2
)
# Überprüfe ob es sich um die gleiche Instanz handelt
self
.
assertIs
(
mars1
,
mars2
,
"
Mars-Instanzen sollten identisch sein (Singleton)
"
)
# Überprüfe ob das Plateau der ersten Instanzierung beibehalten wurde
self
.
assertEqual
(
mars1
.
plateau
.
width
,
5
)
self
.
assertEqual
(
mars2
.
plateau
.
width
,
5
)
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
unittest
.
main
()
unittest
.
main
()
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