Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
test_me_on_student7.py 752 B
import unittest
from other.student7.Calculator import StringCalculator  # Student 7s Code wird getestet

class TestMeOnStudent7(unittest.TestCase):
    def setUp(self):
        self.calc = StringCalculator()

    def test_empty_string(self):
        self.assertEqual(self.calc.add(""), 0)

    def test_custom_delimiter(self):
        self.assertEqual(self.calc.add("//|\n1|2|3|4"), 10)

    def test_newlines_and_large_numbers(self):
        self.assertEqual(self.calc.add("1\n2,1001"), 3)

    def test_negative_handling(self):
        with self.assertRaises(ValueError) as context:
            self.calc.add("1,-2,-3")
        self.assertEqual(str(context.exception), "Negatives not allowed: -2, -3")

if __name__ == "__main__":
    unittest.main()