| 172 | } |
| 173 | |
| 174 | static 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 | |
| 215 | static void test3_thread_callback(void* ctx) |
| 216 | { |
no test coverage detected
searching dependent graphs…