| 148 | /* AUTOGENERATED MOCKS END */ |
| 149 | |
| 150 | int main(int argc, char *argv[]) |
| 151 | { |
| 152 | char *json; |
| 153 | size_t i; |
| 154 | jsmn_parser parser; |
| 155 | jsmntok_t toks[5000]; |
| 156 | const jsmntok_t *t; |
| 157 | |
| 158 | common_setup(argv[0]); |
| 159 | |
| 160 | if (argv[1]) |
| 161 | json = grab_file(tmpctx, argv[1]); |
| 162 | else { |
| 163 | char *dir = getenv("BOLTDIR"); |
| 164 | json = grab_file(tmpctx, |
| 165 | path_join(tmpctx, |
| 166 | dir ? dir : "../bolts", |
| 167 | "bolt12/format-string-test.json")); |
| 168 | if (!json) { |
| 169 | printf("test file not found, skipping\n"); |
| 170 | goto out; |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | jsmn_init(&parser); |
| 175 | if (jsmn_parse(&parser, json, strlen(json), toks, ARRAY_SIZE(toks)) < 0) |
| 176 | abort(); |
| 177 | |
| 178 | json_for_each_arr(i, t, toks) { |
| 179 | bool valid, actual; |
| 180 | const jsmntok_t *strtok; |
| 181 | char *fail; |
| 182 | const char *str; |
| 183 | size_t dlen; |
| 184 | struct json_escape *esc; |
| 185 | |
| 186 | json_to_bool(json, json_get_member(json, t, "valid"), &valid); |
| 187 | strtok = json_get_member(json, t, "string"); |
| 188 | esc = json_escape_string_(tmpctx, json + strtok->start, |
| 189 | strtok->end - strtok->start); |
| 190 | str = json_escape_unescape(tmpctx, esc); |
| 191 | actual = (string_to_data(tmpctx, str, strlen(str), |
| 192 | "lno", &dlen, &fail) != NULL); |
| 193 | assert(actual == valid); |
| 194 | } |
| 195 | out: |
| 196 | common_shutdown(); |
| 197 | return 0; |
| 198 | } |
nothing calls this directly
no test coverage detected