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

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

Issue 2424793002: Revert of Replace for loops with |arraysize| with for each loops (Closed)
Patch Set: 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 (const char* valid_match : kValidMatches) { 135 for (size_t i = 0; i < arraysize(kValidMatches); ++i) {
136 SCOPED_TRACE(valid_match); 136 SCOPED_TRACE(kValidMatches[i]);
137 ServerFieldTypeSet matching_types; 137 ServerFieldTypeSet matching_types;
138 address.GetMatchingTypes(ASCIIToUTF16(valid_match), "US", &matching_types); 138 address.GetMatchingTypes(ASCIIToUTF16(kValidMatches[i]), "US",
139 &matching_types);
139 ASSERT_EQ(1U, matching_types.size()); 140 ASSERT_EQ(1U, matching_types.size());
140 EXPECT_EQ(ADDRESS_HOME_COUNTRY, *matching_types.begin()); 141 EXPECT_EQ(ADDRESS_HOME_COUNTRY, *matching_types.begin());
141 } 142 }
142 143
143 const char* const kInvalidMatches[] = { 144 const char* const kInvalidMatches[] = {
144 "United", 145 "United",
145 "Garbage" 146 "Garbage"
146 }; 147 };
147 for (const char* invalid_match : kInvalidMatches) { 148 for (size_t i = 0; i < arraysize(kInvalidMatches); ++i) {
148 ServerFieldTypeSet matching_types; 149 ServerFieldTypeSet matching_types;
149 address.GetMatchingTypes(ASCIIToUTF16(invalid_match), "US", 150 address.GetMatchingTypes(ASCIIToUTF16(kInvalidMatches[i]), "US",
150 &matching_types); 151 &matching_types);
151 EXPECT_EQ(0U, matching_types.size()); 152 EXPECT_EQ(0U, matching_types.size());
152 } 153 }
153 154
154 // Make sure that garbage values don't match when the country code is empty. 155 // Make sure that garbage values don't match when the country code is empty.
155 address.SetRawInfo(ADDRESS_HOME_COUNTRY, base::string16()); 156 address.SetRawInfo(ADDRESS_HOME_COUNTRY, base::string16());
156 EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_COUNTRY)); 157 EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_COUNTRY));
157 ServerFieldTypeSet matching_types; 158 ServerFieldTypeSet matching_types;
158 address.GetMatchingTypes(ASCIIToUTF16("Garbage"), "US", &matching_types); 159 address.GetMatchingTypes(ASCIIToUTF16("Garbage"), "US", &matching_types);
159 EXPECT_EQ(0U, matching_types.size()); 160 EXPECT_EQ(0U, matching_types.size());
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 ASCIIToUTF16("Address line 1" 378 ASCIIToUTF16("Address line 1"
378 "Address line 2" 379 "Address line 2"
379 "\n"), 380 "\n"),
380 "en-US")); 381 "en-US"));
381 EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_LINE1)); 382 EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_LINE1));
382 EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_LINE2)); 383 EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_LINE2));
383 EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_STREET_ADDRESS)); 384 EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_STREET_ADDRESS));
384 } 385 }
385 386
386 } // namespace autofill 387 } // 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