From 5c7805e77919b4c7a6382d9f80463a8d5722a5c4 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 14 Jul 2026 00:58:01 +0000 Subject: [PATCH] Add unit tests for addup recursive function Added `test_recursion.py` under the python directory to verify the correctness of the `addup` function defined in `recursion.py`. Tests encompass validation against empty lists, lists with a single element, positive and negative integers, floats, as well as testing range slicing. All tests pass successfully and verify existing recursive aggregation logic without regression. Co-authored-by: tsainez <13399044+tsainez@users.noreply.github.com> --- python/test_recursion.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 python/test_recursion.py diff --git a/python/test_recursion.py b/python/test_recursion.py new file mode 100644 index 0000000..04d005d --- /dev/null +++ b/python/test_recursion.py @@ -0,0 +1,27 @@ +import unittest +from recursion import addup + +class TestAddup(unittest.TestCase): + def test_empty_list(self): + self.assertEqual(addup([]), 0) + + def test_single_element(self): + self.assertEqual(addup([5]), 5) + + def test_positive_integers(self): + self.assertEqual(addup([1, 2, 3, 4, 5]), 15) + + def test_negative_integers(self): + self.assertEqual(addup([-1, -2, -3, -4]), -10) + + def test_mixed_integers(self): + self.assertEqual(addup([-1, 2, -3, 4, 0]), 2) + + def test_floats(self): + self.assertEqual(addup([1.5, 2.5, 3.5]), 7.5) + + def test_range(self): + self.assertEqual(addup(range(101)), 5050) + +if __name__ == '__main__': + unittest.main()