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

Side by Side Diff: components/autofill/core/browser/address_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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/autofill/core/browser/address_i18n.h" 5 #include "components/autofill/core/browser/address_i18n.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 {false, ADDRESS_HOME_STATE, ADMIN_AREA}, 54 {false, ADDRESS_HOME_STATE, ADMIN_AREA},
55 {false, ADDRESS_HOME_CITY, LOCALITY}, 55 {false, ADDRESS_HOME_CITY, LOCALITY},
56 {false, ADDRESS_HOME_DEPENDENT_LOCALITY, DEPENDENT_LOCALITY}, 56 {false, ADDRESS_HOME_DEPENDENT_LOCALITY, DEPENDENT_LOCALITY},
57 {false, ADDRESS_HOME_SORTING_CODE, SORTING_CODE}, 57 {false, ADDRESS_HOME_SORTING_CODE, SORTING_CODE},
58 {false, ADDRESS_HOME_ZIP, POSTAL_CODE}, 58 {false, ADDRESS_HOME_ZIP, POSTAL_CODE},
59 {false, ADDRESS_HOME_STREET_ADDRESS, STREET_ADDRESS}, 59 {false, ADDRESS_HOME_STREET_ADDRESS, STREET_ADDRESS},
60 {false, COMPANY_NAME, ORGANIZATION}, 60 {false, COMPANY_NAME, ORGANIZATION},
61 {false, NAME_FULL, RECIPIENT}, 61 {false, NAME_FULL, RECIPIENT},
62 }; 62 };
63 63
64 for (size_t i = 0; i < arraysize(kTestData); ++i) { 64 for (const auto& test_data : kTestData) {
65 AddressField address_field; 65 AddressField address_field;
66 EXPECT_TRUE(FieldForType(kTestData[i].server_field, &address_field)); 66 EXPECT_TRUE(FieldForType(test_data.server_field, &address_field));
67 EXPECT_EQ(kTestData[i].address_field, address_field); 67 EXPECT_EQ(test_data.address_field, address_field);
68 68
69 ServerFieldType server_field = 69 ServerFieldType server_field =
70 TypeForField(kTestData[i].address_field, kTestData[i].billing); 70 TypeForField(test_data.address_field, test_data.billing);
71 EXPECT_EQ(kTestData[i].server_field, server_field); 71 EXPECT_EQ(test_data.server_field, server_field);
72 } 72 }
73 } 73 }
74 74
75 TEST(AddressI18nTest, FieldTypeUnidirectionalConversions) { 75 TEST(AddressI18nTest, FieldTypeUnidirectionalConversions) {
76 static const struct { 76 static const struct {
77 ServerFieldType server_field; 77 ServerFieldType server_field;
78 AddressField expected_address_field; 78 AddressField expected_address_field;
79 } kTestData[] = { 79 } kTestData[] = {
80 {ADDRESS_BILLING_LINE1, STREET_ADDRESS}, 80 {ADDRESS_BILLING_LINE1, STREET_ADDRESS},
81 {ADDRESS_BILLING_LINE2, STREET_ADDRESS}, 81 {ADDRESS_BILLING_LINE2, STREET_ADDRESS},
82 {ADDRESS_HOME_LINE1, STREET_ADDRESS}, 82 {ADDRESS_HOME_LINE1, STREET_ADDRESS},
83 {ADDRESS_HOME_LINE2, STREET_ADDRESS}, 83 {ADDRESS_HOME_LINE2, STREET_ADDRESS},
84 }; 84 };
85 85
86 for (size_t i = 0; i < arraysize(kTestData); ++i) { 86 for (const auto& test_data : kTestData) {
87 AddressField actual_address_field; 87 AddressField actual_address_field;
88 FieldForType(kTestData[i].server_field, &actual_address_field); 88 FieldForType(test_data.server_field, &actual_address_field);
89 EXPECT_EQ(kTestData[i].expected_address_field, actual_address_field); 89 EXPECT_EQ(test_data.expected_address_field, actual_address_field);
90 } 90 }
91 } 91 }
92 92
93 TEST(AddressI18nTest, UnconvertableServerFields) { 93 TEST(AddressI18nTest, UnconvertableServerFields) {
94 EXPECT_FALSE(FieldForType(PHONE_HOME_NUMBER, NULL)); 94 EXPECT_FALSE(FieldForType(PHONE_HOME_NUMBER, NULL));
95 EXPECT_FALSE(FieldForType(EMAIL_ADDRESS, NULL)); 95 EXPECT_FALSE(FieldForType(EMAIL_ADDRESS, NULL));
96 } 96 }
97 97
98 TEST(AddressI18nTest, CreateAddressDataFromAutofillProfile) { 98 TEST(AddressI18nTest, CreateAddressDataFromAutofillProfile) {
99 AutofillProfile profile(base::GenerateGUID(), "http://www.example.com/"); 99 AutofillProfile profile(base::GenerateGUID(), "http://www.example.com/");
(...skipping 22 matching lines...) Expand all
122 expected.postal_code = "91111"; 122 expected.postal_code = "91111";
123 expected.language_code = "en"; 123 expected.language_code = "en";
124 expected.organization = "Underworld"; 124 expected.organization = "Underworld";
125 expected.recipient = "John H. Doe"; 125 expected.recipient = "John H. Doe";
126 126
127 EXPECT_EQ(expected, *actual); 127 EXPECT_EQ(expected, *actual);
128 } 128 }
129 129
130 } // namespace i18n 130 } // namespace i18n
131 } // namespace autofill 131 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/content/renderer/form_cache.cc ('k') | components/autofill/core/browser/address_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698