corrlib/tests/tools_test.py
Justus Kuhlmann 574877c744
Some checks failed
Pytest / pytest (3.12) (push) Failing after 26s
Pytest / pytest (3.13) (push) Failing after 30s
Pytest / pytest (3.14) (push) Failing after 30s
add two more trivial tests
2025-12-01 18:43:47 +01:00

31 lines
645 B
Python

from corrlib import tools as tl
def test_m2k():
for m in [0.1, 0.5, 1.0]:
expected_k = 1 / (2 * m + 8)
assert tl.m2k(m) == expected_k
def test_k2m():
for m in [0.1, 0.5, 1.0]:
assert tl.k2m(m) == (1/(2*m))-4
def test_k2m_m2k():
for m in [0.1, 0.5, 1.0]:
k = tl.m2k(m)
m_converted = tl.k2m(k)
assert abs(m - m_converted) < 1e-9
def test_str2list():
assert tl.str2list("a,b,c") == ["a", "b", "c"]
assert tl.str2list("1,2,3") == ["1", "2", "3"]
def test_list2str():
assert tl.list2str(["a", "b", "c"]) == "a,b,c"
assert tl.list2str(["1", "2", "3"]) == "1,2,3"