Skip to content

Instantly share code, notes, and snippets.

@chelseakomlo
Created September 3, 2015 23:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chelseakomlo/0bf45b175966972cbdf3 to your computer and use it in GitHub Desktop.
Save chelseakomlo/0bf45b175966972cbdf3 to your computer and use it in GitHub Desktop.
#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