Skip to content

Commit

Permalink
add tests for float/double boundaries
Browse files Browse the repository at this point in the history
  • Loading branch information
squizz617 committed Mar 15, 2021
1 parent 0868490 commit aa8cd4c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions rosidl_generator_py/test/test_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ def test_basic_types():
setattr(msg, 'uint%d_value' % i, -1)
with pytest.raises(AssertionError):
setattr(msg, 'int%d_value' % i, 2**i)
with pytest.raises(AssertionError):
setattr(msg, 'float32_value', -3.5e+38)
with pytest.raises(AssertionError):
setattr(msg, 'float32_value', 3.5e+38)
with pytest.raises(AssertionError):
setattr(msg, 'float64_value', 1.8e+308)
with pytest.raises(AssertionError):
setattr(msg, 'float64_value', -1.8e+308)


def test_strings():
Expand Down Expand Up @@ -450,6 +458,10 @@ def test_arrays():
setattr(msg, 'uint64_values', [2**64, 1, 2])
with pytest.raises(AssertionError):
setattr(msg, 'uint64_values', [-1, 1, 2])
with pytest.raises(AssertionError):
setattr(msg, 'float32_values', [-3.5e+38, 0.0, 3.5e+38])
with pytest.raises(AssertionError):
setattr(msg, 'float64_values', [-1.8e+308, 0.0, 1.8e+308])


def test_bounded_sequences():
Expand Down Expand Up @@ -661,6 +673,10 @@ def test_bounded_sequences():
setattr(msg, 'uint64_values', [2**64, 1, 2])
with pytest.raises(AssertionError):
setattr(msg, 'uint64_values', [-1, 1, 2])
with pytest.raises(AssertionError):
setattr(msg, 'float32_values', [-3.5e+38, 0.0, 3.5e+38])
with pytest.raises(AssertionError):
setattr(msg, 'float64_values', [-1.8e+308, 0.0, 1.8e+308])


def test_unbounded_sequences():
Expand Down Expand Up @@ -800,6 +816,10 @@ def test_unbounded_sequences():
setattr(msg, 'uint64_values', [2**64, 1, 2])
with pytest.raises(AssertionError):
setattr(msg, 'uint64_values', [-1, 1, 2])
with pytest.raises(AssertionError):
setattr(msg, 'float32_values', [-3.5e+38, 0.0, 3.5e+38])
with pytest.raises(AssertionError):
setattr(msg, 'float64_values', [-1.8e+308, 0.0, 1.8e+308])


def test_slot_attributes():
Expand Down

0 comments on commit aa8cd4c

Please sign in to comment.