| 1 | #include "stdafx.h" |
| 2 | |
| 3 | static bool test(const char* in, const char* tag, bool once, |
| 4 | acl::string& out, acl::string* left = NULL) |
| 5 | { |
| 6 | acl::json json; |
| 7 | const char* ptr = NULL, *p1 = in; |
| 8 | char buf[2]; |
| 9 | |
| 10 | if (once) |
| 11 | ptr = json.update(p1); |
| 12 | else |
| 13 | { |
| 14 | while (*p1) |
| 15 | { |
| 16 | buf[0] = *p1; |
| 17 | buf[1] = 0; |
| 18 | ptr = json.update(buf); |
| 19 | p1++; |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | const std::vector<acl::json_node*> &receiver = |
| 24 | json.getElementsByTagName(tag); |
| 25 | |
| 26 | std::vector<acl::json_node*>::const_iterator cit; |
| 27 | for (cit = receiver.begin(); cit != receiver.end(); ++cit) |
| 28 | { |
| 29 | acl::json_node* node = (*cit)->get_obj(); |
| 30 | if (node == NULL) |
| 31 | { |
| 32 | printf("get_obj null\r\n"); |
| 33 | break; |
| 34 | } |
| 35 | |
| 36 | printf("--------list all elements of the array --------\r\n"); |
| 37 | |
| 38 | acl::json_node* child = node->first_child(); |
| 39 | while (child) |
| 40 | { |
| 41 | const char* txt = child->get_text(); |
| 42 | if (txt && *txt) |
| 43 | printf("%s\r\n", txt); |
| 44 | else |
| 45 | printf("null\r\n"); |
| 46 | child = node->next_child(); |
| 47 | } |
| 48 | |
| 49 | printf("----------------- list end --------------------\r\n"); |
| 50 | } |
| 51 | |
| 52 | printf("-------------------------------------------------------\r\n"); |
| 53 | |
| 54 | printf("%s\r\n", in); |
| 55 | |
| 56 | printf("-------------------------------------------------------\r\n"); |
| 57 | |
| 58 | printf("json finish: %s, left char: %s\r\n", |
| 59 | json.finish() ? "yes" : "no", ptr); |
| 60 | if (left) |
no test coverage detected
searching dependent graphs…