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

Function main

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 7

common_setupFunction · 0.85
grab_file_strFunction · 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