Skip to content

Commit

Permalink
Rearrange test logic to avoid reference to null (#862)
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Brawner <brawner@gmail.com>
  • Loading branch information
brawner authored Nov 20, 2020
1 parent df5c8d0 commit dd1923b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions rcl_yaml_param_parser/test/test_parse_yaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,14 @@ TEST(test_parser, correct_syntax) {
rcl_variant_t * param_value = rcl_yaml_node_struct_get("lidar_ns/lidar_2", "is_back", params);
ASSERT_TRUE(NULL != param_value) << rcutils_get_error_string().str;
ASSERT_TRUE(NULL != param_value->bool_value);
EXPECT_TRUE(*param_value->bool_value);
// Assigning to local to avoid clang analysis warning "Forming reference to null pointer"
bool bool_value = *param_value->bool_value;
EXPECT_TRUE(bool_value);
res = rcl_parse_yaml_value("lidar_ns/lidar_2", "is_back", "false", params);
EXPECT_TRUE(res) << rcutils_get_error_string().str;
ASSERT_TRUE(NULL != param_value->bool_value);
EXPECT_FALSE(*param_value->bool_value);
bool_value = *param_value->bool_value;
EXPECT_FALSE(bool_value);

param_value = rcl_yaml_node_struct_get("lidar_ns/lidar_2", "id", params);
ASSERT_TRUE(NULL != param_value) << rcutils_get_error_string().str;
Expand Down

0 comments on commit dd1923b

Please sign in to comment.