diff --git a/String calculator b/String calculator index 5cb2cbbb0120e2ec908bafbd6f8b279c34fd85ae..301f5911de519e7b0b35e51e72e8439f8cf17616 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