OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 7 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
8 #include <cstdlib> | 8 #include <cstdlib> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 void CheckUiDisplayNameForLocale(const std::string& locale, | 325 void CheckUiDisplayNameForLocale(const std::string& locale, |
326 const std::string& display_locale, | 326 const std::string& display_locale, |
327 bool is_rtl) { | 327 bool is_rtl) { |
328 EXPECT_EQ(true, base::i18n::IsRTL()); | 328 EXPECT_EQ(true, base::i18n::IsRTL()); |
329 base::string16 result = l10n_util::GetDisplayNameForLocale(locale, | 329 base::string16 result = l10n_util::GetDisplayNameForLocale(locale, |
330 display_locale, | 330 display_locale, |
331 /* is_for_ui */ true); | 331 /* is_for_ui */ true); |
332 | 332 |
333 bool rtl_direction = true; | 333 bool rtl_direction = true; |
334 for (size_t i = 0; i < result.length() - 1; i++) { | 334 for (size_t i = 0; i < result.length() - 1; i++) { |
335 char16 ch = result.at(i); | 335 base::char16 ch = result.at(i); |
336 switch (ch) { | 336 switch (ch) { |
337 case base::i18n::kLeftToRightMark: | 337 case base::i18n::kLeftToRightMark: |
338 case base::i18n::kLeftToRightEmbeddingMark: | 338 case base::i18n::kLeftToRightEmbeddingMark: |
339 rtl_direction = false; | 339 rtl_direction = false; |
340 break; | 340 break; |
341 case base::i18n::kRightToLeftMark: | 341 case base::i18n::kRightToLeftMark: |
342 case base::i18n::kRightToLeftEmbeddingMark: | 342 case base::i18n::kRightToLeftEmbeddingMark: |
343 rtl_direction = true; | 343 rtl_direction = true; |
344 break; | 344 break; |
345 case '(': | 345 case '(': |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 base::i18n::SetICUDefaultLocale("he"); | 381 base::i18n::SetICUDefaultLocale("he"); |
382 CheckUiDisplayNameForLocale("en-US", "en", false); | 382 CheckUiDisplayNameForLocale("en-US", "en", false); |
383 CheckUiDisplayNameForLocale("en-US", "he", true); | 383 CheckUiDisplayNameForLocale("en-US", "he", true); |
384 | 384 |
385 // Clean up. | 385 // Clean up. |
386 base::i18n::SetICUDefaultLocale(original_locale); | 386 base::i18n::SetICUDefaultLocale(original_locale); |
387 #endif | 387 #endif |
388 | 388 |
389 // ToUpper and ToLower should work with embedded NULLs. | 389 // ToUpper and ToLower should work with embedded NULLs. |
390 const size_t length_with_null = 4; | 390 const size_t length_with_null = 4; |
391 char16 buf_with_null[length_with_null] = { 0, 'a', 0, 'b' }; | 391 base::char16 buf_with_null[length_with_null] = { 0, 'a', 0, 'b' }; |
392 base::string16 string16_with_null(buf_with_null, length_with_null); | 392 base::string16 string16_with_null(buf_with_null, length_with_null); |
393 | 393 |
394 base::string16 upper_with_null = base::i18n::ToUpper(string16_with_null); | 394 base::string16 upper_with_null = base::i18n::ToUpper(string16_with_null); |
395 ASSERT_EQ(length_with_null, upper_with_null.size()); | 395 ASSERT_EQ(length_with_null, upper_with_null.size()); |
396 EXPECT_TRUE(upper_with_null[0] == 0 && upper_with_null[1] == 'A' && | 396 EXPECT_TRUE(upper_with_null[0] == 0 && upper_with_null[1] == 'A' && |
397 upper_with_null[2] == 0 && upper_with_null[3] == 'B'); | 397 upper_with_null[2] == 0 && upper_with_null[3] == 'B'); |
398 | 398 |
399 base::string16 lower_with_null = base::i18n::ToLower(upper_with_null); | 399 base::string16 lower_with_null = base::i18n::ToLower(upper_with_null); |
400 ASSERT_EQ(length_with_null, upper_with_null.size()); | 400 ASSERT_EQ(length_with_null, upper_with_null.size()); |
401 EXPECT_TRUE(lower_with_null[0] == 0 && lower_with_null[1] == 'a' && | 401 EXPECT_TRUE(lower_with_null[0] == 0 && lower_with_null[1] == 'a' && |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("Latin")); | 471 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("Latin")); |
472 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("German")); | 472 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("German")); |
473 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("pt--BR")); | 473 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("pt--BR")); |
474 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("sl-macedonia")); | 474 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("sl-macedonia")); |
475 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("@")); | 475 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("@")); |
476 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@")); | 476 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@")); |
477 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@x")); | 477 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@x")); |
478 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@x=")); | 478 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@x=")); |
479 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@=y")); | 479 EXPECT_FALSE(l10n_util::IsValidLocaleSyntax("en-US@=y")); |
480 } | 480 } |
OLD | NEW |