Skip to content

Commit

Permalink
add operator!= for duration (#1236)
Browse files Browse the repository at this point in the history
Signed-off-by: Jannik Abbenseth <jannik.abbenseth@ipa.fraunhofer.de>
Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com>
  • Loading branch information
Jannik Abbenseth authored and ivanpauno committed Aug 14, 2020
1 parent 342f225 commit a966214
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions rclcpp/include/rclcpp/duration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ class RCLCPP_PUBLIC Duration
bool
operator==(const rclcpp::Duration & rhs) const;

bool
operator!=(const rclcpp::Duration & rhs) const;

bool
operator<(const rclcpp::Duration & rhs) const;

Expand Down
6 changes: 6 additions & 0 deletions rclcpp/src/rclcpp/duration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ Duration::operator==(const rclcpp::Duration & rhs) const
return rcl_duration_.nanoseconds == rhs.rcl_duration_.nanoseconds;
}

bool
Duration::operator!=(const rclcpp::Duration & rhs) const
{
return rcl_duration_.nanoseconds != rhs.rcl_duration_.nanoseconds;
}

bool
Duration::operator<(const rclcpp::Duration & rhs) const
{
Expand Down
1 change: 1 addition & 0 deletions rclcpp/test/test_duration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ TEST(TestDuration, operators) {
EXPECT_TRUE(old <= young);
EXPECT_TRUE(young >= old);
EXPECT_FALSE(young == old);
EXPECT_TRUE(young != old);

rclcpp::Duration add = old + young;
EXPECT_EQ(add.nanoseconds(), (rcl_duration_value_t)(old.nanoseconds() + young.nanoseconds()));
Expand Down

0 comments on commit a966214

Please sign in to comment.