ros / roscpp_core

ros distribution sandbox
89 stars 116 forks source link

Fix duration bug and add tests. #98

Closed trainman419 closed 5 years ago

trainman419 commented 5 years ago

Fix bug in ros::Duration::fromNSec that was introduced in https://github.com/ros/roscpp_core/pull/61, where conversions from nsec were not normalized properly, and could result in Durations with a negative nsec component, which then failed to compare properly.

Since the operator- also uses fromNSec, this also resulted in cases where the diff of two durations could result in an invalid duration.

Added tests which exposed this bug, and then re-added the normalization, which fixes it.

dirk-thomas commented 5 years ago

Thanks for the patch.