| 54 | #endif |
| 55 | |
| 56 | static 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'); |
no test coverage detected
searching dependent graphs…