| 164 | } |
| 165 | |
| 166 | static int |
| 167 | test_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 | |
| 189 | typedef int (*test_fn)(void); |
| 190 |
nothing calls this directly
no test coverage detected