Allow empty strings if they are quoted. (#450)

Signed-off-by: Ralf Anton Beier <ralf_beier@me.com>
This commit is contained in:
Ralf Anton Beier 2019-05-24 17:57:47 +02:00 committed by Dirk Thomas
parent 9566f39d60
commit 5f0d331712
3 changed files with 32 additions and 1 deletions

View file

@ -0,0 +1,9 @@
# config/test_yaml
---
lidar_ns:
lidar_1:
ros__parameters:
id: 10
name: ""
another: ''

View file

@ -172,6 +172,25 @@ TEST(test_file_parser, max_string_sz) {
allocator.deallocate(path, allocator.state);
}
TEST(test_file_parser, empty_string) {
rcutils_reset_error();
EXPECT_TRUE(rcutils_get_cwd(cur_dir, 1024));
rcutils_allocator_t allocator = rcutils_get_default_allocator();
char * test_path = rcutils_join_path(cur_dir, "test", allocator);
char * path = rcutils_join_path(test_path, "empty_string.yaml", allocator);
fprintf(stderr, "cur_path: %s\n", path);
EXPECT_TRUE(rcutils_exists(path));
rcl_params_t * params_hdl = rcl_yaml_node_struct_init(allocator);
EXPECT_FALSE(NULL == params_hdl);
bool res = rcl_parse_yaml_file(path, params_hdl);
fprintf(stderr, "%s\n", rcutils_get_error_string().str);
EXPECT_TRUE(res);
rcl_yaml_node_struct_print(params_hdl);
rcl_yaml_node_struct_fini(params_hdl);
allocator.deallocate(test_path, allocator.state);
allocator.deallocate(path, allocator.state);
}
TEST(test_file_parser, no_value1) {
rcutils_reset_error();
EXPECT_TRUE(rcutils_get_cwd(cur_dir, 1024));