parse_value: Use parse_buffer

This commit is contained in:
Max Bruckner
2017-03-14 10:15:57 +01:00
parent 0f98214e71
commit fd0320cf54
3 changed files with 75 additions and 23 deletions

View File

@@ -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.");