Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
ModernDev
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
Hatice Yildirim
ModernDev
Merge requests
!3
GotsisWasili
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
GotsisWasili
feature/GotsisWasili
into
develop
Overview
0
Commits
4
Pipelines
0
Changes
4
Merged
Hatice Yildirim
requested to merge
feature/GotsisWasili
into
develop
2 months ago
Overview
0
Commits
4
Pipelines
0
Changes
4
Expand
0
0
Merge request reports
Compare
develop
develop (base)
and
latest version
latest version
66469dcc
4 commits,
2 months ago
4 files
+
169
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
4
Search (e.g. *.vue) (Ctrl+P)
Other/GotsisWasili_1/TDD_Converter.py
0 → 100644
+
51
−
0
Options
import
unittest
from
abc
import
ABC
,
abstractmethod
#Interface für Counter
class
IRomanNumber
(
ABC
):
@abstractmethod
def
convert_int_to_str
(
self
,
n
:
int
)
->
str
:
pass
# Implementierung Converter Klasse
class
RomanNumber
(
IRomanNumber
):
def
convert_int_to_str
(
self
,
n
:
int
)
->
str
:
#Eingabe anders als int
if
not
isinstance
(
n
,
int
):
return
"
Fehler: Bitte Zahl eingeben
"
#Int Eingabe kleiner gleich 0
if
n
<=
0
:
return
"
Integer muss größer als 0 sein
"
# Bekannte Werte umwandeln
roman_convert
=
{
1
:
"
I
"
,
21
:
"
XXI
"
,
1000
:
"
M
"
}
return
roman_convert
.
get
(
n
)
# Testklasse (TestConverter)
class
TestRomanNumber
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
r
=
RomanNumber
()
def
test_convert_1
(
self
):
self
.
assertEqual
(
self
.
r
.
convert_int_to_str
(
1
),
"
I
"
)
def
test_convert_21
(
self
):
self
.
assertEqual
(
self
.
r
.
convert_int_to_str
(
21
),
"
XXI
"
)
def
test_convert_empty
(
self
):
self
.
assertEqual
(
self
.
r
.
convert_int_to_str
(
None
),
"
Fehler: Bitte Zahl eingeben
"
)
def
test_convert_string
(
self
):
self
.
assertEqual
(
self
.
r
.
convert_int_to_str
(
"
Hello
"
),
"
Fehler: Bitte Zahl eingeben
"
)
def
test_convert_downzero
(
self
):
self
.
assertEqual
(
self
.
r
.
convert_int_to_str
(
-
5
),
"
Integer muss größer als 0 sein
"
)
def
test_convert_downzero
(
self
):
self
.
assertEqual
(
self
.
r
.
convert_int_to_str
(
1000
),
"
M
"
)
if
__name__
==
"
__main__
"
:
unittest
.
main
()
Loading