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

Function test2

lib_acl_cpp/samples/charset/main.cpp:174–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

172}
173
174static int test2(const char* filepath)
175{
176 acl::string buf1;
177
178 if (acl::ifstream::load(filepath, &buf1) == false)
179 {
180 printf("load %s error\n", filepath);
181 return (-1);
182 }
183
184 acl::charset_conv conv;
185
186 acl::string buf2;
187 if (conv.convert("gb18030", "utf-8", buf1.c_str(),
188 buf1.length(), &buf2) == false)
189 {
190 printf("convert from gb18030 to utf-8 error\n");
191 return (-1);
192 }
193
194 acl::string buf3;
195 if (conv.convert("utf-8", "gb18030", buf2.c_str(),
196 buf2.length(), &buf3) == false)
197 {
198 printf("convert from utf-8 to gb18030 error\n");
199 return (-1);
200 }
201
202 if (buf1 != buf3)
203 {
204 printf("convert failed\n");
205 assert(0);
206 return (-1);
207 }
208 else
209 {
210 printf("convert ok(tid: %u)\n", (unsigned int) acl::thread::thread_self());
211 return (0);
212 }
213}
214
215static void test3_thread_callback(void* ctx)
216{

Callers 2

test3_thread_callbackFunction · 0.70
mainFunction · 0.70

Calls 4

thread_selfFunction · 0.85
convertMethod · 0.80
c_strMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…