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

Function test

lib_acl_cpp/samples/json/json12/json.cpp:22–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20}
21
22static bool test(const char* in, bool once, const char* name)
23{
24 acl::json json;
25 const char* ptr = NULL, *p1 = in;
26 char buf[2];
27
28 if (once)
29 ptr = json.update(p1);
30 else
31 {
32 while (*p1)
33 {
34 buf[0] = *p1;
35 buf[1] = 0;
36 ptr = json.update(buf);
37 p1++;
38 }
39 }
40
41 printf("------------------ input json ------------------------\r\n");
42 printf("%s\r\n", in);
43 printf("-------------------------------------------------------\r\n");
44
45 printf("json finish: %s, left: |%s|, len: %d\r\n",
46 json.finish() ? "yes" : "no", ptr, (int) strlen(ptr));
47
48 printf("------------------ rebuild json -----------------------\r\n");
49 printf("%s\r\n", json.to_string().c_str());
50 printf("-------------------------------------------------------\r\n");
51
52 acl::string ibuf(in);
53 ibuf.trim_space().trim_right_line();
54
55 acl::string obuf = json.to_string();
56 obuf.trim_space();
57
58 if (ibuf == obuf)
59 printf("\r\n-----OK----\r\n\r\n");
60 else
61 printf("\r\n-----Error----\r\n\r\n");
62
63 if (name && *name)
64 test_type(json, name);
65
66 return true;
67}
68
69static void usage(const char* procname)
70{

Callers 1

mainFunction · 0.70

Calls 5

test_typeFunction · 0.70
updateMethod · 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…