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

Side by Side Diff: components/autofill/core/browser/phone_number_i18n_unittest.cc

Issue 2417783004: Replace for loops with |arraysize| with for each loops (Closed)
Patch Set: Adressed Comments Created 4 years, 2 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 // Parses vanity numbers. 117 // Parses vanity numbers.
118 {true, "1-650-FLOWERS", "US", "3569377", "650", "1", "US"}, 118 {true, "1-650-FLOWERS", "US", "3569377", "650", "1", "US"},
119 // 800 is not an area code, but the destination code. In our library 119 // 800 is not an area code, but the destination code. In our library
120 // these 120 // these
121 // codes should be treated the same as area codes. 121 // codes should be treated the same as area codes.
122 {true, "1-800-FLOWERS", "US", "3569377", "800", "1", "US"}, 122 {true, "1-800-FLOWERS", "US", "3569377", "800", "1", "US"},
123 // Don't add a country code where there was none. 123 // Don't add a country code where there was none.
124 {true, "(08) 450 777 7777", "DE", "7777777", "8450", "", "DE"}, 124 {true, "(08) 450 777 7777", "DE", "7777777", "8450", "", "DE"},
125 }; 125 };
126 126
127 for (size_t i = 0; i < arraysize(test_cases); ++i) { 127 for (const auto& test_case : test_cases) {
128 SCOPED_TRACE("Testing phone number " + test_cases[i].input); 128 SCOPED_TRACE("Testing phone number " + test_case.input);
129 129
130 base::string16 country_code, city_code, number; 130 base::string16 country_code, city_code, number;
131 std::string deduced_region; 131 std::string deduced_region;
132 ::i18n::phonenumbers::PhoneNumber unused_i18n_number; 132 ::i18n::phonenumbers::PhoneNumber unused_i18n_number;
133 EXPECT_EQ(test_cases[i].valid, 133 EXPECT_EQ(
134 ParsePhoneNumber(ASCIIToUTF16(test_cases[i].input), 134 test_case.valid,
135 test_cases[i].assumed_region, 135 ParsePhoneNumber(ASCIIToUTF16(test_case.input),
136 &country_code, 136 test_case.assumed_region, &country_code, &city_code,
137 &city_code, 137 &number, &deduced_region, &unused_i18n_number));
138 &number, 138 EXPECT_EQ(ASCIIToUTF16(test_case.number), number);
139 &deduced_region, 139 EXPECT_EQ(ASCIIToUTF16(test_case.city_code), city_code);
140 &unused_i18n_number)); 140 EXPECT_EQ(ASCIIToUTF16(test_case.country_code), country_code);
141 EXPECT_EQ(ASCIIToUTF16(test_cases[i].number), number); 141 EXPECT_EQ(test_case.deduced_region, deduced_region);
142 EXPECT_EQ(ASCIIToUTF16(test_cases[i].city_code), city_code);
143 EXPECT_EQ(ASCIIToUTF16(test_cases[i].country_code), country_code);
144 EXPECT_EQ(test_cases[i].deduced_region, deduced_region);
145 } 142 }
146 } 143 }
147 144
148 TEST(PhoneNumberI18NTest, ConstructPhoneNumber) { 145 TEST(PhoneNumberI18NTest, ConstructPhoneNumber) {
149 base::string16 number; 146 base::string16 number;
150 EXPECT_TRUE(ConstructPhoneNumber(ASCIIToUTF16("1"), 147 EXPECT_TRUE(ConstructPhoneNumber(ASCIIToUTF16("1"),
151 ASCIIToUTF16("650"), 148 ASCIIToUTF16("650"),
152 ASCIIToUTF16("2345678"), 149 ASCIIToUTF16("2345678"),
153 "US", 150 "US",
154 &number)); 151 &number));
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 "en-US")); 250 "en-US"));
254 251
255 // Different numbers don't match. 252 // Different numbers don't match.
256 EXPECT_FALSE(PhoneNumbersMatch(ASCIIToUTF16("14158889999"), 253 EXPECT_FALSE(PhoneNumbersMatch(ASCIIToUTF16("14158889999"),
257 ASCIIToUTF16("1415888"), 254 ASCIIToUTF16("1415888"),
258 "US", 255 "US",
259 "en-US")); 256 "en-US"));
260 } 257 }
261 258
262 } // namespace autofill 259 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/phone_field_unittest.cc ('k') | components/autofill/core/browser/state_names.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698