From 3dd15b32e9f49fede8d6e71222824d252daae49c Mon Sep 17 00:00:00 2001 From: DaniRafeh28 <daniel.rafeh@student.reutlingen-university.de> Date: Tue, 25 Mar 2025 16:49:05 +0100 Subject: [PATCH] Test successful --- stringCalculator.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/stringCalculator.py b/stringCalculator.py index 5532a07..3c58954 100644 --- a/stringCalculator.py +++ b/stringCalculator.py @@ -41,6 +41,9 @@ class StringCalculator(IStringCalculator): result = 0 for num in list: result += int(num.strip()) + '''Negative Ergebnisse nicht gestatten''' + if result < 0: + return "negatives not allowed" return result @@ -77,6 +80,10 @@ class TestStringCalculator(unittest.TestCase): res = self.c.add("1\n2,3") self.assertEqual(res, 6) + def test_negativeValues(self): + res = self.c.add("-3") + self.assertEqual(res, "negatives not allowed") + if __name__ == "__main__": unittest.main() \ No newline at end of file -- GitLab