Created
October 19, 2016 12:07
-
-
Save orotemo/453ffe50141de65132899439ab6a1838 to your computer and use it in GitHub Desktop.
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
#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__ |
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
#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