Skip to content

Commit

Permalink
add operator!= for duration
Browse files Browse the repository at this point in the history
Signed-off-by: Jannik Abbenseth <jannik.abbenseth@ipa.fraunhofer.de>
  • Loading branch information
Jannik Abbenseth committed Jul 22, 2020
1 parent 607158a commit 2a7f1fb
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 @@ -62,6 +62,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 2a7f1fb

Please sign in to comment.