Created
June 26, 2022 03:50
-
-
Save louisswarren/a9847e3815cb7d2c5ef8ae77bc1c99c4 to your computer and use it in GitHub Desktop.
Simple testing in C
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int | |
check(const char *s, int p) | |
{ | |
static int passes = 0; | |
static int failures = 0; | |
const char *fail = "\x1B[31mFAIL\x1B[0m"; | |
const char *pass = "\x1B[34mPASS\x1B[0m"; | |
if (s) { | |
fprintf(stderr, "[%s] %s\n", p ? pass : fail, s); | |
passes += p; | |
failures += !p; | |
return 0; | |
} | |
fprintf(stderr, "#%s: %d of %d\n", pass, passes, passes + failures); | |
if (failures == 0) | |
return 0; | |
fprintf(stderr, "#%s: %d of %d\n", fail, failures, passes + failures); | |
return 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment