Skip to content

Commit baaf7b7

Browse files
committed
Add failing test
1 parent 2a2d11d commit baaf7b7

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
"""
2+
Tests of `example_fgen_basic.error_v.creation`
3+
4+
Note that this is the only test of the Fortran code.
5+
I haven't written unit tests for the Fortran directly
6+
(deliberately, just to see how it goes).
7+
"""
8+
9+
from example_fgen_basic.error_v import ErrorV
10+
from example_fgen_basic.error_v.creation import create_error
11+
12+
13+
def test_create_error_odd():
14+
res = create_error(1.0)
15+
16+
assert isinstance(res, ErrorV)
17+
18+
assert res.code == 0
19+
assert res.message == ""
20+
21+
22+
def test_create_error_even():
23+
res = create_error(2.0)
24+
25+
assert isinstance(res, ErrorV)
26+
27+
assert res.code != 0
28+
assert res.code == 1
29+
assert res.message == "Even number supplied"
30+
31+
32+
def test_create_error_negative():
33+
res = create_error(-1.0)
34+
35+
assert isinstance(res, ErrorV)
36+
37+
assert res.code == 2
38+
assert res.message == "Negative number supplied"
39+
40+
41+
# Tests to write:
42+
# - if we create more errors than we have available, we don't segfault.
43+
# Instead, we should get an error back.
44+
# That error should just use the instance ID of the last available array index
45+
# (it is ok to overwrite an already used error to avoid a complete failure,
46+
# but we should probably include that we did this in the error message).
47+
# - we can resize the available number of error instances to avoid hitting limits

0 commit comments

Comments
 (0)