MCPcopy Create free account
hub / github.com/acl-dev/acl / test

Function test

lib_acl_cpp/samples/json/json4/json.cpp:56–176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54#endif
55
56static void test(void)
57{
58 acl::json json1(default_data);
59
60 printf("-------------------------------------------------\r\n");
61 printf("source:\r\n%s\r\n", default_data);
62 printf("-------------------------------------------------\r\n");
63 printf(">>build to_string:\r\n%s\r\n", json1.to_string().c_str());
64 printf("-------------------------------------------------\r\n");
65 if (json1.to_string() != default_result)
66 {
67 printf("%s(%d): result should:\r\n%s\r\n",
68 __FUNCTION__, __LINE__, default_result);
69 exit (1);
70 }
71 else
72 printf("%s(%d): Build json OK!\r\n", __FUNCTION__, __LINE__);
73
74 acl::string buf1 = json1.to_string();
75 json1.reset();
76 json1.update(default_data);
77 if (json1.to_string() != buf1)
78 {
79 printf("-------------------------------------------------\r\n");
80 printf("parse error after reset\r\n");
81 printf("first parse:\r\n%s\r\n", buf1.c_str());
82 printf("second parse:\r\n%s\r\n", json1.to_string().c_str());
83 printf("-------------------------------------------------\r\n");
84 return;
85 }
86
87#if 0
88 acl::json_node* iter = json1.first_node();
89 while (iter)
90 {
91 const char* tag = iter->tag_name();
92 const char* txt = iter->get_text();
93
94 ACL_JSON_NODE* node = iter->get_json_node();
95 for (int i = 0; i < node->depth; i++)
96 putchar('\t');
97 if (node->left_ch)
98 {
99 printf("%c", node->left_ch);
100 fflush(stdout);
101 }
102 if (tag)
103 printf("tag: %s, txt: %s",
104 tag, txt ? txt : "null");
105 /*
106 if (node->right_ch)
107 {
108 printf("%c->", node->right_ch);
109 fflush(stdout);
110 }
111 */
112 iter = json1.next_node();
113 putchar('\n');

Callers 1

mainFunction · 0.70

Calls 12

get_textMethod · 0.80
get_json_nodeMethod · 0.80
set_tagMethod · 0.80
set_textMethod · 0.80
c_strMethod · 0.45
to_stringMethod · 0.45
resetMethod · 0.45
updateMethod · 0.45
first_nodeMethod · 0.45
tag_nameMethod · 0.45
next_nodeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…