OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <math.h> | 5 #include <math.h> |
6 #include <stdarg.h> | 6 #include <stdarg.h> |
7 | 7 |
8 #include <limits> | 8 #include <limits> |
9 #include <sstream> | 9 #include <sstream> |
10 | 10 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 true, | 179 true, |
180 L"\x03B3\x03B5\x03B9\x03AC" L" " L"\x03C3\x03BF\x03C5", | 180 L"\x03B3\x03B5\x03B9\x03AC" L" " L"\x03C3\x03BF\x03C5", |
181 NULL}, | 181 NULL}, |
182 // Hebrew (Windows) | 182 // Hebrew (Windows) |
183 {"windows-1255", | 183 {"windows-1255", |
184 "\xF9\xD1\xC8\xEC\xE5\xC9\xED", | 184 "\xF9\xD1\xC8\xEC\xE5\xC9\xED", |
185 OnStringConversionError::FAIL, | 185 OnStringConversionError::FAIL, |
186 true, | 186 true, |
187 L"\x05E9\x05C1\x05B8\x05DC\x05D5\x05B9\x05DD", | 187 L"\x05E9\x05C1\x05B8\x05DC\x05D5\x05B9\x05DD", |
188 NULL}, | 188 NULL}, |
189 // Hindi Devanagari (ISCII) | |
190 {"iscii-dev", | |
191 "\xEF\x42" "\xC6\xCC\xD7\xE8\xB3\xDA\xCF", | |
192 OnStringConversionError::FAIL, | |
193 true, | |
194 L"\x0928\x092E\x0938\x094D\x0915\x093E\x0930", | |
195 NULL}, | |
196 // Korean (EUC) | 189 // Korean (EUC) |
197 {"euc-kr", | 190 {"euc-kr", |
198 "\xBE\xC8\xB3\xE7\xC7\xCF\xBC\xBC\xBF\xE4", | 191 "\xBE\xC8\xB3\xE7\xC7\xCF\xBC\xBC\xBF\xE4", |
199 OnStringConversionError::FAIL, | 192 OnStringConversionError::FAIL, |
200 true, | 193 true, |
201 L"\xC548\xB155\xD558\xC138\xC694", | 194 L"\xC548\xB155\xD558\xC138\xC694", |
202 NULL}, | 195 NULL}, |
203 // Japanese (EUC) | 196 // Japanese (EUC) |
204 {"euc-jp", | 197 {"euc-jp", |
205 "\xA4\xB3\xA4\xF3\xA4\xCB\xA4\xC1\xA4\xCF\xB0\xEC\x8F\xB0\xA1\x8E\xA6", | 198 "\xA4\xB3\xA4\xF3\xA4\xCB\xA4\xC1\xA4\xCF\xB0\xEC\x8E\xA6", |
206 OnStringConversionError::FAIL, | 199 OnStringConversionError::FAIL, |
207 true, | 200 true, |
208 L"\x3053\x3093\x306B\x3061\x306F\x4E00\x4E02\xFF66", | 201 L"\x3053\x3093\x306B\x3061\x306F\x4E00\xFF66", |
209 NULL}, | 202 NULL}, |
210 // Japanese (ISO-2022) | 203 // Japanese (ISO-2022) |
211 {"iso-2022-jp", | 204 {"iso-2022-jp", |
212 "\x1B$B" "\x24\x33\x24\x73\x24\x4B\x24\x41\x24\x4F\x30\x6C" "\x1B(B" | 205 "\x1B$B" "\x24\x33\x24\x73\x24\x4B\x24\x41\x24\x4F\x30\x6C" "\x1B(B" |
213 "ab" "\x1B(J" "\x5C\x7E#$" "\x1B(B", | 206 "ab" "\x1B(J" "\x5C\x7E#$" "\x1B(B", |
214 OnStringConversionError::FAIL, | 207 OnStringConversionError::FAIL, |
215 true, | 208 true, |
216 L"\x3053\x3093\x306B\x3061\x306F\x4E00" L"ab\x00A5\x203E#$", | 209 L"\x3053\x3093\x306B\x3061\x306F\x4E00" L"ab\x00A5\x203E#$", |
217 NULL}, | 210 NULL}, |
218 // Japanese (Shift-JIS) | 211 // Japanese (Shift-JIS) |
(...skipping 12 matching lines...) Expand all Loading... |
231 L"\x0443\x0439\x0442\x0435", | 224 L"\x0443\x0439\x0442\x0435", |
232 NULL}, | 225 NULL}, |
233 // Thai (windows-874) | 226 // Thai (windows-874) |
234 {"windows-874", | 227 {"windows-874", |
235 "\xCA\xC7\xD1\xCA\xB4\xD5" "\xA4\xC3\xD1\xBA", | 228 "\xCA\xC7\xD1\xCA\xB4\xD5" "\xA4\xC3\xD1\xBA", |
236 OnStringConversionError::FAIL, | 229 OnStringConversionError::FAIL, |
237 true, | 230 true, |
238 L"\x0E2A\x0E27\x0E31\x0E2A\x0E14\x0E35" | 231 L"\x0E2A\x0E27\x0E31\x0E2A\x0E14\x0E35" |
239 L"\x0E04\x0E23\x0e31\x0E1A", | 232 L"\x0E04\x0E23\x0e31\x0E1A", |
240 NULL}, | 233 NULL}, |
241 // Empty text | |
242 {"iscii-dev", | |
243 "", | |
244 OnStringConversionError::FAIL, | |
245 true, | |
246 L"", | |
247 NULL}, | |
248 }; | 234 }; |
249 | 235 |
250 TEST(ICUStringConversionsTest, ConvertBetweenCodepageAndWide) { | 236 TEST(ICUStringConversionsTest, ConvertBetweenCodepageAndWide) { |
251 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kConvertCodepageCases); ++i) { | 237 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kConvertCodepageCases); ++i) { |
252 SCOPED_TRACE(base::StringPrintf( | 238 SCOPED_TRACE(base::StringPrintf( |
253 "Test[%" PRIuS "]: <encoded: %s> <codepage: %s>", i, | 239 "Test[%" PRIuS "]: <encoded: %s> <codepage: %s>", i, |
254 kConvertCodepageCases[i].encoded, | 240 kConvertCodepageCases[i].encoded, |
255 kConvertCodepageCases[i].codepage_name)); | 241 kConvertCodepageCases[i].codepage_name)); |
256 | 242 |
257 std::wstring wide; | 243 std::wstring wide; |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 | 363 |
378 bool success = ConvertToUtf8AndNormalize( | 364 bool success = ConvertToUtf8AndNormalize( |
379 kConvertAndNormalizeCases[i].encoded, | 365 kConvertAndNormalizeCases[i].encoded, |
380 kConvertAndNormalizeCases[i].codepage_name, &result); | 366 kConvertAndNormalizeCases[i].codepage_name, &result); |
381 EXPECT_EQ(kConvertAndNormalizeCases[i].expected_success, success); | 367 EXPECT_EQ(kConvertAndNormalizeCases[i].expected_success, success); |
382 EXPECT_EQ(kConvertAndNormalizeCases[i].expected_value, result); | 368 EXPECT_EQ(kConvertAndNormalizeCases[i].expected_value, result); |
383 } | 369 } |
384 } | 370 } |
385 | 371 |
386 } // namespace base | 372 } // namespace base |
OLD | NEW |