MCPcopy Create free account
hub / github.com/DaveGamble/cJSON / cjson_minify_should_minify_json

Function cjson_minify_should_minify_json

tests/minify_tests.c:100–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98}
99
100static void cjson_minify_should_minify_json(void) {
101 const char to_minify[] =
102 "{\n"
103 " \"glossary\": { // comment\n"
104 " \"title\": \"example glossary\",\n"
105 " /* multi\n"
106 " line */\n"
107 " \"GlossDiv\": {\n"
108 " \"title\": \"S\",\n"
109 " \"GlossList\": {\n"
110 " \"GlossEntry\": {\n"
111 " \"ID\": \"SGML\",\n"
112 " \"SortAs\": \"SGML\",\n"
113 " \"Acronym\": \"SGML\",\n"
114 " \"Abbrev\": \"ISO 8879:1986\",\n"
115 " \"GlossDef\": {\n"
116 " \"GlossSeeAlso\": [\"GML\", \"XML\"]\n"
117 " },\n"
118 " \"GlossSee\": \"markup\"\n"
119 " }\n"
120 " }\n"
121 " }\n"
122 " }\n"
123 "}";
124 const char* minified =
125 "{"
126 "\"glossary\":{"
127 "\"title\":\"example glossary\","
128 "\"GlossDiv\":{"
129 "\"title\":\"S\","
130 "\"GlossList\":{"
131 "\"GlossEntry\":{"
132 "\"ID\":\"SGML\","
133 "\"SortAs\":\"SGML\","
134 "\"Acronym\":\"SGML\","
135 "\"Abbrev\":\"ISO 8879:1986\","
136 "\"GlossDef\":{"
137 "\"GlossSeeAlso\":[\"GML\",\"XML\"]"
138 "},"
139 "\"GlossSee\":\"markup\""
140 "}"
141 "}"
142 "}"
143 "}"
144 "}";
145
146 char *buffer = (char*) malloc(sizeof(to_minify));
147 strcpy(buffer, to_minify);
148
149 cJSON_Minify(buffer);
150 TEST_ASSERT_EQUAL_STRING(minified, buffer);
151
152 free(buffer);
153}
154
155static void cjson_minify_should_not_loop_infinitely(void) {
156 char string[] = { '8', ' ', '/', ' ', '5', '\n', '\0' };

Callers

nothing calls this directly

Calls 1

cJSON_MinifyFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…