From 7e606e4500665e87aa1e712908c5beb4c78031d1 Mon Sep 17 00:00:00 2001 From: ahcorde Date: Wed, 30 Sep 2020 12:02:34 +0200 Subject: [PATCH 1/3] Improved test_subscription_options Signed-off-by: ahcorde --- rclcpp/test/rclcpp/test_subscription_options.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/rclcpp/test/rclcpp/test_subscription_options.cpp b/rclcpp/test/rclcpp/test_subscription_options.cpp index ee24685dca..8fc5378520 100644 --- a/rclcpp/test/rclcpp/test_subscription_options.cpp +++ b/rclcpp/test/rclcpp/test_subscription_options.cpp @@ -85,4 +85,16 @@ TEST_F(TestSubscriptionOptions, topic_statistics_options_node_default_mode) { rclcpp::detail::resolve_enable_topic_statistics( subscription_options, *(node->get_node_base_interface()))); + + subscription_options.topic_stats_options.state = rclcpp::TopicStatisticsState::Disable; + EXPECT_FALSE( + rclcpp::detail::resolve_enable_topic_statistics( + subscription_options, + *(node->get_node_base_interface()))); + + subscription_options.topic_stats_options.state = static_cast(5); + EXPECT_THROW( + rclcpp::detail::resolve_enable_topic_statistics( + subscription_options, + *(node->get_node_base_interface())), std::runtime_error); } From 1b11ec109c8f5e2c07efbd67a66dc24d1c5e0755 Mon Sep 17 00:00:00 2001 From: ahcorde Date: Wed, 30 Sep 2020 14:55:25 +0200 Subject: [PATCH 2/3] used RCLCPP_EXPECT_THROW_EQ in test_subcription_options Signed-off-by: ahcorde --- rclcpp/test/rclcpp/test_subscription_options.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/rclcpp/test/rclcpp/test_subscription_options.cpp b/rclcpp/test/rclcpp/test_subscription_options.cpp index 8fc5378520..b146f8d761 100644 --- a/rclcpp/test/rclcpp/test_subscription_options.cpp +++ b/rclcpp/test/rclcpp/test_subscription_options.cpp @@ -23,6 +23,8 @@ #include "rclcpp/node_options.hpp" #include "rclcpp/subscription_options.hpp" +#include "../utils/rclcpp_gtest_macros.hpp" + using namespace std::chrono_literals; namespace @@ -93,8 +95,9 @@ TEST_F(TestSubscriptionOptions, topic_statistics_options_node_default_mode) { *(node->get_node_base_interface()))); subscription_options.topic_stats_options.state = static_cast(5); - EXPECT_THROW( + RCLCPP_EXPECT_THROW_EQ( rclcpp::detail::resolve_enable_topic_statistics( subscription_options, - *(node->get_node_base_interface())), std::runtime_error); + *(node->get_node_base_interface())), + std::runtime_error("Unrecognized EnableTopicStatistics value")); } From 05f2c5903efe016d4a7650208dff62f0863991c0 Mon Sep 17 00:00:00 2001 From: ahcorde Date: Wed, 30 Sep 2020 14:56:49 +0200 Subject: [PATCH 3/3] make linters happy Signed-off-by: ahcorde --- rclcpp/test/rclcpp/test_subscription_options.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rclcpp/test/rclcpp/test_subscription_options.cpp b/rclcpp/test/rclcpp/test_subscription_options.cpp index b146f8d761..c4cfb6b4c4 100644 --- a/rclcpp/test/rclcpp/test_subscription_options.cpp +++ b/rclcpp/test/rclcpp/test_subscription_options.cpp @@ -99,5 +99,5 @@ TEST_F(TestSubscriptionOptions, topic_statistics_options_node_default_mode) { rclcpp::detail::resolve_enable_topic_statistics( subscription_options, *(node->get_node_base_interface())), - std::runtime_error("Unrecognized EnableTopicStatistics value")); + std::runtime_error("Unrecognized EnableTopicStatistics value")); }