Skip to content

Commit

Permalink
Add operator!= for duration (#1236) (#1278)
Browse files Browse the repository at this point in the history
Signed-off-by: Jannik Abbenseth <jannik.abbenseth@ipa.fraunhofer.de>

Co-authored-by: Jannik Abbenseth <ipa-jba@users.noreply.github.com>
  • Loading branch information
ivanpauno and Jannik Abbenseth authored Aug 18, 2020
1 parent 27e59d9 commit 75f3d54
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 @@ -96,6 +96,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(), old.nanoseconds() + young.nanoseconds());
Expand Down

0 comments on commit 75f3d54

Please sign in to comment.