unity_config.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #ifndef UNITY_CONFIG_H
  2. #define UNITY_CONFIG_H
  3. // This file gets included from unity.h via unity_internals.h
  4. // It is inside #ifdef __cplusplus / extern "C" block, so we can
  5. // only use C features here
  6. // Adapt Unity to our environment, disable FP support
  7. #include <esp_err.h>
  8. #define UNITY_EXCLUDE_FLOAT
  9. #define UNITY_EXCLUDE_DOUBLE
  10. #define UNITY_OUTPUT_CHAR unity_putc
  11. #define UNITY_OUTPUT_FLUSH unity_flush
  12. // Define helpers to register test cases from multiple files
  13. #define UNITY_EXPAND2(a, b) a ## b
  14. #define UNITY_EXPAND(a, b) UNITY_EXPAND2(a, b)
  15. #define UNITY_TEST_UID(what) UNITY_EXPAND(what, __LINE__)
  16. #define UNITY_TEST_REG_HELPER reg_helper ## UNITY_TEST_UID
  17. #define UNITY_TEST_DESC_UID desc ## UNITY_TEST_UID
  18. struct test_desc_t
  19. {
  20. const char* name;
  21. const char* desc;
  22. void (*fn)(void);
  23. const char* file;
  24. int line;
  25. struct test_desc_t* next;
  26. };
  27. void unity_testcase_register(struct test_desc_t* desc);
  28. void unity_run_menu();
  29. void unity_run_tests_with_filter(const char* filter);
  30. void unity_run_all_tests();
  31. /* Test case macro, a-la CATCH framework.
  32. First argument is a free-form description,
  33. second argument is (by convention) a list of identifiers, each one in square brackets.
  34. Identifiers are used to group related tests, or tests with specific properties.
  35. Use like:
  36. TEST_CASE("Frobnicator forbnicates", "[frobnicator][rom]")
  37. {
  38. // test goes here
  39. }
  40. */
  41. #define TEST_CASE(name_, desc_) \
  42. static void UNITY_TEST_UID(test_func_) (void); \
  43. static void __attribute__((constructor)) UNITY_TEST_UID(test_reg_helper_) () \
  44. { \
  45. static struct test_desc_t UNITY_TEST_UID(test_desc_) = { \
  46. .name = name_, \
  47. .desc = desc_, \
  48. .fn = &UNITY_TEST_UID(test_func_), \
  49. .file = __FILE__, \
  50. .line = __LINE__ \
  51. }; \
  52. unity_testcase_register( & UNITY_TEST_UID(test_desc_) ); \
  53. }\
  54. static void UNITY_TEST_UID(test_func_) (void)
  55. // shorthand to check esp_err_t return code
  56. #define TEST_ESP_OK(rc) TEST_ASSERT_EQUAL_INT32(ESP_OK, rc)
  57. #define TEST_ESP_ERR(err, rc) TEST_ASSERT_EQUAL_INT32(err, rc)
  58. #endif //UNITY_CONFIG_H