unittests.h 449 B

123456789101112131415161718
  1. #include <stdio.h>
  2. #define COMMENT(x) printf("\n----" x "----\n");
  3. #define STR(x) #x
  4. #define STR2(x) STR(x)
  5. #define TEST(x) \
  6. if (!(x)) { \
  7. fflush(stdout); \
  8. fflush(stderr); \
  9. fprintf(stderr, "\033[31;1mFAILED:\033[22;39m " __FILE__ ":" STR2(__LINE__) " " #x "\n"); \
  10. status = 1; \
  11. } else { \
  12. fflush(stdout); \
  13. fflush(stderr); \
  14. printf("\033[32;1mOK:\033[22;39m " #x "\n"); \
  15. }