test_decoration.main.c 735 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #define ZF_LOG_LEVEL ZF_LOG_INFO
  2. #include <zf_log.c>
  3. #include <stdlib.h>
  4. #include <stdio.h>
  5. static int main_called;
  6. static void main_output_callback(const zf_log_message *msg, void *arg)
  7. {
  8. (void)arg;
  9. if (strncmp("main", msg->msg_b, (size_t)(msg->p - msg->msg_b)))
  10. {
  11. fprintf(stderr, "incorrect message in main\n");
  12. exit(1);
  13. }
  14. ++main_called;
  15. }
  16. void test_module();
  17. void test_main()
  18. {
  19. zf_log_set_output_v(ZF_LOG_PUT_STD, 0, main_output_callback);
  20. ZF_LOGI("main");
  21. if (!main_called)
  22. {
  23. fprintf(stderr, "main callback was not called\n");
  24. exit(1);
  25. }
  26. }
  27. int main(int argc, char *argv[])
  28. {
  29. (void)argc; (void)argv;
  30. zf_log_set_output_v(ZF_LOG_PUT_STD, 0, main_output_callback);
  31. test_module();
  32. test_main();
  33. return 0;
  34. }