_tap.c (716B)
1 #include <stdarg.h> 2 #include <stdint.h> 3 #include <stdio.h> 4 5 static unsigned test_no; 6 static unsigned test_failures; 7 8 static void tap_begin(const char *name) { 9 printf("TAP version 13\n"); 10 printf("# %s\n", name); 11 } 12 13 static void tap(uint32_t ok, const char *what, const char *fmt, ...) { 14 test_no++; 15 printf("%s %u - %s\n", ok ? "ok" : "not ok", test_no, what); 16 if (!ok) { 17 va_list ap; 18 va_start(ap, fmt); 19 fputs("# ", stdout); 20 vprintf(fmt, ap); 21 fputc('\n', stdout); 22 va_end(ap); 23 test_failures++; 24 } 25 } 26 27 static int tap_plan(void) { 28 printf("1..%u\n", test_no); 29 if (test_failures) { 30 printf("# %u of %u assertions failed\n", test_failures, test_no); 31 return 1; 32 } 33 return 0; 34 }