parse_functions: Return booleans instead of pointers

This commit is contained in:
Max Bruckner
2017-03-14 14:17:35 +01:00
parent c9739c59fd
commit 87a204ed0b
9 changed files with 41 additions and 48 deletions

View File

@ -51,7 +51,7 @@ static void assert_not_array(const char *json)
buffer.length = strlen(json) + sizeof("");
buffer.offset = 0;
TEST_ASSERT_NULL(parse_array(item, &buffer, &error_pointer, &global_hooks));
TEST_ASSERT_FALSE(parse_array(item, &buffer, &error_pointer, &global_hooks));
assert_is_invalid(item);
}
@ -62,7 +62,7 @@ static void assert_parse_array(const char *json)
buffer.length = strlen(json) + sizeof("");
buffer.offset = 0;
TEST_ASSERT_NOT_NULL(parse_array(item, &buffer, &error_pointer, &global_hooks));
TEST_ASSERT_TRUE(parse_array(item, &buffer, &error_pointer, &global_hooks));
assert_is_array(item);
}

View File

@ -50,7 +50,7 @@ static void assert_parse_number(const char *string, int integer, double real)
buffer.length = strlen(string) + sizeof("");
buffer.offset = 0;
TEST_ASSERT_NOT_NULL(parse_number(item, &buffer));
TEST_ASSERT_TRUE(parse_number(item, &buffer));
assert_is_number(item);
TEST_ASSERT_EQUAL_INT(integer, item->valueint);
TEST_ASSERT_EQUAL_DOUBLE(real, item->valuedouble);

View File

@ -59,7 +59,7 @@ static void assert_not_object(const char *json)
parsebuffer.length = strlen(json) + sizeof("");
parsebuffer.offset = 0;
TEST_ASSERT_NULL(parse_object(item, &parsebuffer, &error_pointer, &global_hooks));
TEST_ASSERT_FALSE(parse_object(item, &parsebuffer, &error_pointer, &global_hooks));
assert_is_invalid(item);
reset(item);
}
@ -71,7 +71,7 @@ static void assert_parse_object(const char *json)
parsebuffer.length = strlen(json) + sizeof("");
parsebuffer.offset = 0;
TEST_ASSERT_NOT_NULL(parse_object(item, &parsebuffer, &error_pointer, &global_hooks));
TEST_ASSERT_TRUE(parse_object(item, &parsebuffer, &error_pointer, &global_hooks));
assert_is_object(item);
}

View File

@ -52,7 +52,7 @@ static void assert_parse_string(const char *string, const char *expected)
buffer.length = strlen(string) + sizeof("");
buffer.offset = 0;
TEST_ASSERT_NOT_NULL_MESSAGE(parse_string(item, &buffer, &error_pointer, &global_hooks), "Couldn't parse string.");
TEST_ASSERT_TRUE_MESSAGE(parse_string(item, &buffer, &error_pointer, &global_hooks), "Couldn't parse string.");
assert_is_string(item);
TEST_ASSERT_EQUAL_STRING_MESSAGE(expected, item->valuestring, "The parsed result isn't as expected.");
global_hooks.deallocate(item->valuestring);
@ -66,7 +66,7 @@ static void assert_not_parse_string(const char * const string)
buffer.length = strlen(string) + sizeof("");
buffer.offset = 0;
TEST_ASSERT_NULL_MESSAGE(parse_string(item, &buffer, &error_pointer, &global_hooks), "Malformed string should not be accepted.");
TEST_ASSERT_FALSE_MESSAGE(parse_string(item, &buffer, &error_pointer, &global_hooks), "Malformed string should not be accepted.");
assert_is_invalid(item);
}

View File

@ -48,7 +48,7 @@ static void assert_parse_value(const char *string, int type)
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));
TEST_ASSERT_TRUE(parse_value(item, &buffer, &error_pointer, &global_hooks));
assert_is_value(item, type);
}

View File

@ -53,7 +53,7 @@ static void assert_print_array(const char * const expected, const char * const i
unformatted_buffer.noalloc = true;
memset(item, 0, sizeof(item));
TEST_ASSERT_NOT_NULL_MESSAGE(parse_array(item, &parsebuffer, &error_pointer, &global_hooks), "Failed to parse array.");
TEST_ASSERT_TRUE_MESSAGE(parse_array(item, &parsebuffer, &error_pointer, &global_hooks), "Failed to parse array.");
TEST_ASSERT_TRUE_MESSAGE(print_array(item, 0, false, &unformatted_buffer, &global_hooks), "Failed to print unformatted string.");
TEST_ASSERT_EQUAL_STRING_MESSAGE(input, printed_unformatted, "Unformatted array is not correct.");

View File

@ -54,7 +54,7 @@ static void assert_print_object(const char * const expected, const char * const
unformatted_buffer.noalloc = true;
memset(item, 0, sizeof(item));
TEST_ASSERT_NOT_NULL_MESSAGE(parse_object(item, &parsebuffer, &error_pointer, &global_hooks), "Failed to parse object.");
TEST_ASSERT_TRUE_MESSAGE(parse_object(item, &parsebuffer, &error_pointer, &global_hooks), "Failed to parse object.");
TEST_ASSERT_TRUE_MESSAGE(print_object(item, 0, false, &unformatted_buffer, &global_hooks), "Failed to print unformatted string.");
TEST_ASSERT_EQUAL_STRING_MESSAGE(input, printed_unformatted, "Unformatted object is not correct.");

View File

@ -46,7 +46,7 @@ static void assert_print_value(const char *input)
memset(item, 0, sizeof(item));
TEST_ASSERT_NOT_NULL_MESSAGE(parse_value(item, &parsebuffer, &error_pointer, &global_hooks), "Failed to parse value.");
TEST_ASSERT_TRUE_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.");