Lei Zhang | fc45549 | 2019-06-14 17:16:09 +0000 | [diff] [blame] | 1 | // Copyright 2019 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 | #include "third_party/base/test/scoped_locale.h" |
| 6 | |
| 7 | #include <locale.h> |
| 8 | |
| 9 | #include "testing/gtest/include/gtest/gtest.h" |
| 10 | |
| 11 | namespace pdfium { |
| 12 | namespace base { |
| 13 | |
| 14 | ScopedLocale::ScopedLocale(const std::string& locale) { |
| 15 | prev_locale_ = setlocale(LC_ALL, nullptr); |
| 16 | EXPECT_TRUE(setlocale(LC_ALL, locale.c_str()) != nullptr) |
| 17 | << "Failed to set locale: " << locale; |
| 18 | } |
| 19 | |
| 20 | ScopedLocale::~ScopedLocale() { |
| 21 | EXPECT_STREQ(prev_locale_.c_str(), setlocale(LC_ALL, prev_locale_.c_str())); |
| 22 | } |
| 23 | |
| 24 | } // namespace base |
| 25 | } // namespace pdfium |