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 authored and audrow committed Aug 13, 2020
1 parent 96cccf5 commit 94343ff
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 @@ -77,6 +77,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 @@ -94,6 +94,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/rclcpp/test_duration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ TEST_F(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(), old.nanoseconds() + young.nanoseconds());
Expand Down

0 comments on commit 94343ff

Please sign in to comment.