Skip to content

Commit 2c7d373

Browse files
committed
Add unit tests for TR_string_to_float
1 parent 44e2431 commit 2c7d373

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import pytest
2+
3+
from CPAC.nuisance.utils import compcor
4+
5+
6+
def test_TR_string_to_float():
7+
assert abs(compcor.TR_string_to_float('123') - 123.) < 1e-08
8+
assert abs(compcor.TR_string_to_float('123s') - 123.) < 1e-08
9+
assert abs(compcor.TR_string_to_float('123ms') - 123. / 1000) < 1e-08
10+
11+
assert abs(compcor.TR_string_to_float('1.23') - 1.23) < 1e-08
12+
assert abs(compcor.TR_string_to_float('1.23s') - 1.23) < 1e-08
13+
assert abs(compcor.TR_string_to_float('1.23ms') - 1.23 / 1000) < 1e-08
14+
15+
with pytest.raises(Exception):
16+
compcor.TR_string_to_float(None)
17+
18+
with pytest.raises(Exception):
19+
compcor.TR_string_to_float(['123'])
20+
21+
with pytest.raises(Exception):
22+
compcor.TR_string_to_float(123)
23+
24+
with pytest.raises(Exception):
25+
compcor.TR_string_to_float('ms')

0 commit comments

Comments
 (0)