MCPcopy Create free account
hub / github.com/ElementsProject/lightning / main

Function main

common/test/run-bigsize.c:326–370  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

324}
325
326int main(int argc, char *argv[])
327{
328 char **lines, *json = NULL;
329 int test_count = 0;
330
331 common_setup(argv[0]);
332
333 lines = tal_strsplit(tmpctx, grab_file(tmpctx, tal_fmt(tmpctx, "%s.c",
334 argv[0])),
335 "\n", STR_NO_EMPTY);
336
337 for (size_t i = 0; lines[i]; i++) {
338 const char *l = lines[i];
339 if (!strstarts(l, " * "))
340 continue;
341 l += 3;
342 if (streq(l, "```json"))
343 json = tal_strdup(tmpctx, "");
344 else if (streq(l, "```")) {
345 jsmn_parser parser;
346 jsmntok_t toks[500];
347
348 jsmn_init(&parser);
349 if (jsmn_parse(&parser, json, strlen(json),
350 toks, ARRAY_SIZE(toks)) < 0)
351 abort();
352
353 switch (test_count) {
354 case 0:
355 test_decode(json, toks);
356 break;
357 case 1:
358 test_encode(json, toks);
359 break;
360 default:
361 abort();
362 }
363 test_count++;
364 json = NULL;
365 } else if (json)
366 tal_append_fmt(&json, "%s", l);
367 }
368 assert(test_count == 2);
369 common_shutdown();
370}

Callers

nothing calls this directly

Calls 7

common_setupFunction · 0.85
grab_fileFunction · 0.85
abortFunction · 0.85
tal_append_fmtFunction · 0.85
common_shutdownFunction · 0.85
test_decodeFunction · 0.70
test_encodeFunction · 0.70

Tested by

no test coverage detected