Learning by doing: Reading books and trying to understand the (code) examples
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

15 lines
668 B

  1. // MinUnit test framework
  2. // taken from http://www.jera.com/techinfo/jtns/jtn002.html
  3. // slightly expanded, see http://stackoverflow.com/a/22732645
  4. #include <errno.h>
  5. #include <assert.h>
  6. #define mu_assert(message, test) do {if (!(test)) return message;} while (0)
  7. #define mu_run_test(test) do {char *message = test(); tests_run++; if (message) return message;} while (0)
  8. #define clean_errno() (errno == 0 ? "None" : strerror(errno))
  9. #define log_error(M, ...) fprintf(stderr, "[ERROR] (%s:%d: errno: %s) " M "\n", __FILE__, __LINE__, clean_errno(), ##__VA_ARGS__)
  10. #define assertf(A, M, ...) if(!(A)) {log_error(M, ##__VA_ARGS__); assert(A); }
  11. extern int tests_run;