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

Side by Side Diff: base/i18n/number_formatting_unittest.cc

Issue 2447513002: Update ICU to 58.1 (Closed)
Patch Set: fix a typo in html comment Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « DEPS ('k') | components/url_formatter/url_formatter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/i18n/number_formatting.h" 10 #include "base/i18n/number_formatting.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 EXPECT_EQ(cases[i].expected_german, 92 EXPECT_EQ(cases[i].expected_german,
93 UTF16ToUTF8(FormatDouble(cases[i].number, cases[i].frac_digits))); 93 UTF16ToUTF8(FormatDouble(cases[i].number, cases[i].frac_digits)));
94 } 94 }
95 } 95 }
96 96
97 TEST(NumberFormattingTest, FormatPercent) { 97 TEST(NumberFormattingTest, FormatPercent) {
98 static const struct { 98 static const struct {
99 int64_t number; 99 int64_t number;
100 const char* expected_english; 100 const char* expected_english;
101 const wchar_t* expected_german; // Note: Space before % isn't \x20. 101 const wchar_t* expected_german; // Note: Space before % isn't \x20.
102 const wchar_t* expected_persian; // Note: Non-Arabic numbers and %. 102 // Note: Eastern Arabic-Indic digits (U+06Fx) for Persian and
103 // Arabic-Indic digits (U+066x) for Arabic.
104 // See http://unicode.org/cldr/trac/ticket/9040 for details.
105 const wchar_t* expected_persian;
106 const wchar_t* expected_arabic;
103 } cases[] = { 107 } cases[] = {
104 {0, "0%", L"0\xa0%", L"\x6f0\x200f\x66a"}, 108 {0, "0%", L"0\xa0%", L"\x200e\x66a\xa0\x6f0", L"\x660\xa0\x66a\x61c"},
105 {42, "42%", L"42\xa0%", L"\x6f4\x6f2\x200f\x66a"}, 109 {42, "42%", L"42\xa0%", L"\x200e\x66a\xa0\x6f4\x6f2",
106 {1024, "1,024%", L"1.024\xa0%", L"\x6f1\x66c\x6f0\x6f2\x6f4\x200f\x66a"}, 110 L"\x664\x662\xa0\x66a\x61c"},
111 {1024, "1,024%", L"1.024\xa0%",
112 L"\x200e\x66a\xa0\x6f1\x66c\x6f0\x6f2\x6f4",
113 L"\x661\x66c\x660\x662\x664\xa0\x66a\x61c"},
107 }; 114 };
108 115
109 test::ScopedRestoreICUDefaultLocale restore_locale; 116 test::ScopedRestoreICUDefaultLocale restore_locale;
110 for (size_t i = 0; i < arraysize(cases); ++i) { 117 for (size_t i = 0; i < arraysize(cases); ++i) {
111 i18n::SetICUDefaultLocale("en"); 118 i18n::SetICUDefaultLocale("en");
112 EXPECT_EQ(ASCIIToUTF16(cases[i].expected_english), 119 EXPECT_EQ(ASCIIToUTF16(cases[i].expected_english),
113 FormatPercent(cases[i].number)); 120 FormatPercent(cases[i].number));
114 i18n::SetICUDefaultLocale("de"); 121 i18n::SetICUDefaultLocale("de");
115 EXPECT_EQ(WideToUTF16(cases[i].expected_german), 122 EXPECT_EQ(WideToUTF16(cases[i].expected_german),
116 FormatPercent(cases[i].number)); 123 FormatPercent(cases[i].number));
117 i18n::SetICUDefaultLocale("fa"); 124 i18n::SetICUDefaultLocale("fa");
118 EXPECT_EQ(WideToUTF16(cases[i].expected_persian), 125 EXPECT_EQ(WideToUTF16(cases[i].expected_persian),
119 FormatPercent(cases[i].number)); 126 FormatPercent(cases[i].number));
127 i18n::SetICUDefaultLocale("ar");
128 EXPECT_EQ(WideToUTF16(cases[i].expected_arabic),
129 FormatPercent(cases[i].number));
120 } 130 }
121 } 131 }
122 132
123 } // namespace 133 } // namespace
124 } // namespace base 134 } // namespace base
OLDNEW
« no previous file with comments | « DEPS ('k') | components/url_formatter/url_formatter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698