Files
Group8_Gitearepo/sources/test_calc.py
Giles Gaskell 451a3785a2 Add Python source files
* And update .gitignore
2017-11-28 17:30:45 +11:00

34 lines
816 B
Python

import calc
import unittest
class TestAdd(unittest.TestCase):
"""
Test the add function from the calc library
"""
def test_add_integers(self):
"""
Test that the addition of two integers returns the correct total
"""
result = calc.add(1, 2)
self.assertEqual(result, 3)
def test_add_floats(self):
"""
Test that the addition of two floats returns the correct result
"""
result = calc.add(10.5, 2)
self.assertEqual(result, 12.5)
def test_add_strings(self):
"""
Test the addition of two strings returns the two string as one
concatenated string
"""
result = calc.add('abc', 'def')
self.assertEqual(result, 'abcdef')
if __name__ == '__main__':
unittest.main()