| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <locale.h> | 5 #include <locale.h> |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/string_piece.h" | 10 #include "base/string_piece.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 expected_null.push_back('b'); | 71 expected_null.push_back('b'); |
| 72 | 72 |
| 73 EXPECT_EQ(expected_null, SysUTF8ToWide(utf8_null)); | 73 EXPECT_EQ(expected_null, SysUTF8ToWide(utf8_null)); |
| 74 } | 74 } |
| 75 | 75 |
| 76 #if defined(OS_LINUX) // Tests depend on setting a specific Linux locale. | 76 #if defined(OS_LINUX) // Tests depend on setting a specific Linux locale. |
| 77 namespace { | 77 namespace { |
| 78 | 78 |
| 79 class ScopedSetLocale { | 79 class ScopedSetLocale { |
| 80 public: | 80 public: |
| 81 ScopedSetLocale(const char* locale) { | 81 explicit ScopedSetLocale(const char* locale) { |
| 82 old_locale_ = setlocale(LC_ALL, NULL); | 82 old_locale_ = setlocale(LC_ALL, NULL); |
| 83 setlocale(LC_ALL, locale); | 83 setlocale(LC_ALL, locale); |
| 84 } | 84 } |
| 85 ~ScopedSetLocale() { | 85 ~ScopedSetLocale() { |
| 86 setlocale(LC_ALL, old_locale_.c_str()); | 86 setlocale(LC_ALL, old_locale_.c_str()); |
| 87 } | 87 } |
| 88 | 88 |
| 89 private: | 89 private: |
| 90 std::string old_locale_; | 90 std::string old_locale_; |
| 91 }; | 91 }; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 } | 196 } |
| 197 | 197 |
| 198 for (size_t i = 0; i < arraysize(kConvertRoundtripCases); ++i) { | 198 for (size_t i = 0; i < arraysize(kConvertRoundtripCases); ++i) { |
| 199 std::wstring wide = kConvertRoundtripCases[i]; | 199 std::wstring wide = kConvertRoundtripCases[i]; |
| 200 std::wstring trip = UTF8ToWide(base::SysWideToNativeMB(wide)); | 200 std::wstring trip = UTF8ToWide(base::SysWideToNativeMB(wide)); |
| 201 EXPECT_EQ(wide.size(), trip.size()); | 201 EXPECT_EQ(wide.size(), trip.size()); |
| 202 EXPECT_EQ(wide, trip); | 202 EXPECT_EQ(wide, trip); |
| 203 } | 203 } |
| 204 } | 204 } |
| 205 #endif // OS_LINUX | 205 #endif // OS_LINUX |
| OLD | NEW |