mirror of
https://github.com/DaveGamble/cJSON.git
synced 2023-08-10 21:13:26 +03:00
cJSON_ConfigurationChangeParseEnd
Add a pointer to an end position of parsing to the cJSON_Configuration object. (Essentially like return_parse_end, but as offset instead of pointer).
This commit is contained in:
@@ -129,6 +129,20 @@ static void configuration_change_userdata_should_change_userdata(void)
|
||||
free(configuration);
|
||||
}
|
||||
|
||||
static void configuration_change_parse_end_should_change_parse_end(void)
|
||||
{
|
||||
size_t end_position = 0;
|
||||
internal_configuration *configuration = (internal_configuration*)cJSON_CreateConfiguration(NULL, NULL, NULL);
|
||||
TEST_ASSERT_NOT_NULL(configuration);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
UNITY_BEGIN();
|
||||
@@ -138,6 +152,7 @@ int main(void)
|
||||
RUN_TEST(create_configuration_should_take_custom_allocators);
|
||||
RUN_TEST(configuration_change_allocators_should_change_allocators);
|
||||
RUN_TEST(configuration_change_userdata_should_change_userdata);
|
||||
RUN_TEST(configuration_change_parse_end_should_change_parse_end);
|
||||
|
||||
return UNITY_END();
|
||||
}
|
||||
|
||||
@@ -420,7 +420,7 @@ static void *failing_realloc(void *pointer, size_t size, void *userdata)
|
||||
|
||||
static void ensure_should_fail_on_failed_realloc(void)
|
||||
{
|
||||
printbuffer buffer = {NULL, 10, 0, 0, false, {256, false, true, true, {global_allocate_wrapper, global_deallocate_wrapper, failing_realloc}, NULL } };
|
||||
printbuffer buffer = {NULL, 10, 0, 0, false, {256, false, true, true, {global_allocate_wrapper, global_deallocate_wrapper, failing_realloc}, NULL, NULL } };
|
||||
buffer.configuration.userdata = &buffer;
|
||||
buffer.buffer = (unsigned char*)malloc(100);
|
||||
TEST_ASSERT_NOT_NULL(buffer.buffer);
|
||||
|
||||
Reference in New Issue
Block a user