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

Function test_array_char_escaping

dpdk/app/test/test_telemetry_json.c:143–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

141}
142
143static int
144test_array_char_escaping(void)
145{
146 /* "meaning of life", with tab between first two words, '\n' at end,
147 * and "life" in quotes, followed by "all the fish" in quotes
148 */
149 const char *expected = "[\"meaning\\tof \\\"life\\\"\\n\",\"\\\"all the fish\\\"\"]";
150 char buf[1024];
151 int used = 0;
152
153 used = rte_tel_json_empty_array(buf, sizeof(buf), used);
154 if (used != 2 || strcmp(buf, "[]"))
155 return -1;
156
157 used = rte_tel_json_add_array_string(buf, sizeof(buf), used, "meaning\tof \"life\"\n");
158 used = rte_tel_json_add_array_string(buf, sizeof(buf), used, "\"all the fish\"");
159
160 printf("buf = '%s', expected = '%s'\n", buf, expected);
161 if (used != (int)strlen(expected))
162 return -1;
163 return strncmp(expected, buf, sizeof(buf));
164}
165
166static int
167test_obj_char_escaping(void)

Callers

nothing calls this directly

Calls 5

rte_tel_json_empty_arrayFunction · 0.85
strcmpFunction · 0.85
strncmpFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected