Conversation
cf14a57 to
56ba274
Compare
|
Updated these files after running all the tests through valgrind. There were some memory errors with unitialized memory and a couple of leaks. |
5940d72 to
8b9dd40
Compare
|
Also depends on #775 |
ac7cf6f to
a9bab89
Compare
8b9dd40 to
422dd65
Compare
| RCUTILS_RET_OK, | ||
| parse_value(event, is_seq, node_idx, parameter_idx, &seq_data_type, params_st)) << | ||
| rcutils_get_error_string().str; | ||
| ASSERT_NE(nullptr, params_st->params[0].parameter_values[0].bool_value); |
There was a problem hiding this comment.
@brawner nit^N: should it be
| ASSERT_NE(nullptr, params_st->params[0].parameter_values[0].bool_value); | |
| ASSERT_NE(nullptr, params_st->params[node_idx].parameter_values[parameter_idx].bool_value); |
? Same elsewhere.
| ASSERT_EQ(RCUTILS_RET_OK, node_params_init(¶ms_st->params[0], allocator)); | ||
| params_st->num_nodes = 1u; | ||
|
|
||
| // event.data.scaler.value is NULL, but event.data.scalar.length > 0 |
There was a problem hiding this comment.
@brawner nit^N:
| // event.data.scaler.value is NULL, but event.data.scalar.length > 0 | |
| // event.data.scalar.value is NULL, but event.data.scalar.length > 0 |
| parse_key(event, nullptr, &is_new_map, &node_idx, ¶meter_idx, &ns_tracker, params_st)) << | ||
| rcutils_get_error_string().str; | ||
| EXPECT_TRUE(rcutils_error_is_set()); | ||
| rcutils_reset_error(); |
| ASSERT_NE(nullptr, dest_variant.field); \ | ||
| EXPECT_EQ(*src_variant.field, *dest_variant.field); \ | ||
| rcl_yaml_variant_fini(&dest_variant, allocator); \ | ||
| variant.field = nullptr; \ |
There was a problem hiding this comment.
There was a problem hiding this comment.
Cleaned this macro up a bit. Initialization of src/dest_variants now happen inside this macro. Should help prevent stuff like this.
| ASSERT_NE(nullptr, src_variant.field->values); \ | ||
| src_variant.field->size = array_size; \ | ||
| for (size_t i = 0; i < array_size; ++i) { \ | ||
| variant.field->values[i] = tmp_array[i]; \ |
There was a problem hiding this comment.
@brawner should it be
| variant.field->values[i] = tmp_array[i]; \ | |
| src_variant.field->values[i] = tmp_array[i]; \ |
?
| rcl_yaml_variant_fini(&src_variant, allocator); \ | ||
| rcl_yaml_variant_fini(&dest_variant, allocator); \ | ||
| src_variant.field = nullptr; \ | ||
| dest_variant.field = nullptr; \ |
There was a problem hiding this comment.
@brawner should this be in scoped exits in case asserts above fail?
There was a problem hiding this comment.
I adjusted how everything was cleaned up and added a bunch more scope_exits (not just for these).
| } while (0) | ||
|
|
||
| #define TEST_VARIANT_ARRAY_COPY( \ | ||
| dest_variant, src_variant, field, array_type, value_type, tmp_array, array_size, allocator) \ |
There was a problem hiding this comment.
@brawner nit: I think you can derive array_size from tmp_array considering tmp_array type is always a primitive array and its type has not decayed yet.
| } while (0) | ||
|
|
||
| TEST(TestYamlVariant, copy_fini) { | ||
| rcl_variant_t variant = |
There was a problem hiding this comment.
@brawner nit^N: since this is C++,
| rcl_variant_t variant = | |
| rcl_variant_t variant{}; |
would also work.
There was a problem hiding this comment.
Helps clean things up a bit, done.
| EXPECT_STREQ(variant.string_array_value->data[i], copy.string_array_value->data[i]); | ||
| } | ||
| rcl_yaml_variant_fini(&variant, allocator); | ||
| rcl_yaml_variant_fini(©, allocator); |
There was a problem hiding this comment.
@brawner should these be in scoped exits to avoid leaks if any of the asserts above fail?
a9bab89 to
7cd635f
Compare
422dd65 to
337f9ee
Compare
b062da9 to
8d72dc4
Compare
Signed-off-by: Stephen Brawner <brawner@gmail.com>
Signed-off-by: Stephen Brawner <brawner@gmail.com>
Signed-off-by: Stephen Brawner <brawner@gmail.com>
Signed-off-by: Stephen Brawner <brawner@gmail.com>
68fb9cc to
37cac47
Compare
|
Rebased on to master after merging #754. Testing |
| src_variant.field = nullptr; \ | ||
| } while (0) | ||
|
|
||
| #define TEST_VARIANT_ARRAY_COPY(field, array_type, value_type, tmp_array) \ |
There was a problem hiding this comment.
@brawner nit^N, safe to ignore: you could use decltype expressions to not have to pass types explicitly.
Signed-off-by: Stephen Brawner <brawner@gmail.com>
67df619 to
8cdc65a
Compare
…r (coverage part 1/3) (#771) * Add basic unit tests for refactored functions Signed-off-by: Stephen Brawner <brawner@gmail.com> * PR Fixup Signed-off-by: Stephen Brawner <brawner@gmail.com> * Fix memory errors Signed-off-by: Stephen Brawner <brawner@gmail.com> * headers moved Signed-off-by: Stephen Brawner <brawner@gmail.com> * Addressing feedback Signed-off-by: Stephen Brawner <brawner@gmail.com> * Switch to decltype Signed-off-by: Stephen Brawner <brawner@gmail.com>
…r (coverage part 1/3) (#771) * Add basic unit tests for refactored functions Signed-off-by: Stephen Brawner <brawner@gmail.com> * PR Fixup Signed-off-by: Stephen Brawner <brawner@gmail.com> * Fix memory errors Signed-off-by: Stephen Brawner <brawner@gmail.com> * headers moved Signed-off-by: Stephen Brawner <brawner@gmail.com> * Addressing feedback Signed-off-by: Stephen Brawner <brawner@gmail.com> * Switch to decltype Signed-off-by: Stephen Brawner <brawner@gmail.com>
This is part 1 of added unit tests for increasing coverage of rcl_yaml_param_parser to 95%. This adds additional unit tests for the refactored source code. Depends on #754 and #765
Signed-off-by: Stephen Brawner brawner@gmail.com