RyanJsonBaseTest.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #include "RyanJsonBaseTest.h"
  2. static RyanJsonBool_e likeReferenceTest()
  3. {
  4. // char *str = NULL;
  5. // char jsonstr[] =
  6. // "{\"inter\":16,\"double\":16.89,\"string\":\"hello\",\"boolTrue\":true,\"boolFalse\":false,\"null\":null,\"item\":{\"inter\":16,\"double\":16.89,\"string\":\"hello\",\"boolTrue\":true,\"boolFalse\":false,\"null\":null},\"arrayInt\":[16,16,16,16,16],\"arrayDouble\":[16.89,16.89,16.89,16.89,16.89],\"arrayString\":[\"hello\",\"hello\",\"hello\",\"hello\",\"hello\"],\"array\":[16,16.89,\"hello\",true,false,null],\"arrayItem\":[{\"inter\":16,\"double\":16.89,\"string\":\"hello\",\"boolTrue\":true,\"boolFalse\":false,\"null\":null},{\"inter\":16,\"double\":16.89,\"string\":\"hello\",\"boolTrue\":true,\"boolFalse\":false,\"null\":null}]}";
  7. // RyanJson_t json = RyanJsonParse(jsonstr);
  8. // RyanJson_t item = NULL;
  9. // // RyanJson_t adfasdf = RyanJsonDuplicate(RyanJsonGetObjectToKey(json, "item"));
  10. // // RyanJsonAddItemToObject(json, "test", adfasdf);
  11. // // 这里做你想做的事,这里我选择打印出来
  12. // // str = RyanJsonPrint(json, 50, RyanJsonTrue, NULL);
  13. // // printf("item %s \r\n", str);
  14. // // RyanJsonFree(str);
  15. // for (int i = 0; i < 1; i++)
  16. // {
  17. // // 分离test对象
  18. // item = RyanJsonDetachByKey(json, "item");
  19. // // if (RyanJsonIsKey(item))
  20. // // RyanJsonFree(RyanJsonGetKey(item));
  21. // // RyanJsonFree(item);
  22. // }
  23. // RyanJsonAddItemToObject(json, "item", item);
  24. // str = RyanJsonPrint(json, 50, RyanJsonTrue, NULL);
  25. // printf("item %s \r\n", str);
  26. // RyanJsonFree(str);
  27. // RyanJsonDelete(json);
  28. return 0;
  29. }
  30. RyanJsonBool_e RyanJsonBaseTest(void)
  31. {
  32. int32_t result = 0;
  33. uint32_t testRunCount = 0;
  34. uint64_t funcStartMs;
  35. runTestWithLogAndTimer(RyanJsonBaseTestChangeJson); // 验证 JSON 动态更新及存储模式切换逻辑
  36. runTestWithLogAndTimer(RyanJsonBaseTestCompareJson); // 验证节点及其属性的深度一致性比较逻辑
  37. runTestWithLogAndTimer(RyanJsonBaseTestCreateJson); // 验证全类型节点的构造与初始化逻辑
  38. runTestWithLogAndTimer(RyanJsonBaseTestDeleteJson); // 验证节点及其子项的递归内存回收逻辑
  39. runTestWithLogAndTimer(RyanJsonBaseTestDetachJson); // 验证节点的分离操作及其所属权转移逻辑
  40. runTestWithLogAndTimer(RyanJsonBaseTestDuplicateJson); // 验证对象的深拷贝 (Deep Copy) 完整性逻辑
  41. runTestWithLogAndTimer(RyanJsonBaseTestForEachJson); // 验证数组与对象迭代器的稳定性与边界情况
  42. runTestWithLogAndTimer(RyanJsonBaseTestLoadJson); // 验证复杂 JSON 文本解析与内存映射的健壮性
  43. runTestWithLogAndTimer(RyanJsonBaseTestReplaceJson); // 验证节点就地替换与成员管理机制的有效性
  44. // 验证节点属性一致性
  45. runTestWithLogAndTimer(RyanJsonBaseTestEqualityBool); // 验证布尔值一致性
  46. runTestWithLogAndTimer(RyanJsonBaseTestEqualityDouble); // 验证浮点数一致性
  47. runTestWithLogAndTimer(RyanJsonBaseTestEqualityInt); // 验证整数一致性
  48. runTestWithLogAndTimer(RyanJsonBaseTestEqualityString); // 验证字符串一致性
  49. // result = likeReferenceTest(); // 模仿 引用类型实现 示例
  50. // if (0 != result)
  51. // {
  52. // printf("%s:%d loadJsonTest fail\r\n", __FILE__, __LINE__);
  53. // return RyanJsonFalse;
  54. // }
  55. displayMem();
  56. return RyanJsonTrue;
  57. __exit:
  58. displayMem();
  59. return RyanJsonFalse;
  60. }