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

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

Issue 1542323002: Switch to standard integer types in base/i18n/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: header Created 4 years, 12 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') | base/i18n/rtl.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>
6 #include <stdint.h>
7
5 #include <limits> 8 #include <limits>
6 9
7 #include "base/i18n/number_formatting.h" 10 #include "base/i18n/number_formatting.h"
8 #include "base/i18n/rtl.h" 11 #include "base/i18n/rtl.h"
12 #include "base/macros.h"
9 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
10 #include "base/test/icu_test_util.h" 14 #include "base/test/icu_test_util.h"
15 #include "build/build_config.h"
11 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
12 #include "third_party/icu/source/i18n/unicode/usearch.h" 17 #include "third_party/icu/source/i18n/unicode/usearch.h"
13 18
14 namespace base { 19 namespace base {
15 namespace { 20 namespace {
16 21
17 TEST(NumberFormattingTest, FormatNumber) { 22 TEST(NumberFormattingTest, FormatNumber) {
18 static const struct { 23 static const struct {
19 int64 number; 24 int64_t number;
20 const char* expected_english; 25 const char* expected_english;
21 const char* expected_german; 26 const char* expected_german;
22 } cases[] = { 27 } cases[] = {
23 {0, "0", "0"}, 28 {0, "0", "0"},
24 {1024, "1,024", "1.024"}, 29 {1024, "1,024", "1.024"},
25 {std::numeric_limits<int64>::max(), 30 {std::numeric_limits<int64_t>::max(),
26 "9,223,372,036,854,775,807", "9.223.372.036.854.775.807"}, 31 "9,223,372,036,854,775,807", "9.223.372.036.854.775.807"},
27 {std::numeric_limits<int64>::min(), 32 {std::numeric_limits<int64_t>::min(),
28 "-9,223,372,036,854,775,808", "-9.223.372.036.854.775.808"}, 33 "-9,223,372,036,854,775,808", "-9.223.372.036.854.775.808"},
29 {-42, "-42", "-42"}, 34 {-42, "-42", "-42"},
30 }; 35 };
31 36
32 test::ScopedRestoreICUDefaultLocale restore_locale; 37 test::ScopedRestoreICUDefaultLocale restore_locale;
33 38
34 for (size_t i = 0; i < arraysize(cases); ++i) { 39 for (size_t i = 0; i < arraysize(cases); ++i) {
35 i18n::SetICUDefaultLocale("en"); 40 i18n::SetICUDefaultLocale("en");
36 testing::ResetFormatters(); 41 testing::ResetFormatters();
37 EXPECT_EQ(cases[i].expected_english, 42 EXPECT_EQ(cases[i].expected_english,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 UTF16ToUTF8(FormatDouble(cases[i].number, cases[i].frac_digits))); 89 UTF16ToUTF8(FormatDouble(cases[i].number, cases[i].frac_digits)));
85 i18n::SetICUDefaultLocale("de"); 90 i18n::SetICUDefaultLocale("de");
86 testing::ResetFormatters(); 91 testing::ResetFormatters();
87 EXPECT_EQ(cases[i].expected_german, 92 EXPECT_EQ(cases[i].expected_german,
88 UTF16ToUTF8(FormatDouble(cases[i].number, cases[i].frac_digits))); 93 UTF16ToUTF8(FormatDouble(cases[i].number, cases[i].frac_digits)));
89 } 94 }
90 } 95 }
91 96
92 } // namespace 97 } // namespace
93 } // namespace base 98 } // namespace base
OLDNEW
« no previous file with comments | « base/i18n/number_formatting.cc ('k') | base/i18n/rtl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698