diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 963ba9d..0000000 Binary files a/.DS_Store and /dev/null differ diff --git a/.gitignore b/.gitignore index 113294a..0bb8ddd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.DS_store # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] diff --git a/sources/calc.py b/sources/calc.py new file mode 100644 index 0000000..d1cbd6c --- /dev/null +++ b/sources/calc.py @@ -0,0 +1,5 @@ +''' +A simple addition function. +''' +def add(a, b): + return a + b diff --git a/sources/test_calc.py b/sources/test_calc.py new file mode 100644 index 0000000..02f41f8 --- /dev/null +++ b/sources/test_calc.py @@ -0,0 +1,33 @@ +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()