MCPcopy Create free account
hub / github.com/F-Stack/f-stack / test_obj_char_escaping

Function test_obj_char_escaping

dpdk/app/test/test_telemetry_json.c:166–187  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164}
165
166static int
167test_obj_char_escaping(void)
168{
169 const char *expected = "{\"good\":\"Clint Eastwood\\n\","
170 "\"bad\":\"Lee\\tVan\\tCleef\","
171 "\"ugly\":\"\\rEli Wallach\"}";
172 char buf[1024];
173 int used = 0;
174
175 used = rte_tel_json_empty_obj(buf, sizeof(buf), used);
176 if (used != 2 || strcmp(buf, "{}"))
177 return -1;
178
179 used = rte_tel_json_add_obj_str(buf, sizeof(buf), used, "good", "Clint Eastwood\n");
180 used = rte_tel_json_add_obj_str(buf, sizeof(buf), used, "bad", "Lee\tVan\tCleef");
181 used = rte_tel_json_add_obj_str(buf, sizeof(buf), used, "ugly", "\rEli Wallach");
182
183 printf("buf = '%s', expected = '%s'\n", buf, expected);
184 if (used != (int)strlen(expected))
185 return -1;
186 return strncmp(expected, buf, sizeof(buf));
187}
188
189typedef int (*test_fn)(void);
190

Callers

nothing calls this directly

Calls 5

rte_tel_json_empty_objFunction · 0.85
strcmpFunction · 0.85
rte_tel_json_add_obj_strFunction · 0.85
strncmpFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected