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

Unified Diff: base/i18n/number_formatting_unittest.cc

Issue 1162603004: Restore locales after tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make restores scoped Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/i18n/case_conversion_unittest.cc ('k') | base/i18n/rtl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/i18n/number_formatting_unittest.cc
diff --git a/base/i18n/number_formatting_unittest.cc b/base/i18n/number_formatting_unittest.cc
index 3b0718d454f399395cb20215cad5490b6e1fb7c8..ee9fd82aa1e28589ca46a050bd65e1f8686cf523 100644
--- a/base/i18n/number_formatting_unittest.cc
+++ b/base/i18n/number_formatting_unittest.cc
@@ -8,10 +8,26 @@
#include "base/i18n/rtl.h"
#include "base/strings/utf_string_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/icu/source/i18n/unicode/usearch.h"
namespace base {
namespace {
+class ScopedSetICUDefaultLocale {
Mark Mentovai 2015/08/18 13:18:14 You shouldn’t have to write this class in every fi
+ std::string default_locale;
+
+ public:
+ ScopedSetICUDefaultLocale(std::string locale);
+ ~ScopedSetICUDefaultLocale();
+};
+
+ScopedSetICUDefaultLocale::ScopedSetICUDefaultLocale(std::string locale)
+ : default_locale(locale) {}
+
+ScopedSetICUDefaultLocale::~ScopedSetICUDefaultLocale() {
+ i18n::SetICUDefaultLocale(default_locale.data());
+}
+
TEST(NumberFormattingTest, FormatNumber) {
static const struct {
int64 number;
@@ -27,6 +43,8 @@ TEST(NumberFormattingTest, FormatNumber) {
{-42, "-42", "-42"},
};
+ ScopedSetICUDefaultLocale restore_object(uloc_getDefault());
+
for (size_t i = 0; i < arraysize(cases); ++i) {
i18n::SetICUDefaultLocale("en");
testing::ResetFormatters();
@@ -72,6 +90,7 @@ TEST(NumberFormattingTest, FormatDouble) {
{-42.7, 3, "-42.700", "-42,700"},
};
+ ScopedSetICUDefaultLocale restore_object(uloc_getDefault());
for (size_t i = 0; i < arraysize(cases); ++i) {
i18n::SetICUDefaultLocale("en");
testing::ResetFormatters();
« no previous file with comments | « base/i18n/case_conversion_unittest.cc ('k') | base/i18n/rtl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698