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

Test successful

parent d47a2dea
No related branches found
No related tags found
No related merge requests found
Pipeline #20016 passed
......@@ -20,11 +20,20 @@ class IStringCalculator(ABC):
class StringCalculator(IStringCalculator):
def add(self, numbers: str) -> int:
'''Leere Eingabe soll 0 ausgeben'''
if numbers == "":
return 0
'''Eingabe einer Zahl als String soll den Integer Wert ausgeben'''
return int(numbers)
'''Zahlen mit Kommas werden aufgeteilt'''
list = numbers.split(",")
'''Konvertirung von Strings zu Integer'''
result = 0
for num in list:
result += int(num.strip())
return result
class TestStringCalculator(unittest.TestCase):
......@@ -38,6 +47,10 @@ class TestStringCalculator(unittest.TestCase):
def test_oneNumber(self):
res = self.c.add("1")
self.assertEqual(res, 1)
def test_addingTwoNumbers(self):
res = self.c.add("1,2")
self.assertEqual(res, 3)
if __name__ == "__main__":
unittest.main()
\ No newline at end of file
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