Index: base/test/scoped_locale.h |
diff --git a/base/test/test_util.h b/base/test/scoped_locale.h |
similarity index 61% |
rename from base/test/test_util.h |
rename to base/test/scoped_locale.h |
index 63f0b16c5b15ff965edf75cf11ec9a56e46dad23..a7ad17493bf42ba2e186bb58cc2117daf50b1078 100644 |
--- a/base/test/test_util.h |
+++ b/base/test/scoped_locale.h |
@@ -6,36 +6,32 @@ |
#define BASE_TEST_TEST_UTIL_H_ |
#pragma once |
-// Generic utilities used only by tests. |
- |
-#include <locale.h> |
- |
#include <string> |
-namespace base { |
+#include "base/basictypes.h" |
-#if defined(OS_POSIX) |
+namespace base { |
// Sets the given |locale| on construction, and restores the previous locale |
// on destruction. |
class ScopedSetLocale { |
public: |
- explicit ScopedSetLocale(const char* locale) { |
- old_locale_ = setlocale(LC_ALL, NULL); |
- setlocale(LC_ALL, locale); |
- } |
- ~ScopedSetLocale() { |
- setlocale(LC_ALL, old_locale_.c_str()); |
+ explicit ScopedSetLocale(const std::string& locale); |
Joao da Silva
2011/06/10 15:53:56
Done. I didn't use a StringPiece because is stores
|
+ ~ScopedSetLocale(); |
+ |
+ // Returns the locale that was set by the ctor. |
+ // Can be NULL, if the locale requested isn't available. |
+ const char* current_locale() const { |
+ return current_locale_; |
} |
private: |
- std::string old_locale_; |
+ const char* prev_locale_; |
+ const char* current_locale_; |
DISALLOW_COPY_AND_ASSIGN(ScopedSetLocale); |
}; |
-#endif |
- |
} // namespace base |
#endif // BASE_TEST_TEST_UTIL_H_ |