From d8ca1568f39c3fa494a65cb7a9e32d77da4273ef Mon Sep 17 00:00:00 2001 From: ahcorde Date: Wed, 30 Sep 2020 12:26:24 +0200 Subject: [PATCH 1/2] Covered resolve_use_intra_process Signed-off-by: ahcorde --- rclcpp/test/rclcpp/test_subscription.cpp | 27 ++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/rclcpp/test/rclcpp/test_subscription.cpp b/rclcpp/test/rclcpp/test_subscription.cpp index ef626849a0..149629e9d1 100644 --- a/rclcpp/test/rclcpp/test_subscription.cpp +++ b/rclcpp/test/rclcpp/test_subscription.cpp @@ -461,6 +461,33 @@ TEST_P(TestSubscriptionInvalidIntraprocessQos, test_subscription_throws) { } } +/* + Testing subscription with invalid use_intra_process_comm + */ +TEST_P(TestSubscriptionInvalidIntraprocessQos, test_subscription_throws_intraprocess) { + // Adds more coverage + rclcpp::SubscriptionOptionsWithAllocator> options; + options.use_intra_process_comm = static_cast(5); + + initialize(); + rclcpp::QoS qos = GetParam().qos; + using test_msgs::msg::Empty; + { + auto callback = std::bind( + &TestSubscriptionInvalidIntraprocessQos::OnMessage, + this, + std::placeholders::_1); + + ASSERT_THROW( + {auto subscription = node->create_subscription( + "topic", + qos, + callback, + options);}, + std::runtime_error); + } +} + static std::vector invalid_qos_profiles() { std::vector parameters; From 9452349cf838e742d205ee6bd7953b408d65de5d Mon Sep 17 00:00:00 2001 From: ahcorde Date: Wed, 30 Sep 2020 15:05:20 +0200 Subject: [PATCH 2/2] used RCLCPP_EXPECT_THROW_EQ in test_subscription_throws_intraprocess Signed-off-by: ahcorde --- rclcpp/test/rclcpp/test_subscription.cpp | 27 +++++++++++------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/rclcpp/test/rclcpp/test_subscription.cpp b/rclcpp/test/rclcpp/test_subscription.cpp index 149629e9d1..9559e69c4b 100644 --- a/rclcpp/test/rclcpp/test_subscription.cpp +++ b/rclcpp/test/rclcpp/test_subscription.cpp @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -465,27 +466,23 @@ TEST_P(TestSubscriptionInvalidIntraprocessQos, test_subscription_throws) { Testing subscription with invalid use_intra_process_comm */ TEST_P(TestSubscriptionInvalidIntraprocessQos, test_subscription_throws_intraprocess) { - // Adds more coverage rclcpp::SubscriptionOptionsWithAllocator> options; options.use_intra_process_comm = static_cast(5); initialize(); rclcpp::QoS qos = GetParam().qos; - using test_msgs::msg::Empty; - { - auto callback = std::bind( - &TestSubscriptionInvalidIntraprocessQos::OnMessage, - this, - std::placeholders::_1); + auto callback = std::bind( + &TestSubscriptionInvalidIntraprocessQos::OnMessage, + this, + std::placeholders::_1); - ASSERT_THROW( - {auto subscription = node->create_subscription( - "topic", - qos, - callback, - options);}, - std::runtime_error); - } + RCLCPP_EXPECT_THROW_EQ( + {auto subscription = node->create_subscription( + "topic", + qos, + callback, + options);}, + std::runtime_error("Unrecognized IntraProcessSetting value")); } static std::vector invalid_qos_profiles()