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

Function test_zip_stream

lib_acl_cpp/samples/zlib/zlib.cpp:14–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12#include "acl_cpp/stdlib/zlib_stream.hpp"
13
14static int test_zip_stream(void)
15{
16 const char* dummy = "�������������������������\r\n";
17 acl::zlib_stream zstream;
18 acl::string out, out2;
19
20 const char* ptr = dummy;
21 int n = (int) strlen(ptr);
22
23 bool ret = zstream.zip_begin(acl::zlib_level9);
24 if (ret == false)
25 {
26 printf("zip_begin error\r\n");
27 zstream.zip_reset();
28 return 1;
29 }
30 while (n > 0)
31 {
32 ret = zstream.zip_update(ptr, n, &out, acl::zlib_flush_off);
33 if (ret == false)
34 {
35 printf("zip_update error\r\n");
36 return 1;
37 }
38 ptr++;
39 n--;
40 n = 0;
41 }
42 ret = zstream.zip_finish(&out);
43 if (ret == false)
44 {
45 printf("zip_finish error\r\n");
46 return 1;
47 }
48
49 printf(">>after zip, src's len: %d, dst's len: %d\r\n",
50 (int) strlen(dummy), (int) out.length());
51
52 ptr = out.c_str();
53 n = (int) out.length();
54
55 ret = zstream.unzip_begin();
56 if (ret == false)
57 {
58 printf("unzip_begin error\r\n");
59 return 1;
60 }
61
62 while (n > 0)
63 {
64 ret = zstream.unzip_update(ptr, 1, &out2, acl::zlib_flush_full);
65 if (ret == false)
66 {
67 printf("unzip_update error\r\n");
68 return 1;
69 }
70 ptr++;
71 n--;

Callers 1

mainFunction · 0.85

Calls 9

zip_beginMethod · 0.80
zip_resetMethod · 0.80
zip_updateMethod · 0.80
zip_finishMethod · 0.80
unzip_beginMethod · 0.80
unzip_updateMethod · 0.80
unzip_finishMethod · 0.80
lengthMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…