OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef BASE_TEST_TEST_UTIL_H_ | |
6 #define BASE_TEST_TEST_UTIL_H_ | |
7 #pragma once | |
8 | |
9 // Generic utilities used only by tests. | |
10 | |
11 #include <locale.h> | |
12 | |
13 #include <string> | |
14 | |
15 namespace base { | |
16 | |
17 #if defined(OS_POSIX) | |
18 | |
19 // Sets the given |locale| on construction, and restores the previous locale | |
20 // on destruction. | |
21 class ScopedSetLocale { | |
22 public: | |
23 explicit ScopedSetLocale(const char* locale) { | |
24 old_locale_ = setlocale(LC_ALL, NULL); | |
25 setlocale(LC_ALL, locale); | |
26 } | |
27 ~ScopedSetLocale() { | |
28 setlocale(LC_ALL, old_locale_.c_str()); | |
29 } | |
30 | |
31 private: | |
32 std::string old_locale_; | |
33 | |
34 DISALLOW_COPY_AND_ASSIGN(ScopedSetLocale); | |
35 }; | |
36 | |
37 #endif | |
38 | |
39 } // namespace base | |
40 | |
41 #endif // BASE_TEST_TEST_UTIL_H_ | |
OLD | NEW |