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

Unified Diff: base/i18n/number_formatting_unittest.cc

Issue 1989563002: i18n of Zoom % to use locally correct numeric glyphs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add unit test for FormatPercent() Created 4 years, 7 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/number_formatting.cc ('k') | chrome/app/generated_resources.grd » ('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 31341ac25e421013cadc0835056d079a54bfbd83..a131bf3e7d7a078dfbb028316ef91fe73e465a46 100644
--- a/base/i18n/number_formatting_unittest.cc
+++ b/base/i18n/number_formatting_unittest.cc
@@ -94,5 +94,31 @@ TEST(NumberFormattingTest, FormatDouble) {
}
}
+TEST(NumberFormattingTest, FormatPercent) {
+ static const struct {
+ int64_t number;
+ const char* expected_english;
+ const wchar_t* expected_german; // Note: Space before % isn't \x20.
jungshik at Google 2016/05/25 07:48:29 I didn't know that U+00A0 is used, but it kinda ma
+ const wchar_t* expected_persian; // Note: Non-Arabic numbers and %.
+ } cases[] = {
+ {0, "0%", L"0\xa0%", L"\x6f0\x200f\x66a"},
+ {42, "42%", L"42\xa0%", L"\x6f4\x6f2\x200f\x66a"},
+ {1024, "1,024%", L"1.024\xa0%", L"\x6f1\x66c\x6f0\x6f2\x6f4\x200f\x66a"},
+ };
+
+ test::ScopedRestoreICUDefaultLocale restore_locale;
+ for (size_t i = 0; i < arraysize(cases); ++i) {
+ i18n::SetICUDefaultLocale("en");
+ EXPECT_EQ(ASCIIToUTF16(cases[i].expected_english),
+ FormatPercent(cases[i].number));
+ i18n::SetICUDefaultLocale("de");
+ EXPECT_EQ(WideToUTF16(cases[i].expected_german),
+ FormatPercent(cases[i].number));
+ i18n::SetICUDefaultLocale("fa");
+ EXPECT_EQ(WideToUTF16(cases[i].expected_persian),
+ FormatPercent(cases[i].number));
+ }
+}
+
} // namespace
} // namespace base
« no previous file with comments | « base/i18n/number_formatting.cc ('k') | chrome/app/generated_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698