testCommon.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #ifndef RYANJSON_TEST_COMMON_H
  2. #define RYANJSON_TEST_COMMON_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include <stdio.h>
  7. #include <stdint.h>
  8. #include <stdlib.h>
  9. #include <math.h>
  10. #include <time.h>
  11. #include <ctype.h>
  12. #include <inttypes.h>
  13. #include "FreeRTOS.h"
  14. #include "task.h"
  15. #include "unity.h"
  16. #include "valloc.h"
  17. #include "RyanJson.h"
  18. #include "cJSON.h"
  19. #include "yyjson.h"
  20. #include "testPlatform.h"
  21. #ifndef RyanJsonTestAllocHeaderSize
  22. #define RyanJsonTestAllocHeaderSize RyanJsonMallocHeaderSize
  23. #endif
  24. #ifndef RyanJsonTestAllocAlignSize
  25. #define RyanJsonTestAllocAlignSize RyanJsonMallocAlign
  26. #endif
  27. static inline void delay(uint32_t ms)
  28. {
  29. testPlatformSleepMs(ms);
  30. }
  31. #define getArraySize(arr) ((int32_t)(sizeof(arr) / sizeof((arr)[0])))
  32. #define checkMemory \
  33. do \
  34. { \
  35. if (0 != unityTestGetUse()) \
  36. { \
  37. testLog("内存泄漏\r\n"); \
  38. while (1) \
  39. { \
  40. showMemoryInfo(); \
  41. delay(3000); \
  42. } \
  43. } \
  44. } while (0)
  45. // 定义枚举类型
  46. extern void *unityTestMalloc(size_t size);
  47. extern void unityTestFree(void *block);
  48. extern void *unityTestRealloc(void *block, size_t size);
  49. extern void unityTestSetAllocSimulation(uint8_t isEnable);
  50. extern uint8_t unityTestGetAllocSimulation(void);
  51. extern int32_t unityTestGetUse(void);
  52. extern void showMemoryInfo(void);
  53. extern void logTaskStackRuntimeInfoByHandle(const char *tag, const char *taskName, TaskHandle_t taskHandle);
  54. // 定义结构体类型
  55. extern uint64_t platformUptimeMs(void);
  56. extern RyanJsonBool_e RyanJsonExample(void);
  57. extern RyanJsonBool_e RyanJsonTestFun(void);
  58. extern void ryanJsonTestSetup(void);
  59. extern void ryanJsonTestTeardown(void);
  60. #ifdef __cplusplus
  61. }
  62. #endif
  63. #endif