From 640204bd0b7d30b766af4e74b3aa69d270892f64 Mon Sep 17 00:00:00 2001 From: ASPP Student Date: Tue, 23 Sep 2025 17:42:23 +0300 Subject: [PATCH] add test cases --- testing_project/test_logistic.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/testing_project/test_logistic.py b/testing_project/test_logistic.py index 100d824..8e3c548 100644 --- a/testing_project/test_logistic.py +++ b/testing_project/test_logistic.py @@ -1,5 +1,6 @@ from numpy.testing import assert_allclose - +from numpy import isclose +import pytest from logistic import f @@ -18,11 +19,25 @@ def test_f_corner_cases(): # x=0.1, r=2.2 => f(x, r)=0.198 # x=0.2, r=3.4 => f(x, r)=0.544 # x=0.5, r=2 => f(x, r)=0.5 +def test_f_generic_cases(): + cases = [ + (0.1, 2.2, 0.198), + (0.2, 3.4, 0.544), + (0.5, 2, 0.5), + ] + for x, r, expected in cases: + result = f(x, r) + assert_allclose(result, expected) # Hands on 2: # parametrize the above test using @pytest.mark.parametrize +@pytest.mark.parametrize('x, r, expected', ([0.1, 2.2, 0.198],[0.2, 3.4, 0.544],[0.5, 2, 0.5])) +def test_f_parametrize(x, r, expected): + result = f(x, r) + isclose(result, expected) + # Hands on 3 # Implement a function iterate_f that runs f for it iterations. Write tests for the following cases: -- 2.39.5