Add affinity_effect_calculator/tests/test_core.py
This commit is contained in:
parent
0fa1c18c8b
commit
67560fd0c3
1 changed files with 46 additions and 0 deletions
46
affinity_effect_calculator/tests/test_core.py
Normal file
46
affinity_effect_calculator/tests/test_core.py
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
import pytest
|
||||
|
||||
from src.affinity_effect_calculator import core
|
||||
|
||||
|
||||
def test_calculate_affinity_effect_nominal():
|
||||
# Nominal case, typical positive values
|
||||
effect_4x = 1.2
|
||||
effect_2x = 0.8
|
||||
expected = 0.4
|
||||
result = core.calculate_affinity_effect(effect_4x, effect_2x)
|
||||
assert pytest.approx(result, rel=1e-9) == expected
|
||||
|
||||
|
||||
def test_calculate_affinity_effect_negative_values():
|
||||
# Handles negative values correctly
|
||||
effect_4x = -0.5
|
||||
effect_2x = -1.0
|
||||
expected = 0.5 # (-0.5) - (-1.0) = 0.5
|
||||
result = core.calculate_affinity_effect(effect_4x, effect_2x)
|
||||
assert pytest.approx(result, rel=1e-9) == expected
|
||||
|
||||
|
||||
def test_calculate_affinity_effect_zero_difference():
|
||||
effect_4x = 1.0
|
||||
effect_2x = 1.0
|
||||
expected = 0.0
|
||||
result = core.calculate_affinity_effect(effect_4x, effect_2x)
|
||||
assert pytest.approx(result, rel=1e-9) == expected
|
||||
|
||||
|
||||
def test_calculate_affinity_effect_type_validation():
|
||||
# Input validation should raise TypeError for non-floats
|
||||
with pytest.raises(TypeError):
|
||||
core.calculate_affinity_effect("4.0", 2.0)
|
||||
with pytest.raises(TypeError):
|
||||
core.calculate_affinity_effect(4.0, None)
|
||||
|
||||
|
||||
def test_calculate_affinity_effect_large_numbers():
|
||||
# Use large floats to check precision handling
|
||||
effect_4x = 1e12
|
||||
effect_2x = 5e11
|
||||
expected = 5e11
|
||||
result = core.calculate_affinity_effect(effect_4x, effect_2x)
|
||||
assert pytest.approx(result, rel=1e-12) == expected
|
||||
Loading…
Reference in a new issue