diff --git a/rcl_yaml_param_parser/src/parse.c b/rcl_yaml_param_parser/src/parse.c index ba58d7da3f..1d7c050891 100644 --- a/rcl_yaml_param_parser/src/parse.c +++ b/rcl_yaml_param_parser/src/parse.c @@ -509,7 +509,8 @@ rcutils_ret_t parse_descriptor( return RCUTILS_RET_ERROR; } // If parsing a yaml value, then current parameter namespace must be parameter name - allocator.deallocate(params_st->descriptors[node_idx].parameter_names[parameter_idx], + allocator.deallocate( + params_st->descriptors[node_idx].parameter_names[parameter_idx], allocator.state); params_st->descriptors[node_idx].parameter_names[parameter_idx] = rcutils_strdup(ns_tracker->parameter_ns, allocator); @@ -526,8 +527,9 @@ rcutils_ret_t parse_descriptor( return RCUTILS_RET_ERROR; } - if (0 == strncmp("additional_constraints", ns_tracker->descriptor_key_ns, - strlen("additional_constraints"))) + if (0 == strncmp( + "additional_constraints", ns_tracker->descriptor_key_ns, + strlen("additional_constraints"))) { if (val_type == DATA_TYPE_STRING) { param_descriptor->additional_constraints = (char *)ret_val; @@ -947,8 +949,9 @@ rcutils_ret_t parse_key( ret = RCUTILS_RET_ERROR; break; } - ret = replace_ns(ns_tracker, parameter_ns, (ns_tracker->num_parameter_ns + 1U), - NS_TYPE_PARAM, allocator); + ret = replace_ns( + ns_tracker, parameter_ns, (ns_tracker->num_parameter_ns + 1U), + NS_TYPE_PARAM, allocator); if (RCUTILS_RET_OK != ret) { RCUTILS_SET_ERROR_MSG_WITH_FORMAT_STRING( "Internal error replacing namespace at line %d", line_num); @@ -972,9 +975,10 @@ rcutils_ret_t parse_key( } ret = - replace_ns(ns_tracker, rcutils_strdup(value, allocator), - (ns_tracker->num_descriptor_key_ns + 1U), - NS_TYPE_DESCRIPTOR, allocator); + replace_ns( + ns_tracker, rcutils_strdup(value, allocator), + (ns_tracker->num_descriptor_key_ns + 1U), + NS_TYPE_DESCRIPTOR, allocator); if (RCUTILS_RET_OK != ret) { RCUTILS_SET_ERROR_MSG_WITH_FORMAT_STRING( "Internal error replacing namespace at line %d", line_num); @@ -1091,8 +1095,9 @@ rcutils_ret_t parse_file_events( if (map_level != 3U) { ret = parse_value(event, is_seq, node_idx, parameter_idx, &seq_data_type, params_st); } else { - ret = parse_descriptor(ns_tracker, event, is_seq, node_idx, parameter_idx, - params_st); + ret = parse_descriptor( + ns_tracker, event, is_seq, node_idx, parameter_idx, + params_st); } if (RCUTILS_RET_OK != ret) { break; diff --git a/rcl_yaml_param_parser/test/test_node_params_descriptors.cpp b/rcl_yaml_param_parser/test/test_node_params_descriptors.cpp index 87a79913fc..a9d435b68f 100644 --- a/rcl_yaml_param_parser/test/test_node_params_descriptors.cpp +++ b/rcl_yaml_param_parser/test/test_node_params_descriptors.cpp @@ -39,8 +39,9 @@ TEST(TestNodeParamsDescriptors, init_fini) { TEST(TestNodeParamsDescriptors, init_with_capacity_fini) { rcutils_allocator_t allocator = rcutils_get_default_allocator(); rcl_node_params_descriptors_t node_descriptors = {NULL, NULL, 0u, 1024u}; - EXPECT_EQ(RCUTILS_RET_OK, node_params_descriptors_init_with_capacity( - &node_descriptors, 1024, allocator)); + EXPECT_EQ( + RCUTILS_RET_OK, node_params_descriptors_init_with_capacity( + &node_descriptors, 1024, allocator)); EXPECT_NE(nullptr, node_descriptors.parameter_names); EXPECT_NE(nullptr, node_descriptors.parameter_descriptors); EXPECT_EQ(0u, node_descriptors.num_params); @@ -59,8 +60,9 @@ TEST(TestNodeParamsDescriptors, init_with_capacity_fini) { TEST(TestNodeParamsDescriptors, reallocate_with_capacity_fini) { rcutils_allocator_t allocator = rcutils_get_default_allocator(); rcl_node_params_descriptors_t node_descriptors = {NULL, NULL, 0u, 1024u}; - EXPECT_EQ(RCUTILS_RET_OK, node_params_descriptors_init_with_capacity( - &node_descriptors, 1024, allocator)); + EXPECT_EQ( + RCUTILS_RET_OK, node_params_descriptors_init_with_capacity( + &node_descriptors, 1024, allocator)); EXPECT_NE(nullptr, node_descriptors.parameter_names); EXPECT_NE(nullptr, node_descriptors.parameter_descriptors); EXPECT_EQ(0u, node_descriptors.num_params); diff --git a/rcl_yaml_param_parser/test/test_parse.cpp b/rcl_yaml_param_parser/test/test_parse.cpp index ee1a426698..2ce4f86afa 100644 --- a/rcl_yaml_param_parser/test/test_parse.cpp +++ b/rcl_yaml_param_parser/test/test_parse.cpp @@ -175,7 +175,8 @@ TEST(TestParse, parse_descriptor) { RCUTILS_RET_OK, parse_descriptor(&ns_tracker, event, is_seq, node_idx, parameter_idx, params_st)) << rcutils_get_error_string().str; - ASSERT_NE(nullptr, + ASSERT_NE( + nullptr, params_st->descriptors[node_idx].parameter_descriptors[parameter_idx].read_only); EXPECT_TRUE(*params_st->descriptors[node_idx].parameter_descriptors[parameter_idx].read_only); allocator.deallocate( @@ -193,9 +194,11 @@ TEST(TestParse, parse_descriptor) { RCUTILS_RET_OK, parse_descriptor(&ns_tracker, event, is_seq, node_idx, parameter_idx, params_st)) << rcutils_get_error_string().str; - ASSERT_NE(nullptr, + ASSERT_NE( + nullptr, params_st->descriptors[node_idx].parameter_descriptors[parameter_idx].min_value_int); - EXPECT_EQ(28, + EXPECT_EQ( + 28, *params_st->descriptors[node_idx].parameter_descriptors[parameter_idx].min_value_int); allocator.deallocate( params_st->descriptors[node_idx].parameter_descriptors[parameter_idx].min_value_int, @@ -209,9 +212,11 @@ TEST(TestParse, parse_descriptor) { RCUTILS_RET_OK, parse_descriptor(&ns_tracker, event, is_seq, node_idx, parameter_idx, params_st)) << rcutils_get_error_string().str; - ASSERT_NE(nullptr, + ASSERT_NE( + nullptr, params_st->descriptors[node_idx].parameter_descriptors[parameter_idx].min_value_double); - EXPECT_EQ(1.23456, + EXPECT_EQ( + 1.23456, *params_st->descriptors[node_idx].parameter_descriptors[parameter_idx].min_value_double); allocator.deallocate( params_st->descriptors[node_idx].parameter_descriptors[parameter_idx].min_value_double, @@ -228,9 +233,11 @@ TEST(TestParse, parse_descriptor) { RCUTILS_RET_OK, parse_descriptor(&ns_tracker, event, is_seq, node_idx, parameter_idx, params_st)) << rcutils_get_error_string().str; - ASSERT_NE(nullptr, + ASSERT_NE( + nullptr, params_st->descriptors[node_idx].parameter_descriptors[parameter_idx].max_value_int); - EXPECT_EQ(28, + EXPECT_EQ( + 28, *params_st->descriptors[node_idx].parameter_descriptors[parameter_idx].max_value_int); allocator.deallocate( params_st->descriptors[node_idx].parameter_descriptors[parameter_idx].max_value_int, @@ -244,9 +251,11 @@ TEST(TestParse, parse_descriptor) { RCUTILS_RET_OK, parse_descriptor(&ns_tracker, event, is_seq, node_idx, parameter_idx, params_st)) << rcutils_get_error_string().str; - ASSERT_NE(nullptr, + ASSERT_NE( + nullptr, params_st->descriptors[node_idx].parameter_descriptors[parameter_idx].max_value_double); - EXPECT_EQ(1.23456, + EXPECT_EQ( + 1.23456, *params_st->descriptors[node_idx].parameter_descriptors[parameter_idx].max_value_double); allocator.deallocate( params_st->descriptors[node_idx].parameter_descriptors[parameter_idx].max_value_double, @@ -254,7 +263,7 @@ TEST(TestParse, parse_descriptor) { allocator.deallocate(ns_tracker.descriptor_key_ns, allocator.state); params_st->descriptors[node_idx].parameter_descriptors[parameter_idx].max_value_double = nullptr; - // step (int) + // step (int) ns_tracker.descriptor_key_ns = rcutils_strdup("step", allocator); ASSERT_STREQ("step", ns_tracker.descriptor_key_ns); event.data.scalar.value = int_value; @@ -263,7 +272,8 @@ TEST(TestParse, parse_descriptor) { RCUTILS_RET_OK, parse_descriptor(&ns_tracker, event, is_seq, node_idx, parameter_idx, params_st)) << rcutils_get_error_string().str; - ASSERT_NE(nullptr, + ASSERT_NE( + nullptr, params_st->descriptors[node_idx].parameter_descriptors[parameter_idx].step_int); EXPECT_EQ(28, *params_st->descriptors[node_idx].parameter_descriptors[parameter_idx].step_int); allocator.deallocate( @@ -278,9 +288,11 @@ TEST(TestParse, parse_descriptor) { RCUTILS_RET_OK, parse_descriptor(&ns_tracker, event, is_seq, node_idx, parameter_idx, params_st)) << rcutils_get_error_string().str; - ASSERT_NE(nullptr, + ASSERT_NE( + nullptr, params_st->descriptors[node_idx].parameter_descriptors[parameter_idx].step_double); - EXPECT_EQ(1.23456, + EXPECT_EQ( + 1.23456, *params_st->descriptors[node_idx].parameter_descriptors[parameter_idx].step_double); allocator.deallocate( params_st->descriptors[node_idx].parameter_descriptors[parameter_idx].step_double, @@ -297,7 +309,8 @@ TEST(TestParse, parse_descriptor) { RCUTILS_RET_OK, parse_descriptor(&ns_tracker, event, is_seq, node_idx, parameter_idx, params_st)) << rcutils_get_error_string().str; - ASSERT_NE(nullptr, + ASSERT_NE( + nullptr, params_st->descriptors[node_idx].parameter_descriptors[parameter_idx].description); EXPECT_STREQ( "I am a string", @@ -317,8 +330,9 @@ TEST(TestParse, parse_descriptor) { RCUTILS_RET_OK, parse_descriptor(&ns_tracker, event, is_seq, node_idx, parameter_idx, params_st)) << rcutils_get_error_string().str; - ASSERT_NE(nullptr, - params_st->descriptors[node_idx].parameter_descriptors[parameter_idx].additional_constraints); + ASSERT_NE( + nullptr, + params_st->descriptors[node_idx].parameter_descriptors[parameter_idx].additional_constraints); EXPECT_STREQ( "I am a string", params_st->descriptors[node_idx].parameter_descriptors[parameter_idx].additional_constraints); @@ -546,7 +560,7 @@ TEST(TestParse, parse_descriptor_bad_types) { params_st->descriptors[node_idx].parameter_descriptors[parameter_idx].max_value_int = nullptr; rcutils_reset_error(); - // step (int) + // step (int) ns_tracker.descriptor_key_ns = rcutils_strdup("step", allocator); ASSERT_STREQ("step", ns_tracker.descriptor_key_ns); // step: catch invalid value type diff --git a/rcl_yaml_param_parser/test/test_parse_yaml.cpp b/rcl_yaml_param_parser/test/test_parse_yaml.cpp index 66f4983efb..f60c31486a 100644 --- a/rcl_yaml_param_parser/test/test_parse_yaml.cpp +++ b/rcl_yaml_param_parser/test/test_parse_yaml.cpp @@ -667,18 +667,21 @@ TEST(test_file_parser, correct_syntax_descriptors) { rcutils_allocator_t allocator = rcutils_get_default_allocator(); char * test_path = rcutils_join_path(cur_dir, "test", allocator); ASSERT_TRUE(NULL != test_path) << rcutils_get_error_string().str; - OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT({ + OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT( + { allocator.deallocate(test_path, allocator.state); }); char * path = rcutils_join_path(test_path, "correct_param_descriptors.yaml", allocator); ASSERT_TRUE(NULL != path) << rcutils_get_error_string().str; - OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT({ + OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT( + { allocator.deallocate(path, allocator.state); }); ASSERT_TRUE(rcutils_exists(path)) << "No test YAML file found at " << path; rcl_params_t * params_hdl = rcl_yaml_node_struct_init(allocator); ASSERT_TRUE(NULL != params_hdl) << rcutils_get_error_string().str; - OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT({ + OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT( + { rcl_yaml_node_struct_fini(params_hdl); }); bool res = rcl_parse_yaml_file(path, params_hdl); @@ -686,7 +689,8 @@ TEST(test_file_parser, correct_syntax_descriptors) { char * another_path = rcutils_join_path(test_path, "overlay_descriptors.yaml", allocator); ASSERT_TRUE(NULL != another_path) << rcutils_get_error_string().str; - OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT({ + OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT( + { allocator.deallocate(another_path, allocator.state); }); ASSERT_TRUE(rcutils_exists(another_path)) << "No test YAML file found at " << another_path; @@ -695,7 +699,8 @@ TEST(test_file_parser, correct_syntax_descriptors) { rcl_params_t * copy_of_params_hdl = rcl_yaml_node_struct_copy(params_hdl); ASSERT_TRUE(NULL != copy_of_params_hdl) << rcutils_get_error_string().str; - OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT({ + OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT( + { rcl_yaml_node_struct_fini(copy_of_params_hdl); }); @@ -773,12 +778,14 @@ TEST(test_parser, param_assign_in_descriptors) { rcutils_allocator_t allocator = rcutils_get_default_allocator(); char * test_path = rcutils_join_path(cur_dir, "test", allocator); ASSERT_TRUE(NULL != test_path) << rcutils_get_error_string().str; - OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT({ + OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT( + { allocator.deallocate(test_path, allocator.state); }); char * path = rcutils_join_path(test_path, "assign_param_in_descriptors.yaml", allocator); ASSERT_TRUE(NULL != path) << rcutils_get_error_string().str; - OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT({ + OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT( + { allocator.deallocate(path, allocator.state); }); ASSERT_TRUE(rcutils_exists(path)) << "No test YAML file found at " << path; @@ -794,12 +801,14 @@ TEST(test_parser, invalid_param_descriptor_key) { rcutils_allocator_t allocator = rcutils_get_default_allocator(); char * test_path = rcutils_join_path(cur_dir, "test", allocator); ASSERT_TRUE(NULL != test_path) << rcutils_get_error_string().str; - OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT({ + OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT( + { allocator.deallocate(test_path, allocator.state); }); char * path = rcutils_join_path(test_path, "invalid_param_descriptor_key.yaml", allocator); ASSERT_TRUE(NULL != path) << rcutils_get_error_string().str; - OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT({ + OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT( + { allocator.deallocate(path, allocator.state); }); ASSERT_TRUE(rcutils_exists(path)) << "No test YAML file found at " << path; @@ -815,12 +824,14 @@ TEST(test_parser, invalid_param_descriptor_type) { rcutils_allocator_t allocator = rcutils_get_default_allocator(); char * test_path = rcutils_join_path(cur_dir, "test", allocator); ASSERT_TRUE(NULL != test_path) << rcutils_get_error_string().str; - OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT({ + OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT( + { allocator.deallocate(test_path, allocator.state); }); char * path = rcutils_join_path(test_path, "invalid_param_descriptor_type.yaml", allocator); ASSERT_TRUE(NULL != path) << rcutils_get_error_string().str; - OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT({ + OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT( + { allocator.deallocate(path, allocator.state); }); ASSERT_TRUE(rcutils_exists(path)) << "No test YAML file found at " << path; @@ -836,12 +847,14 @@ TEST(test_parser, no_value_descriptor) { rcutils_allocator_t allocator = rcutils_get_default_allocator(); char * test_path = rcutils_join_path(cur_dir, "test", allocator); ASSERT_TRUE(NULL != test_path) << rcutils_get_error_string().str; - OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT({ + OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT( + { allocator.deallocate(test_path, allocator.state); }); char * path = rcutils_join_path(test_path, "no_value_descriptor.yaml", allocator); ASSERT_TRUE(NULL != path) << rcutils_get_error_string().str; - OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT({ + OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT( + { allocator.deallocate(path, allocator.state); }); ASSERT_TRUE(rcutils_exists(path)) << "No test YAML file found at " << path;