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

Function test2

lib_acl_cpp/samples/token_tree/main.cpp:24–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22}
23
24static void test2(void)
25{
26 const char* disks = "/data1; /data2; /data3; /data4; /data; /data5;"
27 " /data6; /data7; /data8; /data9; /data10; /data10/www"
28 " .baidu.com; sina.com; sohu.com";
29 acl::string buf(disks);
30 std::vector<acl::string>& tokens = buf.split2(";, \t\r\n");
31 acl::token_tree tree;
32 for (std::vector<acl::string>::const_iterator cit = tokens.begin();
33 cit != tokens.end(); ++cit) {
34 tree.insert(*cit);
35 }
36
37 const char* path = "/data10/www/xxxx", *ptr = path;
38 const acl::token_node* node = tree.search(&ptr);
39 if (node) {
40 printf("ok, found it, key=%s, path=%s\r\n",
41 node->get_key(), path);
42 } else {
43 printf("not found, path=%s\r\n", path);
44 }
45
46 node = tree.find(path);
47 if (node) {
48 printf("error, we found it, path=%s, key=%s\r\n",
49 path, node->get_key());
50 } else {
51 printf("ok, not found, key=%s\r\n", path);
52 }
53
54 path = "/data10";
55 node = tree.find(path);
56 if (node) {
57 printf("ok, found it, path=%s, key=%s\r\n",
58 path, node->get_key());
59 } else {
60 printf("error, not found, path=%s\r\n", path);
61 }
62
63 path = "/data10/";
64 node = tree.find(path);
65 if (node) {
66 printf("error, found it, path=%s, key=%s\r\n",
67 path, node->get_key());
68 } else {
69 printf("ok, not found, path=%s\r\n", path);
70 }
71
72 path = "www.baidu.com";
73 node = tree.find(path);
74 if (node) {
75 printf("error, found it, path=%s, key=%s\r\n",
76 path, node->get_key());
77 } else {
78 printf("ok, not found, path=%s\r\n", path);
79 }
80
81 path = "www.baidu.com";

Callers 1

mainFunction · 0.70

Calls 6

beginMethod · 0.80
insertMethod · 0.80
searchMethod · 0.80
endMethod · 0.45
get_keyMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…