unittests.h 683 B

1234567891011121314151617181920212223242526
  1. #include <stdio.h>
  2. #ifdef UNITTESTS_SHORT_MSGS
  3. /* Short debug messages for platforms with limited memory */
  4. #define COMMENT(x) printf("\n----" x "----\n");
  5. #define TEST(x) \
  6. if (!(x)) { \
  7. fprintf(stderr, "FAIL: Line %d\n", __LINE__); \
  8. status = 1; \
  9. } else { \
  10. printf("OK: Line %d\n", __LINE__); \
  11. }
  12. #else
  13. /* Elaborate debug messages for normal development */
  14. #define COMMENT(x) printf("\n----" x "----\n");
  15. #define TEST(x) \
  16. if (!(x)) { \
  17. fprintf(stderr, "\033[31;1mFAILED:\033[22;39m %s:%d %s\n", __FILE__, __LINE__, #x); \
  18. status = 1; \
  19. } else { \
  20. printf("\033[32;1mOK:\033[22;39m %s\n", #x); \
  21. }
  22. #endif