Skip to content

Commit 2e0e779

Browse files
Ryanf55henrygerardmoore
authored and
Ryan Friedman
committed
Combine constant tests in a loop
Co-authored-by: Henry Moore <[email protected]> Signed-off-by: Ryan <[email protected]>
1 parent 46f608f commit 2e0e779

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

rosidl_adapter/test/test_constant.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import math
16+
1517
import pytest
1618

1719
from rosidl_adapter.parser import Constant
@@ -31,14 +33,9 @@ def test_constant_constructor():
3133
Constant('bool', 'FOO', None)
3234

3335
# NaN is case insensitive in python, so test a few variations.
34-
value = Constant('float32', 'FOO', 'nan')
35-
value = Constant('float32', 'FOO', 'Nan')
36-
value = Constant('float32', 'FOO', 'NaN')
37-
value = Constant('float32', 'FOO', 'NAN')
38-
value = Constant('float64', 'FOO', 'nan')
39-
value = Constant('float64', 'FOO', 'Nan')
40-
value = Constant('float64', 'FOO', 'NaN')
41-
value = Constant('float64', 'FOO', 'NAN')
36+
for nan_string in ['nan', 'Nan', 'NaN', 'NAN', 'nan', 'Nan', 'NaN', 'NAN']:
37+
value = Constant('float32', 'FOO', nan_string)
38+
assert math.isnan(value.value)
4239

4340

4441
def test_constant_methods():

0 commit comments

Comments
 (0)