mirror of
https://github.com/DaveGamble/cJSON.git
synced 2023-08-10 21:13:26 +03:00
parse_value: Use parse_buffer
This commit is contained in:
@@ -44,7 +44,11 @@ static void assert_is_value(cJSON *value_item, int type)
|
||||
|
||||
static void assert_parse_value(const char *string, int type)
|
||||
{
|
||||
TEST_ASSERT_NOT_NULL(parse_value(item, (const unsigned char*)string, &error_pointer, &global_hooks));
|
||||
parse_buffer buffer;
|
||||
buffer.content = (const unsigned char*) string;
|
||||
buffer.length = strlen(string) + sizeof("");
|
||||
buffer.offset = 0;
|
||||
TEST_ASSERT_NOT_NULL(parse_value(item, &buffer, &error_pointer, &global_hooks));
|
||||
assert_is_value(item, type);
|
||||
}
|
||||
|
||||
|
@@ -34,14 +34,19 @@ static void assert_print_value(const char *input)
|
||||
const unsigned char *error_pointer = NULL;
|
||||
cJSON item[1];
|
||||
printbuffer buffer;
|
||||
parse_buffer parsebuffer;
|
||||
buffer.buffer = printed;
|
||||
buffer.length = sizeof(printed);
|
||||
buffer.offset = 0;
|
||||
buffer.noalloc = true;
|
||||
|
||||
parsebuffer.content = (const unsigned char*)input;
|
||||
parsebuffer.length = strlen(input) + sizeof("");
|
||||
parsebuffer.offset = 0;
|
||||
|
||||
memset(item, 0, sizeof(item));
|
||||
|
||||
TEST_ASSERT_NOT_NULL_MESSAGE(parse_value(item, (const unsigned char*)input, &error_pointer, &global_hooks), "Failed to parse value.");
|
||||
TEST_ASSERT_NOT_NULL_MESSAGE(parse_value(item, &parsebuffer, &error_pointer, &global_hooks), "Failed to parse value.");
|
||||
|
||||
TEST_ASSERT_TRUE_MESSAGE(print_value(item, 0, false, &buffer, &global_hooks), "Failed to print value.");
|
||||
TEST_ASSERT_EQUAL_STRING_MESSAGE(input, buffer.buffer, "Printed value is not as expected.");
|
||||
|
Reference in New Issue
Block a user