Skip to content

Commit d27ca8e

Browse files
ivanpaunoJannik Abbenseth
andauthored
add operator!= for duration (#1236) (#1277)
Signed-off-by: Jannik Abbenseth <jannik.abbenseth@ipa.fraunhofer.de> Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com> Co-authored-by: Jannik Abbenseth <ipa-jba@users.noreply.github.com>
1 parent 342f225 commit d27ca8e

3 files changed

Lines changed: 10 additions & 0 deletions

File tree

rclcpp/include/rclcpp/duration.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ class RCLCPP_PUBLIC Duration
6060
bool
6161
operator==(const rclcpp::Duration & rhs) const;
6262

63+
bool
64+
operator!=(const rclcpp::Duration & rhs) const;
65+
6366
bool
6467
operator<(const rclcpp::Duration & rhs) const;
6568

rclcpp/src/rclcpp/duration.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ Duration::operator==(const rclcpp::Duration & rhs) const
9595
return rcl_duration_.nanoseconds == rhs.rcl_duration_.nanoseconds;
9696
}
9797

98+
bool
99+
Duration::operator!=(const rclcpp::Duration & rhs) const
100+
{
101+
return rcl_duration_.nanoseconds != rhs.rcl_duration_.nanoseconds;
102+
}
103+
98104
bool
99105
Duration::operator<(const rclcpp::Duration & rhs) const
100106
{

rclcpp/test/test_duration.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ TEST(TestDuration, operators) {
4545
EXPECT_TRUE(old <= young);
4646
EXPECT_TRUE(young >= old);
4747
EXPECT_FALSE(young == old);
48+
EXPECT_TRUE(young != old);
4849

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

0 commit comments

Comments
 (0)