OLD | NEW |
---|---|
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 Loading... | |
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 |
OLD | NEW |