RyanJsonTest.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #include "RyanJsonTest.h"
  2. static void printfTitle(char *title)
  3. {
  4. printf("\r\n");
  5. printf("\r\n");
  6. printf("*****************************************************************************\r\n");
  7. printf("*************************** %s **************************\r\n", title);
  8. printf("*****************************************************************************\r\n");
  9. }
  10. #ifndef isEnableFuzzer
  11. extern void printJsonDebug(RyanJson_t json);
  12. int main(void)
  13. {
  14. RyanJsonBool_e result = RyanJsonFalse;
  15. RyanJsonInitHooks(v_malloc, v_free, v_realloc);
  16. for (uint32_t i = 0; i < 1; i++)
  17. {
  18. char *str = NULL;
  19. RyanJson_t jsonRoot, item;
  20. // const char *jsonstr =
  21. // "{\"emoji\":\"\\uD83D\\uDE00\"} ";
  22. // const char *jsonstr = "{\"name\":\"Mash\",\"star\":4,\"hits\":[2,2,1,3]}";
  23. const char *jsonstr = "[1";
  24. // extern int LLVMFuzzerTestOneInput(const char *data, int32_t size);
  25. // LLVMFuzzerTestOneInput(jsonstr, strlen(jsonstr));
  26. // 解析json数据
  27. // jsonRoot = RyanJsonParse(jsonstr);
  28. // if (jsonRoot == NULL) { printf("%s:%d 序列化失败\r\n", __FILE__, __LINE__); }
  29. // else
  30. // {
  31. // uint32_t len = 0;
  32. // str = RyanJsonPrint(jsonRoot, 10, RyanJsonFalse, &len); // 以带格式方式将数据打印出来
  33. // printf("strLen: %d, data: %s\r\n", len, str);
  34. // RyanJsonFree(str);
  35. // RyanJsonDelete(jsonRoot);
  36. // }
  37. }
  38. RyanJsonExample();
  39. result = RyanJsonBaseTest();
  40. if (RyanJsonTrue != result)
  41. {
  42. printf("%s:%d RyanJsonTest fail\r\n", __FILE__, __LINE__);
  43. return -1;
  44. }
  45. printfTitle("RyanJson / cJSON / yyjson RFC8259标准测试");
  46. RFC8259JsonTest();
  47. printfTitle("RyanJson / cJSON / yyjson 内存对比程序");
  48. RyanJsonMemoryFootprintTest();
  49. printf("\r\nok\r\n");
  50. displayMem();
  51. return 0;
  52. }
  53. #endif // isEnableFuzzer