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
Marvin Serchimo
ModernDev
Commits
8d57bd07
Commit
8d57bd07
authored
2 weeks ago
by
Marvin Serchimo
Browse files
Options
Downloads
Patches
Plain Diff
ICounter
parent
b69dc03c
Branches
develop
main
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.DS_Store
+0
-0
0 additions, 0 deletions
.DS_Store
ICounter.py
+56
-0
56 additions, 0 deletions
ICounter.py
Testliste Counter Str
+5
-0
5 additions, 0 deletions
Testliste Counter Str
with
61 additions
and
0 deletions
.DS_Store
+
0
−
0
View file @
8d57bd07
No preview for this file type
This diff is collapsed.
Click to expand it.
ICounter.py
0 → 100644
+
56
−
0
View file @
8d57bd07
from
abc
import
ABC
,
abstractmethod
from
calendar
import
c
import
unittest
from
weakref
import
ref
#Interface
class
ICounter
(
ABC
):
@abstractmethod
def
count_ED
(
self
,
s
):
pass
# Implementierung Klasse
class
Counter
(
ICounter
):
def
count_ED
(
self
,):
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
):
self
.
c
res
=
c
.
count_ED
(
"
Decker
"
)
self
.
assertEqual
(
res
,
3
)
def
test_count_ED_empty
(
self
):
ergebnis
=
self
.
c
.
count_ED
(
""
)
self
.
assertCountEqual
(
ergebnis
,
0
)
def
test_count_ED_wo
(
self
):
"""
testet einen string ohne E und D
"""
ergebnis
=
self
.
c
.
count_ED
(
"
Hallo
"
)
self
.
assertEqual
(
ergebnis
,
0
)
def
test_count_ED_insensitive
(
self
):
"""
TEstes verschiedene Groß und Kleinschreibungen
"""
ergebnis
=
self
.
c
.
count_ED
(
"
Der Esel
"
)
self
.
assertEqual
(
ergebnis
,
4
)
def
test_count_ED_single_letter
(
self
):
"""
Testet Eingaben nur mit einem Buchstaben
"""
ergebnis
=
self
.
c
.
count_ED
(
"
D
"
)
self
.
assertEqual
(
ergebnis
,
1
)
ergebnis
=
self
.
c
.
count_ED
(
"
E
"
)
self
.
assertEqual
(
ergebnis
,
1
)
ergebnis
=
self
.
c
.
count_ED
(
"
d
"
)
self
.
assertEqual
(
ergebnis
,
1
)
ergebnis
=
self
.
c
.
count_ED
(
"
e
"
)
self
.
assertEqual
(
ergebnis
,
1
)
if
__name__
==
"
__main__
"
:
unittest
.
main
()
This diff is collapsed.
Click to expand it.
Testliste Counter Str
0 → 100644
+
5
−
0
View file @
8d57bd07
Testliste Counter Str
Bei Eingabe des Strings Decker liefert die Funktion 3
Bei Eingabe eines leeren Strings soll 0 ausgegeben werden
Bei Eingabe des Srings "Hallo" ohne e und D soll 0 ausgegeben werden
Bei Eingabe von dem String "Der Esel" soll großgroß-kleinschreibung (caseinsensitive ) gezählt werden
\ 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