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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « base/i18n/number_formatting.cc ('k') | chrome/app/generated_resources.grd » ('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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 testing::ResetFormatters(); 87 testing::ResetFormatters();
88 EXPECT_EQ(cases[i].expected_english, 88 EXPECT_EQ(cases[i].expected_english,
89 UTF16ToUTF8(FormatDouble(cases[i].number, cases[i].frac_digits))); 89 UTF16ToUTF8(FormatDouble(cases[i].number, cases[i].frac_digits)));
90 i18n::SetICUDefaultLocale("de"); 90 i18n::SetICUDefaultLocale("de");
91 testing::ResetFormatters(); 91 testing::ResetFormatters();
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) {
98 static const struct {
99 int64_t number;
100 const char* expected_english;
101 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
102 const wchar_t* expected_persian; // Note: Non-Arabic numbers and %.
103 } cases[] = {
104 {0, "0%", L"0\xa0%", L"\x6f0\x200f\x66a"},
105 {42, "42%", L"42\xa0%", L"\x6f4\x6f2\x200f\x66a"},
106 {1024, "1,024%", L"1.024\xa0%", L"\x6f1\x66c\x6f0\x6f2\x6f4\x200f\x66a"},
107 };
108
109 test::ScopedRestoreICUDefaultLocale restore_locale;
110 for (size_t i = 0; i < arraysize(cases); ++i) {
111 i18n::SetICUDefaultLocale("en");
112 EXPECT_EQ(ASCIIToUTF16(cases[i].expected_english),
113 FormatPercent(cases[i].number));
114 i18n::SetICUDefaultLocale("de");
115 EXPECT_EQ(WideToUTF16(cases[i].expected_german),
116 FormatPercent(cases[i].number));
117 i18n::SetICUDefaultLocale("fa");
118 EXPECT_EQ(WideToUTF16(cases[i].expected_persian),
119 FormatPercent(cases[i].number));
120 }
121 }
122
97 } // namespace 123 } // namespace
98 } // namespace base 124 } // namespace base
OLDNEW
« 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