Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: base/i18n/icu_string_conversions_unittest.cc

Issue 656033009: Convert ARRAYSIZE_UNSAFE -> arraysize in base/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/files/file_proxy_unittest.cc ('k') | base/i18n/number_formatting_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 {"windows-874", 227 {"windows-874",
228 "\xCA\xC7\xD1\xCA\xB4\xD5" "\xA4\xC3\xD1\xBA", 228 "\xCA\xC7\xD1\xCA\xB4\xD5" "\xA4\xC3\xD1\xBA",
229 OnStringConversionError::FAIL, 229 OnStringConversionError::FAIL,
230 true, 230 true,
231 L"\x0E2A\x0E27\x0E31\x0E2A\x0E14\x0E35" 231 L"\x0E2A\x0E27\x0E31\x0E2A\x0E14\x0E35"
232 L"\x0E04\x0E23\x0e31\x0E1A", 232 L"\x0E04\x0E23\x0e31\x0E1A",
233 NULL}, 233 NULL},
234 }; 234 };
235 235
236 TEST(ICUStringConversionsTest, ConvertBetweenCodepageAndWide) { 236 TEST(ICUStringConversionsTest, ConvertBetweenCodepageAndWide) {
237 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kConvertCodepageCases); ++i) { 237 for (size_t i = 0; i < arraysize(kConvertCodepageCases); ++i) {
238 SCOPED_TRACE(base::StringPrintf( 238 SCOPED_TRACE(base::StringPrintf(
239 "Test[%" PRIuS "]: <encoded: %s> <codepage: %s>", i, 239 "Test[%" PRIuS "]: <encoded: %s> <codepage: %s>", i,
240 kConvertCodepageCases[i].encoded, 240 kConvertCodepageCases[i].encoded,
241 kConvertCodepageCases[i].codepage_name)); 241 kConvertCodepageCases[i].codepage_name));
242 242
243 std::wstring wide; 243 std::wstring wide;
244 bool success = CodepageToWide(kConvertCodepageCases[i].encoded, 244 bool success = CodepageToWide(kConvertCodepageCases[i].encoded,
245 kConvertCodepageCases[i].codepage_name, 245 kConvertCodepageCases[i].codepage_name,
246 kConvertCodepageCases[i].on_error, 246 kConvertCodepageCases[i].on_error,
247 &wide); 247 &wide);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 EXPECT_TRUE(WideToCodepage(L"a\xffffz", "iso-8859-1", 294 EXPECT_TRUE(WideToCodepage(L"a\xffffz", "iso-8859-1",
295 OnStringConversionError::SKIP, &encoded)); 295 OnStringConversionError::SKIP, &encoded));
296 EXPECT_STREQ("az", encoded.c_str()); 296 EXPECT_STREQ("az", encoded.c_str());
297 297
298 // Invalid codepages should fail. 298 // Invalid codepages should fail.
299 EXPECT_FALSE(WideToCodepage(L"Hello, world", "awesome-8571-2", 299 EXPECT_FALSE(WideToCodepage(L"Hello, world", "awesome-8571-2",
300 OnStringConversionError::SKIP, &encoded)); 300 OnStringConversionError::SKIP, &encoded));
301 } 301 }
302 302
303 TEST(ICUStringConversionsTest, ConvertBetweenCodepageAndUTF16) { 303 TEST(ICUStringConversionsTest, ConvertBetweenCodepageAndUTF16) {
304 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kConvertCodepageCases); ++i) { 304 for (size_t i = 0; i < arraysize(kConvertCodepageCases); ++i) {
305 SCOPED_TRACE(base::StringPrintf( 305 SCOPED_TRACE(base::StringPrintf(
306 "Test[%" PRIuS "]: <encoded: %s> <codepage: %s>", i, 306 "Test[%" PRIuS "]: <encoded: %s> <codepage: %s>", i,
307 kConvertCodepageCases[i].encoded, 307 kConvertCodepageCases[i].encoded,
308 kConvertCodepageCases[i].codepage_name)); 308 kConvertCodepageCases[i].codepage_name));
309 309
310 string16 utf16; 310 string16 utf16;
311 bool success = CodepageToUTF16(kConvertCodepageCases[i].encoded, 311 bool success = CodepageToUTF16(kConvertCodepageCases[i].encoded,
312 kConvertCodepageCases[i].codepage_name, 312 kConvertCodepageCases[i].codepage_name,
313 kConvertCodepageCases[i].on_error, 313 kConvertCodepageCases[i].on_error,
314 &utf16); 314 &utf16);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 {"foo-a\xcc\x88.html", "utf-8", true, "foo-\xc3\xa4.html"}, 348 {"foo-a\xcc\x88.html", "utf-8", true, "foo-\xc3\xa4.html"},
349 {"\x95\x32\x82\x36\xD2\xBB", "gb18030", true, "\xF0\xA0\x80\x80\xE4\xB8\x80"}, 349 {"\x95\x32\x82\x36\xD2\xBB", "gb18030", true, "\xF0\xA0\x80\x80\xE4\xB8\x80"},
350 {"\xA7\x41\xA6\x6E", "big5", true, "\xE4\xBD\xA0\xE5\xA5\xBD"}, 350 {"\xA7\x41\xA6\x6E", "big5", true, "\xE4\xBD\xA0\xE5\xA5\xBD"},
351 // Windows-1258 does have a combining character at xD2 (which is U+0309). 351 // Windows-1258 does have a combining character at xD2 (which is U+0309).
352 // The sequence of (U+00E2, U+0309) is also encoded as U+1EA9. 352 // The sequence of (U+00E2, U+0309) is also encoded as U+1EA9.
353 {"foo\xE2\xD2", "windows-1258", true, "foo\xE1\xBA\xA9"}, 353 {"foo\xE2\xD2", "windows-1258", true, "foo\xE1\xBA\xA9"},
354 {"", "iso-8859-1", true, ""}, 354 {"", "iso-8859-1", true, ""},
355 }; 355 };
356 TEST(ICUStringConversionsTest, ConvertToUtf8AndNormalize) { 356 TEST(ICUStringConversionsTest, ConvertToUtf8AndNormalize) {
357 std::string result; 357 std::string result;
358 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kConvertAndNormalizeCases); ++i) { 358 for (size_t i = 0; i < arraysize(kConvertAndNormalizeCases); ++i) {
359 SCOPED_TRACE(base::StringPrintf( 359 SCOPED_TRACE(base::StringPrintf(
360 "Test[%" PRIuS "]: <encoded: %s> <codepage: %s>", i, 360 "Test[%" PRIuS "]: <encoded: %s> <codepage: %s>", i,
361 kConvertAndNormalizeCases[i].encoded, 361 kConvertAndNormalizeCases[i].encoded,
362 kConvertAndNormalizeCases[i].codepage_name)); 362 kConvertAndNormalizeCases[i].codepage_name));
363 363
364 bool success = ConvertToUtf8AndNormalize( 364 bool success = ConvertToUtf8AndNormalize(
365 kConvertAndNormalizeCases[i].encoded, 365 kConvertAndNormalizeCases[i].encoded,
366 kConvertAndNormalizeCases[i].codepage_name, &result); 366 kConvertAndNormalizeCases[i].codepage_name, &result);
367 EXPECT_EQ(kConvertAndNormalizeCases[i].expected_success, success); 367 EXPECT_EQ(kConvertAndNormalizeCases[i].expected_success, success);
368 EXPECT_EQ(kConvertAndNormalizeCases[i].expected_value, result); 368 EXPECT_EQ(kConvertAndNormalizeCases[i].expected_value, result);
369 } 369 }
370 } 370 }
371 371
372 } // namespace base 372 } // namespace base
OLDNEW
« no previous file with comments | « base/files/file_proxy_unittest.cc ('k') | base/i18n/number_formatting_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698