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

Function test

lib_acl_cpp/samples/json/json2/json.cpp:81–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79}
80
81static void test(void)
82{
83 static const char* data = \
84"{'Action' : 'set' , 'Object' : 'user' , 'UpdateTime' : '<updatetime_value>' , 'Key' : '<xmuserid>',\r\n"
85" 'DataList' : [\r\n"
86" {'DataKey' : 'BindInfo' , 'DataValue' : {'BindList' : [{'BindName' : 'BindText'}, {'BindType' : '<bindtype_value>' , 'BindId' : '<bindid_value>'}]}},\r\n"
87" {'DataKey' : 'BindRule' , 'DataValue' : [{'name1':'value1'}, {'name2': 'value2'}]},\r\n"
88" {'DataKey' : 'UserTap' , 'DataValue' : {'RemoteLogin' : 'true' , 'ModifyPass' : 'true' , 'MailForward' : 'true' , 'Secure' : 'remote'}} \r\n"
89"]}\r\n";
90 acl::json json(data);
91
92 printf("-------------------------------------------------------\r\n");
93
94 printf("%s", data);
95
96 printf("-------------------------------------------------------\r\n");
97
98 const char* tags_list[] = {
99 "DataList",
100 "DataList/DataKey",
101 "DataList/DataValue",
102 "DataList/DataValue/BindList",
103 "DataValue/BindList/BindName",
104 "DataList/DataValue/name1",
105 "DataList/*/name1",
106 "DataList/DataValue/MailForward",
107 "DataList/*/MailForward",
108 "DataList/MailForward",
109 NULL
110 };
111
112 for (int i = 0; tags_list[i] != NULL; i++)
113 {
114 const vector<acl::json_node*>& dlist = json.getElementsByTags(tags_list[i]);
115 if (dlist.empty())
116 printf(">>> empty tags: %s\r\n", tags_list[i]);
117 else
118 {
119 printf(">>> find %s:\r\n", tags_list[i]);
120 list_print(dlist);
121 }
122 printf("-------------------------------------------------------\r\n");
123 }
124}
125
126int main(void)
127{

Callers 1

mainFunction · 0.70

Calls 2

list_printFunction · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…