Skip to content
Snippets Groups Projects
Commit 8c6df414 authored by Daniel Rafeh's avatar Daniel Rafeh
Browse files

Delete counter.py

parent 4de27f12
No related branches found
No related tags found
No related merge requests found
Checking pipeline status
from abc import ABC, abstractmethod
import unittest
# Bei Eingabe des Strings Decker liegert die Funktion 3
# Bei Eingabe eines leeren Strings soll 0 ausgegeben werden
# Bei Eingabe des Strings Hallo soll 0 ausgegeben werden
# Bei Eingabe von Groß-/Kleinschreibung soll trotzdem der entsprechende Wert rauskommen
# Bei Eingabe vom Buchstaben D oder E soll trotzdem die 1 rauskommen
class ICounter(ABC):
@abstractmethod
def count_ED(self, s):
pass
class Counter(ICounter):
def count_ED(self, s):
s = s.upper()
return s.count("E") + s.count("D")
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):
res = self.c.count_ED("Hallo")
self.assertEqual(res, 0)
def test_count_ED_insensetiv(self):
res = self.c.count_ED("Der Esel")
self.assertEqual(res, 4)
def test_count_ED_oneL(self):
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)
res = self.c.count_ED('d')
self.assertEqual(res, 1)
if __name__ == "__main__":
unittest.main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment