| 141 | } |
| 142 | |
| 143 | static int |
| 144 | test_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 | |
| 166 | static int |
| 167 | test_obj_char_escaping(void) |
nothing calls this directly
no test coverage detected