Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: base/test/test_util.h

Issue 7129056: Cleanup in base/test. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed base.gyp Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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_
Joao da Silva 2011/06/10 15:53:56 Done, see scoped_locale.[h,cc].
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698