Skip to content

Commit

Permalink
formatting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
henrygerardmoore committed Sep 5, 2024
1 parent 63c3f3d commit b8b4d41
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions rosidl_generator_cpp/rosidl_generator_cpp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from math import isnan
from ast import literal_eval

from rosidl_parser.definition import AbstractGenericString
Expand All @@ -27,8 +28,6 @@
from rosidl_parser.definition import UnboundedSequence
from rosidl_pycommon import generate_files

from math import isnan


def generate_cpp(generator_arguments_file):
mapping = {
Expand Down Expand Up @@ -205,7 +204,7 @@ def primitive_value_to_cpp(type_, value):
'int16', 'uint16',
]:
return str(value)

if type_.typename in ['double', 'long double']:
if isnan(value):
return 'std::numeric_limits<double>::quiet_NaN()'
Expand Down Expand Up @@ -233,7 +232,7 @@ def primitive_value_to_cpp(type_, value):
return '%sull' % value

if type_.typename == 'float':
if isnan(value) :
if isnan(value):
return 'std::numeric_limits<float>::quiet_NaN()'
return '%sf' % value

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -549,10 +549,10 @@ TEST(Test_messages, Test_nan) {
float float_nv_lc = rosidl_generator_tests::msg::NanTest::FLOAT32_NAN_UC;
double double_nv_uc = rosidl_generator_tests::msg::NanTest::FLOAT64_NAN_UC;
double double_nv_lc = rosidl_generator_tests::msg::NanTest::FLOAT64_NAN_UC;

// nan is not equal to nan, so make sure the values are nan
EXPECT_TRUE(std::isnan(float_nv_uc));
EXPECT_TRUE(std::isnan(float_nv_lc));
EXPECT_TRUE(std::isnan(double_nv_uc));
EXPECT_TRUE(std::isnan(double_nv_lc));
}
}

0 comments on commit b8b4d41

Please sign in to comment.