Test that nodes are returned with correct multiplicity (#598)

Signed-off-by: Dan Rose <dan@digilabs.io>
This commit is contained in:
Dan Rose 2020-03-13 13:20:43 -05:00 committed by GitHub
parent 069d1f0729
commit 00f3acc8d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -67,7 +67,7 @@ TEST_F(CLASSNAME(TestGetNodeNames, RMW_IMPLEMENTATION), test_rcl_get_node_names)
EXPECT_EQ(RCL_RET_OK, rcl_shutdown(&context)) << rcl_get_error_string().str; EXPECT_EQ(RCL_RET_OK, rcl_shutdown(&context)) << rcl_get_error_string().str;
EXPECT_EQ(RCL_RET_OK, rcl_context_fini(&context)) << rcl_get_error_string().str; EXPECT_EQ(RCL_RET_OK, rcl_context_fini(&context)) << rcl_get_error_string().str;
}); });
std::set<std::pair<std::string, std::string>> expected_nodes, discovered_nodes; std::multiset<std::pair<std::string, std::string>> expected_nodes, discovered_nodes;
auto node1_ptr = new rcl_node_t; auto node1_ptr = new rcl_node_t;
*node1_ptr = rcl_get_zero_initialized_node(); *node1_ptr = rcl_get_zero_initialized_node();
@ -105,6 +105,15 @@ TEST_F(CLASSNAME(TestGetNodeNames, RMW_IMPLEMENTATION), test_rcl_get_node_names)
ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str; ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
expected_nodes.insert(std::make_pair(std::string(node4_name), std::string(node4_namespace))); expected_nodes.insert(std::make_pair(std::string(node4_name), std::string(node4_namespace)));
auto node5_ptr = new rcl_node_t;
*node5_ptr = rcl_get_zero_initialized_node();
const char * node5_name = "node1";
const char * node5_namespace = "/";
rcl_node_options_t node5_options = rcl_node_get_default_options();
ret = rcl_node_init(node5_ptr, node5_name, node5_namespace, &context, &node5_options);
ASSERT_EQ(RCL_RET_OK, ret) << rcl_get_error_string().str;
expected_nodes.insert(std::make_pair(std::string(node5_name), std::string(node5_namespace)));
std::this_thread::sleep_for(1s); std::this_thread::sleep_for(1s);
rcutils_string_array_t node_names = rcutils_get_zero_initialized_string_array(); rcutils_string_array_t node_names = rcutils_get_zero_initialized_string_array();