comparison UnitTests/main.cpp @ 107:3b45473c0a73

replace boost::locale with iconv for debian
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 04 Oct 2012 11:22:20 +0200
parents 7593b57dc1bf
children 0e97abc7b950
comparison
equal deleted inserted replaced
106:332fec038d52 107:3b45473c0a73
286 TEST(Logger, Basic) 286 TEST(Logger, Basic)
287 { 287 {
288 LOG(INFO) << "I say hello"; 288 LOG(INFO) << "I say hello";
289 } 289 }
290 290
291 TEST(Toolbox, ConvertFromLatin1)
292 {
293 // This is a Latin-1 test string
294 const unsigned char data[10] = { 0xe0, 0xe9, 0xea, 0xe7, 0x26, 0xc6, 0x61, 0x62, 0x63, 0x00 };
295
296 /*FILE* f = fopen("/tmp/tutu", "w");
297 fwrite(&data[0], 9, 1, f);
298 fclose(f);*/
299
300 std::string s((char*) &data[0], 10);
301 ASSERT_EQ("&abc", Toolbox::ConvertToAscii(s));
302
303 // Open in Emacs, then save with UTF-8 encoding, then "hexdump -C"
304 std::string utf8 = Toolbox::ConvertToUtf8(s, "ISO-8859-1");
305 ASSERT_EQ(15, utf8.size());
306 ASSERT_EQ(0xc3, static_cast<unsigned char>(utf8[0]));
307 ASSERT_EQ(0xa0, static_cast<unsigned char>(utf8[1]));
308 ASSERT_EQ(0xc3, static_cast<unsigned char>(utf8[2]));
309 ASSERT_EQ(0xa9, static_cast<unsigned char>(utf8[3]));
310 ASSERT_EQ(0xc3, static_cast<unsigned char>(utf8[4]));
311 ASSERT_EQ(0xaa, static_cast<unsigned char>(utf8[5]));
312 ASSERT_EQ(0xc3, static_cast<unsigned char>(utf8[6]));
313 ASSERT_EQ(0xa7, static_cast<unsigned char>(utf8[7]));
314 ASSERT_EQ(0x26, static_cast<unsigned char>(utf8[8]));
315 ASSERT_EQ(0xc3, static_cast<unsigned char>(utf8[9]));
316 ASSERT_EQ(0x86, static_cast<unsigned char>(utf8[10]));
317 ASSERT_EQ(0x61, static_cast<unsigned char>(utf8[11]));
318 ASSERT_EQ(0x62, static_cast<unsigned char>(utf8[12]));
319 ASSERT_EQ(0x63, static_cast<unsigned char>(utf8[13]));
320 ASSERT_EQ(0x00, static_cast<unsigned char>(utf8[14])); // Null-terminated string
321 }
322
291 323
292 int main(int argc, char **argv) 324 int main(int argc, char **argv)
293 { 325 {
294 // Initialize Google's logging library. 326 // Initialize Google's logging library.
295 FLAGS_logtostderr = true; 327 FLAGS_logtostderr = true;