Skip to content

Commit 4b6f728

Browse files
committed
Add failing tests
1 parent 7937334 commit 4b6f728

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

tests/unit/test_get_square_root.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"""
2+
Tests of `example_fgen_basic.get_square_root`
3+
"""
4+
5+
import pytest
6+
7+
from example_fgen_basic.get_square_root import get_square_root
8+
from example_fgen_basic.pyfgen_runtime.exceptions import FortranError
9+
10+
11+
@pytest.mark.parametrize(
12+
"inv, exp, exp_error",
13+
(
14+
(4.0, 2.0, None),
15+
(-4.0, None, pytest.raises(FortranError, match="inv is negative")),
16+
),
17+
)
18+
def test_basic(inv, exp, exp_error):
19+
if exp is not None:
20+
assert get_square_root(inv) == exp
21+
22+
else:
23+
if exp_error is None:
24+
raise AssertionError
25+
26+
with exp_error:
27+
get_square_root(inv)

0 commit comments

Comments
 (0)