Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PraxisprojektTechnologiebasierteInnovation
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
Lasse Pikkemaat
PraxisprojektTechnologiebasierteInnovation
Commits
72d0864b
Commit
72d0864b
authored
2 months ago
by
linopino
Browse files
Options
Downloads
Patches
Plain Diff
Create Counter.py
parent
506a816f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Counter.py
+48
-0
48 additions, 0 deletions
Counter.py
with
48 additions
and
0 deletions
Counter.py
0 → 100644
+
48
−
0
View file @
72d0864b
#Bei Eingabe des Strings "Decker" liefert die Funktion 3
#Bei Eingabe eines leeren Stings soll 0 augegeben werden
#Bei Eingabe des Strings "Hallo" ohne E und D soll 0 ausgegeben werden
#Bei Eingabe von dem String "Der Esel" soll Groß-Kleinschreibung (Caseinsensitive) gezählt werden. das Ergebnis ist 4
#Bei Eingabe des Buchstaben D oder E soll 1 ausgegeben werden
from
abc
import
ABC
,
abstractmethod
import
unittest
class
ICounter
(
ABC
):
@abstractmethod
def
count_ED
(
self
,
s
):
pass
class
Counter
(
ICounter
):
def
count_ED
(
self
,
s
):
s
=
s
.
upper
()
return
s
.
count
(
"
D
"
)
+
s
.
count
(
"
E
"
)
class
TestCounter
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
c
=
Counter
()
def
test_count_ED_regular
(
self
):
res
=
self
.
c
.
count_ED
(
"
Decker
"
)
self
.
assertEqual
(
res
,
3
)
def
test_count_ED_empty
(
self
):
res
=
self
.
c
.
count_ED
(
""
)
self
.
assertEqual
(
res
,
0
)
def
test_count_ED_wo
(
self
):
'''
Testet einen String ohne E und D
'''
res
=
self
.
c
.
count_ED
(
"
Hallo
"
)
self
.
assertEqual
(
res
,
0
)
def
test_count_ED_case_insensitive
(
self
):
'''
Testet verschiedene Groß- und Kleinschreibungen
'''
res
=
self
.
c
.
count_ED
(
"
Der Esel
"
)
self
.
assertEqual
(
res
,
4
)
def
test_count_ED_single_letetr
(
self
):
'''
Testet Eingaben mit nur einem Buchstaben
'''
res
=
self
.
c
.
count_ED
(
'
D
'
)
self
.
assertEqual
(
res
,
1
)
res
=
self
.
c
.
count_ED
(
'
E
'
)
self
.
assertEqual
(
res
,
1
)
res
=
self
.
c
.
count_ED
(
'
d
'
)
self
.
assertEqual
(
res
,
1
)
res
=
self
.
c
.
count_ED
(
'
e
'
)
self
.
assertEqual
(
res
,
1
)
if
__name__
==
"
__main__
"
:
unittest
.
main
()
\ No newline at end of file
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