Created
March 27, 2021 22:27
-
-
Save simon-saliba/d438729ebcf2595b23df5de1eb0241d0 to your computer and use it in GitHub Desktop.
Testing Add function can support a random number of numbers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
from stringcalculator import add | |
class TestStringCalculator(unittest.TestCase): | |
def test_add_empty_string_return_zero(self): | |
self.assertEqual(add(''), 0) | |
def test_add_one_number_will_return_itself(self): | |
self.assertEqual(add('2'), 2) | |
self.assertEqual(add('24'), 24) | |
def test_add_two_numbers_separated_by_comma(self): | |
self.assertEqual(add('1,2'),3) | |
self.assertEqual(add('21,9'),30) | |
def test_add_supports_random_number_of_numbers(self): | |
self.assertEqual(add('1,3,9,6'), 19) | |
self.assertEqual(add('1,4,7,9,8,10,11,23'),72) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment