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

Side by Side Diff: components/autofill/core/browser/autofill_merge_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 <map> 7 #include <map>
8 #include <memory> 8 #include <memory>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 84
85 return files; 85 return files;
86 } 86 }
87 87
88 // Serializes the |profiles| into a string. 88 // Serializes the |profiles| into a string.
89 std::string SerializeProfiles(const std::vector<AutofillProfile*>& profiles) { 89 std::string SerializeProfiles(const std::vector<AutofillProfile*>& profiles) {
90 std::string result; 90 std::string result;
91 for (size_t i = 0; i < profiles.size(); ++i) { 91 for (size_t i = 0; i < profiles.size(); ++i) {
92 result += kProfileSeparator; 92 result += kProfileSeparator;
93 result += "\n"; 93 result += "\n";
94 for (size_t j = 0; j < arraysize(kProfileFieldTypes); ++j) { 94 for (const ServerFieldType& type : kProfileFieldTypes) {
95 ServerFieldType type = kProfileFieldTypes[j];
96 base::string16 value = profiles[i]->GetRawInfo(type); 95 base::string16 value = profiles[i]->GetRawInfo(type);
97 result += AutofillType(type).ToString(); 96 result += AutofillType(type).ToString();
98 result += kFieldSeparator; 97 result += kFieldSeparator;
99 if (!value.empty()) { 98 if (!value.empty()) {
100 base::ReplaceFirstSubstringAfterOffset( 99 base::ReplaceFirstSubstringAfterOffset(
101 &value, 0, base::ASCIIToUTF16("\\n"), base::ASCIIToUTF16("\n")); 100 &value, 0, base::ASCIIToUTF16("\\n"), base::ASCIIToUTF16("\n"));
102 result += " "; 101 result += " ";
103 result += base::UTF16ToUTF8(value); 102 result += base::UTF16ToUTF8(value);
104 } 103 }
105 result += "\n"; 104 result += "\n";
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 return string_to_field_type_map_[str]; 288 return string_to_field_type_map_[str];
290 } 289 }
291 290
292 TEST_P(AutofillMergeTest, DataDrivenMergeProfiles) { 291 TEST_P(AutofillMergeTest, DataDrivenMergeProfiles) {
293 RunOneDataDrivenTest(GetParam(), GetOutputDirectory(kTestName)); 292 RunOneDataDrivenTest(GetParam(), GetOutputDirectory(kTestName));
294 } 293 }
295 294
296 INSTANTIATE_TEST_CASE_P(, AutofillMergeTest, testing::ValuesIn(GetTestFiles())); 295 INSTANTIATE_TEST_CASE_P(, AutofillMergeTest, testing::ValuesIn(GetTestFiles()));
297 296
298 } // namespace autofill 297 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_manager_unittest.cc ('k') | components/autofill/core/browser/autofill_profile.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698