Skip to content

Instantly share code, notes, and snippets.

@orotemo
Created October 19, 2016 12:07
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 orotemo/453ffe50141de65132899439ab6a1838 to your computer and use it in GitHub Desktop.
Save orotemo/453ffe50141de65132899439ab6a1838 to your computer and use it in GitHub Desktop.
#ifndef __MINUNIT_H__
#define __MINUNIT_H__
#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;
#endif //__MINUNIT_H__
#include "minunit.h"
static char * test_something() {
mu_assert("should have something true, or this prints!", 3 == 3);
return 0;
}
static char * all_tests() {
mu_run_test(test_something);
return 0;
}
int main(int argc, char **argv) {
char *result = all_tests();
if (result != 0) {
printf("%s\n", result);
}
else {
printf("ALL TESTS PASSED\n");
}
printf("Tests run: %d\n", tests_run);
return result != 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment