From 4c99a46a5c996b290625bb15c955f46d2c3dca99 Mon Sep 17 00:00:00 2001 From: Muhamed <Muhamedalici@hotmail.de> Date: Thu, 27 Mar 2025 02:41:11 +0100 Subject: [PATCH] multiple negative numbers and \n --- String calculator | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/String calculator b/String calculator index 5cb2cbb..301f591 100644 --- a/String calculator +++ b/String calculator @@ -61,6 +61,17 @@ class TestStingCalculator(unittest.TestCase): with self.assertRaises(ValueError) as e: self.calculator.add("-1,2") self.assertEqual(str(e.exception), "negatives not allowed: -1") + def test_multiple_negative_numbers_exception(self): + with self.assertRaises(ValueError)as e: + self.calculator.add("-1,-2,3") + self.assertEqual(str(e.exception),"negatives not allowed: -1,-2") + with self.assertRaises(ValueError) as e: + self.calculator.add("-1,-3,4") + self.assertEqual(str(e.exception),"negatives not allowed: -1,-3") + with self.assertRaises(ValueError) as e: + self.calculator.add("-1\n-3,4") + self.assertEqual(str(e.exception),"negatives not allowed: -1,-3") + if __name__=='__main__': unittest.main() \ No newline at end of file -- GitLab