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

Unified Diff: base/i18n/message_formatter_unittest.cc

Issue 1958073003: Add a percent format example Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add a padding example 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/i18n/message_formatter_unittest.cc
diff --git a/base/i18n/message_formatter_unittest.cc b/base/i18n/message_formatter_unittest.cc
index a6f461370c7ffaef00f5971f63ca09139060f4d4..9a0615e069f2278a2d781a01f0b157a63af50c88 100644
--- a/base/i18n/message_formatter_unittest.cc
+++ b/base/i18n/message_formatter_unittest.cc
@@ -138,10 +138,17 @@ TEST_F(MessageFormatterTest, PluralNumberedArgsWithDate) {
TEST_F(MessageFormatterTest, DateTimeAndNumber) {
// Note that using 'mph' for all locales is not a good i18n practice.
+ // For various ways to format numbers, see
+ // http://icu-project.org/apiref/icu4c/classicu_1_1MessageFormat.html and
+ // http://icu-project.org/apiref/icu4c/classicu_1_1DecimalFormat.html
const string16 pattern = ASCIIToUTF16(
"At {0,time, short} on {0,date, medium}, "
"there was {1} at building {2,number,integer}. "
- "The speed of the wind was {3,number,###.#} mph.");
+ "The speed of the wind was {3,number,###.#} mph."
+ "It was a new record {4,number,percent} higher than the previous."
+ "It was a new record {4,number,##.#%} higher than the previous."
+ // padding example: '*' followed by a padding symbol.
+ "We were given {5,number,integer}:{6,number,*0##} for evacuation.");
using icu::DateFormat;
std::unique_ptr<DateFormat> tf(
@@ -155,10 +162,13 @@ TEST_F(MessageFormatterTest, DateTimeAndNumber) {
expected.append(" on ");
AppendFormattedDateTime(df, now, &expected);
expected.append(", there was an explosion at building 3. "
- "The speed of the wind was 37.4 mph.");
+ "The speed of the wind was 37.4 mph."
+ "It was a new record 6% higher than the previous."
+ "It was a new record 5.8% higher than the previous."
+ "We were given 3:05 for evacuation.");
EXPECT_EQ(expected, UTF16ToASCII(MessageFormatter::FormatWithNumberedArgs(
- pattern, now, "an explosion", 3, 37.413)));
+ pattern, now, "an explosion", 3, 37.413, 0.0578, 3, 5)));
}
TEST_F(MessageFormatterTest, SelectorSingleOrMultiple) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698