test_externally_defined_state.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #define ZF_LOG_EXTERN_TAG_PREFIX
  2. #define ZF_LOG_EXTERN_GLOBAL_FORMAT
  3. #define ZF_LOG_EXTERN_GLOBAL_OUTPUT
  4. #define ZF_LOG_EXTERN_GLOBAL_OUTPUT_LEVEL
  5. #include <zf_log.c>
  6. #include "zf_test.h"
  7. enum { MEM_WIDTH = 8 };
  8. static void mock_output_callback(const zf_log_message *msg, void *arg);
  9. ZF_LOG_DEFINE_TAG_PREFIX = "MOCK_PREFIX";
  10. ZF_LOG_DEFINE_GLOBAL_FORMAT =
  11. {
  12. 0xc0defade
  13. };
  14. ZF_LOG_DEFINE_GLOBAL_OUTPUT =
  15. {
  16. 0xcafebabe,
  17. (void *)(ptrdiff_t)0xfafacaca,
  18. mock_output_callback
  19. };
  20. ZF_LOG_DEFINE_GLOBAL_OUTPUT_LEVEL = 0xdeadbeef;
  21. static void mock_output_callback(const zf_log_message *msg, void *arg)
  22. {
  23. (void)msg; (void)arg;
  24. }
  25. static void test_static_initialization()
  26. {
  27. TEST_VERIFY_TRUE(0 == strcmp(_zf_log_tag_prefix, "MOCK_PREFIX"));
  28. TEST_VERIFY_EQUAL(_zf_log_global_format.mem_width, 0xc0defade);
  29. TEST_VERIFY_EQUAL(_zf_log_global_output.mask, 0xcafebabe);
  30. TEST_VERIFY_EQUAL(_zf_log_global_output.arg, (void *)(ptrdiff_t)0xfafacaca);
  31. TEST_VERIFY_EQUAL(_zf_log_global_output.callback, mock_output_callback);
  32. TEST_VERIFY_EQUAL(_zf_log_global_output_lvl, (int)0xdeadbeef);
  33. TEST_VERIFY_EQUAL(ZF_LOG_GLOBAL_FORMAT, &_zf_log_global_format);
  34. TEST_VERIFY_EQUAL(ZF_LOG_GLOBAL_OUTPUT, &_zf_log_global_output);
  35. }
  36. int main(int argc, char *argv[])
  37. {
  38. TEST_RUNNER_CREATE(argc, argv);
  39. TEST_EXECUTE(test_static_initialization());
  40. return TEST_RUNNER_EXIT_CODE();
  41. }