Created
September 3, 2015 23:44
-
-
Save chelseakomlo/0bf45b175966972cbdf3 to your computer and use it in GitHub Desktop.
This file contains 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
#include <stdio.h> | |
// miniunit | |
// source: http://www.jera.com/techinfo/jtns/jtn002.html | |
#define mu_assert(message, test) do { if (!(test)) return message; } while (0) | |
#define mu_run_test(test) do { char *message = test(); tests_run++; \ | |
if (message) return message; } while (0) | |
extern int tests_run; | |
// test | |
int tests_run = 0; | |
int foo = 8; | |
static char * test_foo() { | |
mu_assert("error, foo != 7", foo == 99); | |
return 0; | |
} | |
// test runner | |
static char * all_tests() { | |
mu_run_test(test_foo); | |
return 0; | |
} | |
int main(int argc, char *argv[]) { | |
char *results = all_tests(); | |
if(results != 0) { | |
printf("%s\n", results); | |
} else { | |
printf("all passed"); | |
} | |
return results != 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment