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(); |