cJSON_ConfigurationChangeParseEnd -> cJSON_ConfigurationGetParseEnd

This is probably a better approach than potentially having a pointer
that points to garbage on the stack and gets written to by cJSON.
This commit is contained in:
Max Bruckner
2018-02-03 04:28:44 +01:00
parent 691a83a479
commit d2d19127d3
4 changed files with 18 additions and 32 deletions

View File

@@ -129,18 +129,12 @@ static void configuration_change_userdata_should_change_userdata(void)
free(configuration);
}
static void configuration_change_parse_end_should_change_parse_end(void)
static void configuration_get_parse_end_should_get_the_parse_end(void)
{
size_t end_position = 0;
internal_configuration *configuration = (internal_configuration*)cJSON_CreateConfiguration(NULL, NULL);
TEST_ASSERT_NOT_NULL(configuration);
internal_configuration configuration = global_default_configuration;
configuration.end_position = 42;
configuration = (internal_configuration*)cJSON_ConfigurationChangeParseEnd(configuration, &end_position);
TEST_ASSERT_NOT_NULL(configuration);
TEST_ASSERT_TRUE_MESSAGE(configuration->end_position == &end_position, "Failed to set parse end.");
free(configuration);
TEST_ASSERT_EQUAL_MESSAGE(cJSON_ConfigurationGetParseEnd(&configuration), 42, "Failed to get parse end.");
}
static void configuration_change_prebuffer_size_should_change_buffer_size(void)
@@ -220,7 +214,7 @@ int main(void)
RUN_TEST(configuration_change_allocators_should_change_allocators);
RUN_TEST(configuration_change_allocators_should_not_change_incomplete_allocators);
RUN_TEST(configuration_change_userdata_should_change_userdata);
RUN_TEST(configuration_change_parse_end_should_change_parse_end);
RUN_TEST(configuration_get_parse_end_should_get_the_parse_end);
RUN_TEST(configuration_change_prebuffer_size_should_change_buffer_size);
RUN_TEST(configuration_change_prebuffer_size_should_not_allow_empty_sizes);
RUN_TEST(configuration_change_format_should_change_format);