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

Side by Side Diff: components/autofill/core/browser/address_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 <string> 7 #include <string>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 Address address; 125 Address address;
126 address.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US")); 126 address.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US"));
127 127
128 const char* const kValidMatches[] = { 128 const char* const kValidMatches[] = {
129 "United States", 129 "United States",
130 "USA", 130 "USA",
131 "US", 131 "US",
132 "United states", 132 "United states",
133 "us" 133 "us"
134 }; 134 };
135 for (size_t i = 0; i < arraysize(kValidMatches); ++i) { 135 for (const char* valid_match : kValidMatches) {
136 SCOPED_TRACE(kValidMatches[i]); 136 SCOPED_TRACE(valid_match);
137 ServerFieldTypeSet matching_types; 137 ServerFieldTypeSet matching_types;
138 address.GetMatchingTypes(ASCIIToUTF16(kValidMatches[i]), "US", 138 address.GetMatchingTypes(ASCIIToUTF16(valid_match), "US", &matching_types);
139 &matching_types);
140 ASSERT_EQ(1U, matching_types.size()); 139 ASSERT_EQ(1U, matching_types.size());
141 EXPECT_EQ(ADDRESS_HOME_COUNTRY, *matching_types.begin()); 140 EXPECT_EQ(ADDRESS_HOME_COUNTRY, *matching_types.begin());
142 } 141 }
143 142
144 const char* const kInvalidMatches[] = { 143 const char* const kInvalidMatches[] = {
145 "United", 144 "United",
146 "Garbage" 145 "Garbage"
147 }; 146 };
148 for (size_t i = 0; i < arraysize(kInvalidMatches); ++i) { 147 for (const char* invalid_match : kInvalidMatches) {
149 ServerFieldTypeSet matching_types; 148 ServerFieldTypeSet matching_types;
150 address.GetMatchingTypes(ASCIIToUTF16(kInvalidMatches[i]), "US", 149 address.GetMatchingTypes(ASCIIToUTF16(invalid_match), "US",
151 &matching_types); 150 &matching_types);
152 EXPECT_EQ(0U, matching_types.size()); 151 EXPECT_EQ(0U, matching_types.size());
153 } 152 }
154 153
155 // Make sure that garbage values don't match when the country code is empty. 154 // Make sure that garbage values don't match when the country code is empty.
156 address.SetRawInfo(ADDRESS_HOME_COUNTRY, base::string16()); 155 address.SetRawInfo(ADDRESS_HOME_COUNTRY, base::string16());
157 EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_COUNTRY)); 156 EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_COUNTRY));
158 ServerFieldTypeSet matching_types; 157 ServerFieldTypeSet matching_types;
159 address.GetMatchingTypes(ASCIIToUTF16("Garbage"), "US", &matching_types); 158 address.GetMatchingTypes(ASCIIToUTF16("Garbage"), "US", &matching_types);
160 EXPECT_EQ(0U, matching_types.size()); 159 EXPECT_EQ(0U, matching_types.size());
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 ASCIIToUTF16("Address line 1" 377 ASCIIToUTF16("Address line 1"
379 "Address line 2" 378 "Address line 2"
380 "\n"), 379 "\n"),
381 "en-US")); 380 "en-US"));
382 EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_LINE1)); 381 EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_LINE1));
383 EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_LINE2)); 382 EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_LINE2));
384 EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_STREET_ADDRESS)); 383 EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_STREET_ADDRESS));
385 } 384 }
386 385
387 } // namespace autofill 386 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/address_i18n_unittest.cc ('k') | components/autofill/core/browser/autofill_data_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698