@@ -129,6 +129,9 @@ TEST_F(TestNodeGraph, construct_from_node)
129129
130130 EXPECT_EQ (0u , node_graph ()->count_publishers (" not_a_topic" ));
131131 EXPECT_EQ (0u , node_graph ()->count_subscribers (" not_a_topic" ));
132+ EXPECT_EQ (0u , node_graph ()->count_clients (" not_a_service" ));
133+ EXPECT_EQ (0u , node_graph ()->count_services (" not_a_service" ));
134+
132135 EXPECT_NE (nullptr , node_graph ()->get_graph_guard_condition ());
133136
134137 // get_graph_event is non-const
@@ -534,6 +537,22 @@ TEST_F(TestNodeGraph, count_subscribers_rcl_error)
534537 std::runtime_error (" could not count subscribers: error not set" ));
535538}
536539
540+ TEST_F (TestNodeGraph, count_clients_rcl_error)
541+ {
542+ auto mock = mocking_utils::patch_and_return (" lib:rclcpp" , rcl_count_clients, RCL_RET_ERROR);
543+ RCLCPP_EXPECT_THROW_EQ (
544+ node_graph ()->count_clients (" service" ),
545+ std::runtime_error (" could not count clients: error not set" ));
546+ }
547+
548+ TEST_F (TestNodeGraph, count_services_rcl_error)
549+ {
550+ auto mock = mocking_utils::patch_and_return (" lib:rclcpp" , rcl_count_services, RCL_RET_ERROR);
551+ RCLCPP_EXPECT_THROW_EQ (
552+ node_graph ()->count_services (" service" ),
553+ std::runtime_error (" could not count services: error not set" ));
554+ }
555+
537556TEST_F (TestNodeGraph, notify_shutdown)
538557{
539558 EXPECT_NO_THROW (node ()->get_node_graph_interface ()->notify_shutdown ());
0 commit comments