From 2e0e7794996212fdc410f50f8e5c729b23b8753a Mon Sep 17 00:00:00 2001 From: Ryan Date: Sat, 7 Sep 2024 00:29:09 -0600 Subject: [PATCH] Combine constant tests in a loop Co-authored-by: Henry Moore Signed-off-by: Ryan --- rosidl_adapter/test/test_constant.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/rosidl_adapter/test/test_constant.py b/rosidl_adapter/test/test_constant.py index 6ee8fd161..f6240c414 100644 --- a/rosidl_adapter/test/test_constant.py +++ b/rosidl_adapter/test/test_constant.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import math + import pytest from rosidl_adapter.parser import Constant @@ -31,14 +33,9 @@ def test_constant_constructor(): Constant('bool', 'FOO', None) # NaN is case insensitive in python, so test a few variations. - value = Constant('float32', 'FOO', 'nan') - value = Constant('float32', 'FOO', 'Nan') - value = Constant('float32', 'FOO', 'NaN') - value = Constant('float32', 'FOO', 'NAN') - value = Constant('float64', 'FOO', 'nan') - value = Constant('float64', 'FOO', 'Nan') - value = Constant('float64', 'FOO', 'NaN') - value = Constant('float64', 'FOO', 'NAN') + for nan_string in ['nan', 'Nan', 'NaN', 'NAN', 'nan', 'Nan', 'NaN', 'NAN']: + value = Constant('float32', 'FOO', nan_string) + assert math.isnan(value.value) def test_constant_methods():