minunit.h 881 B

123456789101112131415161718192021222324252627282930
  1. #define KNRM "\x1B[0m"
  2. #define KBLU "\x1B[34m"
  3. #define KGRN "\x1B[32m"
  4. #define KERR "\x1B[5;31;50m"
  5. /* macro to print out the header for a new group of tests */
  6. #define mu_group(name) printf("%s • %s%s\n", KBLU, name, KNRM)
  7. /* macro for asserting a statement */
  8. #define mu_assert(message, test) do { \
  9. if (!(test)) { \
  10. printf("\t%s× %s%s\n", KERR, message, KNRM); \
  11. return message; \
  12. } \
  13. printf("\t%s• %s%s\n", KGRN, message, KNRM); \
  14. } while (0)
  15. /* macro for asserting a statement without printing it unless it is a failure */
  16. #define mu_silent_assert(message, test) do { \
  17. if (!(test)) { \
  18. printf("\t\t%s× %s%s\n", KERR, message, KNRM); \
  19. return message; \
  20. } \
  21. } while (0)
  22. /* run a test function and return result */
  23. #define mu_run_test(test) do { \
  24. char *message = test(); tests_run++; \
  25. if (message) { return message; } \
  26. } while (0)