Use space after object keys in pretty-print output; update unit tests

This commit is contained in:
Ondřej Hruška 2020-07-14 14:44:37 +02:00
parent cf97c6f066
commit 6b15bb73e7
11 changed files with 217 additions and 217 deletions

View File

@ -1765,7 +1765,7 @@ static cJSON_bool print_object(const cJSON * const item, printbuffer * const out
*output_pointer++ = ':';
if (output_buffer->format)
{
*output_pointer++ = '\t';
*output_pointer++ = ' ';
}
output_buffer->offset += length;

View File

@ -76,16 +76,16 @@ static void print_object_should_print_empty_objects(void)
static void print_object_should_print_objects_with_one_element(void)
{
assert_print_object("{\n\t\"one\":\t1\n}", "{\"one\":1}");
assert_print_object("{\n\t\"hello\":\t\"world!\"\n}", "{\"hello\":\"world!\"}");
assert_print_object("{\n\t\"array\":\t[]\n}", "{\"array\":[]}");
assert_print_object("{\n\t\"null\":\tnull\n}", "{\"null\":null}");
assert_print_object("{\n\t\"one\": 1\n}", "{\"one\":1}");
assert_print_object("{\n\t\"hello\": \"world!\"\n}", "{\"hello\":\"world!\"}");
assert_print_object("{\n\t\"array\": []\n}", "{\"array\":[]}");
assert_print_object("{\n\t\"null\": null\n}", "{\"null\":null}");
}
static void print_object_should_print_objects_with_multiple_elements(void)
{
assert_print_object("{\n\t\"one\":\t1,\n\t\"two\":\t2,\n\t\"three\":\t3\n}", "{\"one\":1,\"two\":2,\"three\":3}");
assert_print_object("{\n\t\"one\":\t1,\n\t\"NULL\":\tnull,\n\t\"TRUE\":\ttrue,\n\t\"FALSE\":\tfalse,\n\t\"array\":\t[],\n\t\"world\":\t\"hello\",\n\t\"object\":\t{\n\t}\n}", "{\"one\":1,\"NULL\":null,\"TRUE\":true,\"FALSE\":false,\"array\":[],\"world\":\"hello\",\"object\":{}}");
assert_print_object("{\n\t\"one\": 1,\n\t\"two\": 2,\n\t\"three\": 3\n}", "{\"one\":1,\"two\":2,\"three\":3}");
assert_print_object("{\n\t\"one\": 1,\n\t\"NULL\": null,\n\t\"TRUE\": true,\n\t\"FALSE\": false,\n\t\"array\": [],\n\t\"world\": \"hello\",\n\t\"object\": {\n\t}\n}", "{\"one\":1,\"NULL\":null,\"TRUE\":true,\"FALSE\":false,\"array\":[],\"world\":\"hello\",\"object\":{}}");
}
int CJSON_CDECL main(void)

View File

@ -29,16 +29,16 @@
#include "common.h"
static const char *json = "{\n\
\t\"name\":\t\"Awesome 4K\",\n\
\t\"resolutions\":\t[{\n\
\t\t\t\"width\":\t1280,\n\
\t\t\t\"height\":\t720\n\
\t\"name\": \"Awesome 4K\",\n\
\t\"resolutions\": [{\n\
\t\t\t\"width\": 1280,\n\
\t\t\t\"height\": 720\n\
\t\t}, {\n\
\t\t\t\"width\":\t1920,\n\
\t\t\t\"height\":\t1080\n\
\t\t\t\"width\": 1920,\n\
\t\t\t\"height\": 1080\n\
\t\t}, {\n\
\t\t\t\"width\":\t3840,\n\
\t\t\t\"height\":\t2160\n\
\t\t\t\"width\": 3840,\n\
\t\t\t\"height\": 2160\n\
\t\t}]\n\
}";
@ -236,9 +236,9 @@ static void supports_full_hd_should_check_for_full_hd_support(void)
{
static const char *monitor_without_hd = "{\n\
\t\t\"name\": \"lame monitor\",\n\
\t\t\"resolutions\":\t[{\n\
\t\t\t\"width\":\t640,\n\
\t\t\t\"height\":\t480\n\
\t\t\"resolutions\": [{\n\
\t\t\t\"width\": 640,\n\
\t\t\t\"height\": 480\n\
\t\t}]\n\
}";