From 9bad745abd94fd0eeb0b0dc6aba0d6a74db33f81 Mon Sep 17 00:00:00 2001 From: Munyoki Kilyungi (aider) Date: Wed, 26 Feb 2025 17:32:54 +0300 Subject: test: Add unit tests for fibonacci function in rqtl2 module --- tests/unit/api/test_rqtl2.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tests/unit/api/test_rqtl2.py (limited to 'tests/unit/api/test_rqtl2.py') diff --git a/tests/unit/api/test_rqtl2.py b/tests/unit/api/test_rqtl2.py new file mode 100644 index 0000000..fbd0d25 --- /dev/null +++ b/tests/unit/api/test_rqtl2.py @@ -0,0 +1,35 @@ +import pytest +from gn3.api.rqtl2 import fibonacci + +def test_fibonacci_zero(): + assert fibonacci(0) == 0 + +def test_fibonacci_one(): + assert fibonacci(1) == 1 + +def test_fibonacci_ten(): + assert fibonacci(10) == 55 + +def test_fibonacci_negative(): + with pytest.raises(ValueError) as excinfo: + fibonacci(-1) + assert "non-negative integer" in str(excinfo.value) + +def test_fibonacci_non_integer(): + with pytest.raises(ValueError) as excinfo: + fibonacci(5.5) + assert "non-negative integer" in str(excinfo.value) + +def test_fibonacci_large(): + assert fibonacci(20) == 6765 + +@pytest.mark.parametrize("n, expected", [ + (2, 1), + (3, 2), + (4, 3), + (5, 5), + (6, 8), + (7, 13), +]) +def test_fibonacci_multiple(n, expected): + assert fibonacci(n) == expected -- cgit 1.4.1