#pragma once typedef bool (*test_t)(const char ** scenario); #define RUNNER(tests) \ int main() \ { \ int fail_count = 0; \ for (int i = 0; i < (sizeof (tests)) / (sizeof (test_t)); i++) { \ const char * scenario; \ bool result = tests[i](&scenario); \ const char * result_s = result ? "ok" : "fail"; \ fail_count += !result; \ fprintf(stderr, "%s: %s\n", scenario, result_s); \ } \ fprintf(stderr, "\nfailed tests: %d\n", fail_count); \ \ return !(fail_count == 0); \ }