| 79 | } |
| 80 | |
| 81 | static 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 | |
| 126 | int main(void) |
| 127 | { |
no test coverage detected
searching dependent graphs…