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

Function test

lib_acl_cpp/samples/json/json11/json.cpp:3–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1#include "stdafx.h"
2
3static 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)

Callers 1

mainFunction · 0.70

Calls 10

beginMethod · 0.80
get_objMethod · 0.80
get_textMethod · 0.80
updateMethod · 0.45
endMethod · 0.45
first_childMethod · 0.45
next_childMethod · 0.45
finishMethod · 0.45
c_strMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…