Skip to content

Commit

Permalink
Combine constant tests in a loop
Browse files Browse the repository at this point in the history
Co-authored-by: Henry Moore <henry.moore@picknik.ai>
Signed-off-by: Ryan <ryanfriedman5410+github@gmail.com>
  • Loading branch information
2 people authored and Ryan Friedman committed Sep 7, 2024
1 parent 46f608f commit 2e0e779
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions rosidl_adapter/test/test_constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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():
Expand Down

0 comments on commit 2e0e779

Please sign in to comment.