| 24 | #include <stdio.h> |
| 25 | |
| 26 | int |
| 27 | main(int argc, char **argv) |
| 28 | { |
| 29 | RecTree *new_rec_tree = new RecTree(nullptr); |
| 30 | |
| 31 | new_rec_tree->rec_tree_insert("proxy.process.librecords.first_child"); |
| 32 | printf("\n"); |
| 33 | new_rec_tree->rec_tree_insert("proxy.process.librecords.first_child.grandchild1"); |
| 34 | printf("\n"); |
| 35 | new_rec_tree->rec_tree_insert("proxy.process.librecords.first_child.grandchild2"); |
| 36 | printf("\n"); |
| 37 | new_rec_tree->rec_tree_insert("proxy.process.librecords.first_child.grandchild2.grandgrandchild1"); |
| 38 | printf("\n"); |
| 39 | new_rec_tree->rec_tree_insert("proxy.process.librecords.first_child.grandchild2.grandgrandchild2"); |
| 40 | printf("\n"); |
| 41 | new_rec_tree->rec_tree_insert("proxy.process.librecords.first_child.grandchild3"); |
| 42 | printf("\n"); |
| 43 | new_rec_tree->rec_tree_insert("proxy.process.librecords.second_child"); |
| 44 | printf("\n"); |
| 45 | new_rec_tree->rec_tree_insert("proxy.process.librecords.second_child.grandchild1"); |
| 46 | printf("\n"); |
| 47 | new_rec_tree->rec_tree_insert("proxy.process.librecords.1"); |
| 48 | printf("\n"); |
| 49 | new_rec_tree->rec_tree_insert("proxy.process.librecords.2"); |
| 50 | printf("\n"); |
| 51 | new_rec_tree->rec_tree_insert("proxy.node.http.hitrate"); |
| 52 | printf("\n"); |
| 53 | new_rec_tree->print(); |
| 54 | |
| 55 | /* Test getting subtree */ |
| 56 | printf("\nTest getting subtree(1)\n"); |
| 57 | printf("----------------------------------------------------------------\n"); |
| 58 | RecTree *sub_tree = new_rec_tree->rec_tree_get("proxy.process.librecords"); |
| 59 | sub_tree->print(); |
| 60 | |
| 61 | printf("\nTest getting subtree(2)\n"); |
| 62 | printf("----------------------------------------------------------------\n"); |
| 63 | sub_tree = new_rec_tree->rec_tree_get("proxy.process.*"); |
| 64 | sub_tree->print(); |
| 65 | |
| 66 | /* Test getting a list of variables */ |
| 67 | printf("\nTest getting variables list\n"); |
| 68 | printf("----------------------------------------------------------------\n"); |
| 69 | int count = 0; |
| 70 | char **variable_list; |
| 71 | new_rec_tree->rec_tree_get_list("proxy.process", &variable_list, &count); |
| 72 | for (int i = 0; i < count; i++) { |
| 73 | printf("[RecTreeTest] %s\n", variable_list[i]); |
| 74 | } |
| 75 | |
| 76 | printf("\n -- Fin --\n"); |
| 77 | } |