diff options
| author | Munyoki Kilyungi (aider) | 2025-02-26 17:32:54 +0300 |
|---|---|---|
| committer | BonfaceKilz | 2025-03-04 15:48:10 +0300 |
| commit | 9bad745abd94fd0eeb0b0dc6aba0d6a74db33f81 (patch) | |
| tree | 580d41f7e1b76247308616f929cfcadc3e110dfb /tests/unit/api | |
| parent | 280c5e97d21501c03f672ed3576ae3eddfc76420 (diff) | |
| download | genenetwork3-9bad745abd94fd0eeb0b0dc6aba0d6a74db33f81.tar.gz | |
test: Add unit tests for fibonacci function in rqtl2 module
Diffstat (limited to 'tests/unit/api')
| -rw-r--r-- | tests/unit/api/test_rqtl2.py | 35 |
1 files changed, 35 insertions, 0 deletions
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 |
