blob: 2643dd9be17f162c44c76f8fa3a4dd5770b4466b [file] [log] [blame]
Lei Zhangfc455492019-06-14 17:16:09 +00001// 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
11namespace pdfium {
12namespace base {
13
14ScopedLocale::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
20ScopedLocale::~ScopedLocale() {
21 EXPECT_STREQ(prev_locale_.c_str(), setlocale(LC_ALL, prev_locale_.c_str()));
22}
23
24} // namespace base
25} // namespace pdfium