Index: base/i18n/case_conversion_unittest.cc |
diff --git a/base/i18n/case_conversion_unittest.cc b/base/i18n/case_conversion_unittest.cc |
index dc5bc1fe8b145d8080f593221051f3fc9a1628ff..d5fb61264c278ae92479a484f81b40e29be1db5f 100644 |
--- a/base/i18n/case_conversion_unittest.cc |
+++ b/base/i18n/case_conversion_unittest.cc |
@@ -13,6 +13,21 @@ namespace i18n { |
namespace { |
+class ScopedSetICUDefaultLocale { |
+ std::string default_locale; |
+ |
+ public: |
+ ScopedSetICUDefaultLocale(std::string locale); |
+ ~ScopedSetICUDefaultLocale(); |
+}; |
+ |
+ScopedSetICUDefaultLocale::ScopedSetICUDefaultLocale(std::string locale) |
+ : default_locale(locale) {} |
+ |
+ScopedSetICUDefaultLocale::~ScopedSetICUDefaultLocale() { |
+ i18n::SetICUDefaultLocale(default_locale.data()); |
+} |
+ |
const wchar_t kNonASCIIMixed[] = |
L"\xC4\xD6\xE4\xF6\x20\xCF\xEF\x20\xF7\x25" |
L"\xA4\x23\x2A\x5E\x60\x40\xA3\x24\x2030\x201A\x7E\x20\x1F07\x1F0F" |
@@ -58,7 +73,7 @@ TEST(CaseConversionTest, TurkishLocaleConversion) { |
const string16 expected_lower(WideToUTF16(L"\x69\x131")); |
const string16 expected_upper(WideToUTF16(L"\x49\x49")); |
- std::string default_locale(uloc_getDefault()); |
+ ScopedSetICUDefaultLocale restore_object(uloc_getDefault()); |
i18n::SetICUDefaultLocale("en_US"); |
string16 result = ToLower(mixed); |
@@ -77,8 +92,6 @@ TEST(CaseConversionTest, TurkishLocaleConversion) { |
result = ToUpper(mixed); |
EXPECT_EQ(expected_upper_turkish, result); |
- |
- SetICUDefaultLocale(default_locale.data()); |
} |
TEST(CaseConversionTest, FoldCase) { |
@@ -97,7 +110,7 @@ TEST(CaseConversionTest, FoldCase) { |
const string16 turkish(WideToUTF16(L"\x49\x131")); |
const string16 turkish_expected(WideToUTF16(L"\x69\x131")); |
- std::string default_locale(uloc_getDefault()); |
+ ScopedSetICUDefaultLocale restore_object(uloc_getDefault()); |
i18n::SetICUDefaultLocale("en_US"); |
EXPECT_EQ(turkish_expected, FoldCase(turkish)); |