nkululeko icon indicating copy to clipboard operation
nkululeko copied to clipboard

Add unit tests

Open felixbur opened this issue 1 year ago • 0 comments

Here is an example

  • Add test parameters
  • Test for expected value
  • Add tests/test_to_db.py:
import numpy as np
import pytest

import spmath


@pytest.mark.parametrize(
    'x, expected_y',
    [
        (2, 6.0206),
        (.5, -6.0206),
        (0, -np.Inf),
        (-1, np.nan),
    ],
)
def test_to_db(x, expected_y):
    y = spmath.to_db(x)
    np.testing.assert_allclose(y, expected_y)

felixbur avatar Oct 05 '23 09:10 felixbur