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

Side by Side Diff: third_party/libaddressinput/chromium/cpp/test/rule_test.cc

Issue 261013010: autocomplete: add ability to get full address (hidden behind a flag). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: self review Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (C) 2013 Google Inc. 1 // Copyright (C) 2013 Google Inc.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 #include "rule.h" 15 #include "rule.h"
16 16
17 #include <libaddressinput/address_field.h> 17 #include <libaddressinput/address_field.h>
18 18
19 #include <string> 19 #include <string>
20 #include <utility> 20 #include <utility>
21 #include <vector> 21 #include <vector>
22 22
23 #include <gtest/gtest.h> 23 #include <gtest/gtest.h>
24 24
25 #include "grit/libaddressinput_strings.h"
26 #include "region_data_constants.h" 25 #include "region_data_constants.h"
27 26
28 namespace { 27 namespace {
29 28
30 using i18n::addressinput::AddressField; 29 using i18n::addressinput::AddressField;
31 using i18n::addressinput::ADMIN_AREA; 30 using i18n::addressinput::ADMIN_AREA;
32 using i18n::addressinput::COUNTRY; 31 using i18n::addressinput::COUNTRY;
33 using i18n::addressinput::FormatElement; 32 using i18n::addressinput::FormatElement;
34 using i18n::addressinput::LOCALITY; 33 using i18n::addressinput::LOCALITY;
35 using i18n::addressinput::ORGANIZATION; 34 using i18n::addressinput::ORGANIZATION;
(...skipping 29 matching lines...) Expand all
65 "\"zip\":\"\\\\d{5}([ \\\\-]\\\\d{4})?\"" 64 "\"zip\":\"\\\\d{5}([ \\\\-]\\\\d{4})?\""
66 "}")); 65 "}"));
67 66
68 Rule copy; 67 Rule copy;
69 EXPECT_NE(rule.GetFormat(), copy.GetFormat()); 68 EXPECT_NE(rule.GetFormat(), copy.GetFormat());
70 EXPECT_NE(rule.GetRequired(), copy.GetRequired()); 69 EXPECT_NE(rule.GetRequired(), copy.GetRequired());
71 EXPECT_NE(rule.GetSubKeys(), copy.GetSubKeys()); 70 EXPECT_NE(rule.GetSubKeys(), copy.GetSubKeys());
72 EXPECT_NE(rule.GetLanguages(), copy.GetLanguages()); 71 EXPECT_NE(rule.GetLanguages(), copy.GetLanguages());
73 EXPECT_NE(rule.GetLanguage(), copy.GetLanguage()); 72 EXPECT_NE(rule.GetLanguage(), copy.GetLanguage());
74 EXPECT_NE(rule.GetPostalCodeFormat(), copy.GetPostalCodeFormat()); 73 EXPECT_NE(rule.GetPostalCodeFormat(), copy.GetPostalCodeFormat());
75 EXPECT_NE(rule.GetAdminAreaNameMessageId(), 74 EXPECT_NE(rule.GetAdminAreaNameType(),
76 copy.GetAdminAreaNameMessageId()); 75 copy.GetAdminAreaNameType());
77 EXPECT_NE(rule.GetInvalidAdminAreaMessageId(), 76 EXPECT_NE(rule.GetPostalCodeNameType(),
78 copy.GetInvalidAdminAreaMessageId()); 77 copy.GetPostalCodeNameType());
79 EXPECT_NE(rule.GetPostalCodeNameMessageId(),
80 copy.GetPostalCodeNameMessageId());
81 EXPECT_NE(rule.GetInvalidPostalCodeMessageId(),
82 copy.GetInvalidPostalCodeMessageId());
83 78
84 copy.CopyFrom(rule); 79 copy.CopyFrom(rule);
85 EXPECT_EQ(rule.GetFormat(), copy.GetFormat()); 80 EXPECT_EQ(rule.GetFormat(), copy.GetFormat());
86 EXPECT_EQ(rule.GetRequired(), copy.GetRequired()); 81 EXPECT_EQ(rule.GetRequired(), copy.GetRequired());
87 EXPECT_EQ(rule.GetSubKeys(), copy.GetSubKeys()); 82 EXPECT_EQ(rule.GetSubKeys(), copy.GetSubKeys());
88 EXPECT_EQ(rule.GetLanguages(), copy.GetLanguages()); 83 EXPECT_EQ(rule.GetLanguages(), copy.GetLanguages());
89 EXPECT_EQ(rule.GetLanguage(), copy.GetLanguage()); 84 EXPECT_EQ(rule.GetLanguage(), copy.GetLanguage());
90 EXPECT_EQ(rule.GetPostalCodeFormat(), copy.GetPostalCodeFormat()); 85 EXPECT_EQ(rule.GetPostalCodeFormat(), copy.GetPostalCodeFormat());
91 EXPECT_EQ(rule.GetAdminAreaNameMessageId(), 86 EXPECT_EQ(rule.GetAdminAreaNameType(),
92 copy.GetAdminAreaNameMessageId()); 87 copy.GetAdminAreaNameType());
93 EXPECT_EQ(rule.GetInvalidAdminAreaMessageId(), 88 EXPECT_EQ(rule.GetPostalCodeNameType(),
94 copy.GetInvalidAdminAreaMessageId()); 89 copy.GetPostalCodeNameType());
95 EXPECT_EQ(rule.GetPostalCodeNameMessageId(),
96 copy.GetPostalCodeNameMessageId());
97 EXPECT_EQ(rule.GetInvalidPostalCodeMessageId(),
98 copy.GetInvalidPostalCodeMessageId());
99 } 90 }
100 91
101 TEST(RuleTest, ParseOverwritesRule) { 92 TEST(RuleTest, ParseOverwritesRule) {
102 Rule rule; 93 Rule rule;
103 ASSERT_TRUE(rule.ParseSerializedRule( 94 ASSERT_TRUE(rule.ParseSerializedRule(
104 "{" 95 "{"
105 "\"fmt\":\"%S%Z\"," 96 "\"fmt\":\"%S%Z\","
106 "\"require\":\"SZ\"," 97 "\"require\":\"SZ\","
107 "\"state_name_type\":\"area\"," 98 "\"state_name_type\":\"area\","
108 "\"zip_name_type\":\"postal\"," 99 "\"zip_name_type\":\"postal\","
109 "\"sub_keys\":\"CA~NY~TX\"," 100 "\"sub_keys\":\"CA~NY~TX\","
110 "\"lang\":\"en\"," 101 "\"lang\":\"en\","
111 "\"languages\":\"en~fr\"," 102 "\"languages\":\"en~fr\","
112 "\"zip\":\"\\\\d{5}([ \\\\-]\\\\d{4})?\"" 103 "\"zip\":\"\\\\d{5}([ \\\\-]\\\\d{4})?\""
113 "}")); 104 "}"));
114 EXPECT_FALSE(IsFormatEmpty(rule.GetFormat())); 105 EXPECT_FALSE(IsFormatEmpty(rule.GetFormat()));
115 EXPECT_FALSE(rule.GetRequired().empty()); 106 EXPECT_FALSE(rule.GetRequired().empty());
116 EXPECT_FALSE(rule.GetSubKeys().empty()); 107 EXPECT_FALSE(rule.GetSubKeys().empty());
117 EXPECT_FALSE(rule.GetLanguages().empty()); 108 EXPECT_FALSE(rule.GetLanguages().empty());
118 EXPECT_FALSE(rule.GetLanguage().empty()); 109 EXPECT_FALSE(rule.GetLanguage().empty());
119 EXPECT_FALSE(rule.GetPostalCodeFormat().empty()); 110 EXPECT_FALSE(rule.GetPostalCodeFormat().empty());
120 EXPECT_EQ(IDS_LIBADDRESSINPUT_I18N_AREA, 111 EXPECT_EQ("area", rule.GetAdminAreaNameType());
121 rule.GetAdminAreaNameMessageId()); 112 EXPECT_EQ("postal", rule.GetPostalCodeNameType());
122 EXPECT_EQ(IDS_LIBADDRESSINPUT_I18N_INVALID_AREA,
123 rule.GetInvalidAdminAreaMessageId());
124 EXPECT_EQ(IDS_LIBADDRESSINPUT_I18N_POSTAL_CODE_LABEL,
125 rule.GetPostalCodeNameMessageId());
126 EXPECT_EQ(IDS_LIBADDRESSINPUT_I18N_INVALID_POSTAL_CODE_LABEL,
127 rule.GetInvalidPostalCodeMessageId());
128 113
129 ASSERT_TRUE(rule.ParseSerializedRule( 114 ASSERT_TRUE(rule.ParseSerializedRule(
130 "{" 115 "{"
131 "\"fmt\":\"\"," 116 "\"fmt\":\"\","
132 "\"require\":\"\"," 117 "\"require\":\"\","
133 "\"state_name_type\":\"do_si\"," 118 "\"state_name_type\":\"do_si\","
134 "\"zip_name_type\":\"zip\"," 119 "\"zip_name_type\":\"zip\","
135 "\"sub_keys\":\"\"," 120 "\"sub_keys\":\"\","
136 "\"lang\":\"\"," 121 "\"lang\":\"\","
137 "\"languages\":\"\"," 122 "\"languages\":\"\","
138 "\"zip\":\"\"" 123 "\"zip\":\"\""
139 "}")); 124 "}"));
140 EXPECT_TRUE(IsFormatEmpty(rule.GetFormat())); 125 EXPECT_TRUE(IsFormatEmpty(rule.GetFormat()));
141 EXPECT_TRUE(rule.GetRequired().empty()); 126 EXPECT_TRUE(rule.GetRequired().empty());
142 EXPECT_TRUE(rule.GetSubKeys().empty()); 127 EXPECT_TRUE(rule.GetSubKeys().empty());
143 EXPECT_TRUE(rule.GetLanguages().empty()); 128 EXPECT_TRUE(rule.GetLanguages().empty());
144 EXPECT_TRUE(rule.GetLanguage().empty()); 129 EXPECT_TRUE(rule.GetLanguage().empty());
145 EXPECT_TRUE(rule.GetPostalCodeFormat().empty()); 130 EXPECT_TRUE(rule.GetPostalCodeFormat().empty());
146 EXPECT_EQ(IDS_LIBADDRESSINPUT_I18N_DO_SI, 131 EXPECT_EQ("do_si", rule.GetAdminAreaNameType());
147 rule.GetAdminAreaNameMessageId()); 132 EXPECT_EQ("zip", rule.GetPostalCodeNameType());
148 EXPECT_EQ(IDS_LIBADDRESSINPUT_I18N_INVALID_DO_SI,
149 rule.GetInvalidAdminAreaMessageId());
150 EXPECT_EQ(IDS_LIBADDRESSINPUT_I18N_ZIP_CODE_LABEL,
151 rule.GetPostalCodeNameMessageId());
152 EXPECT_EQ(IDS_LIBADDRESSINPUT_I18N_INVALID_ZIP_CODE_LABEL,
153 rule.GetInvalidPostalCodeMessageId());
154 } 133 }
155 134
156 TEST(RuleTest, ParseEmptyDataDoesNotOverwriteRule) { 135 TEST(RuleTest, ParseEmptyDataDoesNotOverwriteRule) {
157 Rule rule; 136 Rule rule;
158 ASSERT_TRUE(rule.ParseSerializedRule( 137 ASSERT_TRUE(rule.ParseSerializedRule(
159 "{" 138 "{"
160 "\"fmt\":\"%S%Z\"," 139 "\"fmt\":\"%S%Z\","
161 "\"require\":\"SZ\"," 140 "\"require\":\"SZ\","
162 "\"state_name_type\":\"area\"," 141 "\"state_name_type\":\"area\","
163 "\"zip_name_type\":\"postal\"," 142 "\"zip_name_type\":\"postal\","
164 "\"sub_keys\":\"CA~NY~TX\"," 143 "\"sub_keys\":\"CA~NY~TX\","
165 "\"lang\":\"en\"," 144 "\"lang\":\"en\","
166 "\"languages\":\"en~fr\"," 145 "\"languages\":\"en~fr\","
167 "\"zip\":\"\\\\d{5}([ \\\\-]\\\\d{4})?\"" 146 "\"zip\":\"\\\\d{5}([ \\\\-]\\\\d{4})?\""
168 "}")); 147 "}"));
169 148
170 Rule copy; 149 Rule copy;
171 copy.CopyFrom(rule); 150 copy.CopyFrom(rule);
172 ASSERT_TRUE(copy.ParseSerializedRule("{}")); 151 ASSERT_TRUE(copy.ParseSerializedRule("{}"));
173 152
174 EXPECT_EQ(rule.GetFormat(), copy.GetFormat()); 153 EXPECT_EQ(rule.GetFormat(), copy.GetFormat());
175 EXPECT_EQ(rule.GetRequired(), copy.GetRequired()); 154 EXPECT_EQ(rule.GetRequired(), copy.GetRequired());
176 EXPECT_EQ(rule.GetSubKeys(), copy.GetSubKeys()); 155 EXPECT_EQ(rule.GetSubKeys(), copy.GetSubKeys());
177 EXPECT_EQ(rule.GetLanguages(), copy.GetLanguages()); 156 EXPECT_EQ(rule.GetLanguages(), copy.GetLanguages());
178 EXPECT_EQ(rule.GetLanguage(), copy.GetLanguage()); 157 EXPECT_EQ(rule.GetLanguage(), copy.GetLanguage());
179 EXPECT_EQ(rule.GetPostalCodeFormat(), copy.GetPostalCodeFormat()); 158 EXPECT_EQ(rule.GetPostalCodeFormat(), copy.GetPostalCodeFormat());
180 EXPECT_EQ(rule.GetAdminAreaNameMessageId(), 159 EXPECT_EQ(rule.GetAdminAreaNameType(),
181 copy.GetAdminAreaNameMessageId()); 160 copy.GetAdminAreaNameType());
182 EXPECT_EQ(rule.GetInvalidAdminAreaMessageId(), 161 EXPECT_EQ(rule.GetPostalCodeNameType(),
183 copy.GetInvalidAdminAreaMessageId()); 162 copy.GetPostalCodeNameType());
184 EXPECT_EQ(rule.GetPostalCodeNameMessageId(),
185 copy.GetPostalCodeNameMessageId());
186 EXPECT_EQ(rule.GetInvalidPostalCodeMessageId(),
187 copy.GetInvalidPostalCodeMessageId());
188 } 163 }
189 164
190 TEST(RuleTest, ParseFormatWithNewLines) { 165 TEST(RuleTest, ParseFormatWithNewLines) {
191 Rule rule; 166 Rule rule;
192 ASSERT_TRUE( 167 ASSERT_TRUE(
193 rule.ParseSerializedRule("{\"fmt\":\"%O%n%N%n%A%nAX-%Z %C%nÅLAND\"}")); 168 rule.ParseSerializedRule("{\"fmt\":\"%O%n%N%n%A%nAX-%Z %C%nÅLAND\"}"));
194 169
195 std::vector<std::vector<FormatElement> > expected_format; 170 std::vector<std::vector<FormatElement> > expected_format;
196 expected_format.push_back( 171 expected_format.push_back(
197 std::vector<FormatElement>(1, FormatElement(ORGANIZATION))); 172 std::vector<FormatElement>(1, FormatElement(ORGANIZATION)));
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 // Keep input latin. 320 // Keep input latin.
346 EXPECT_TRUE(rule.CanonicalizeSubKey("Bartopolis2", true, &sub_key)); 321 EXPECT_TRUE(rule.CanonicalizeSubKey("Bartopolis2", true, &sub_key));
347 EXPECT_EQ("Bartopolis2", sub_key); 322 EXPECT_EQ("Bartopolis2", sub_key);
348 sub_key.clear(); 323 sub_key.clear();
349 324
350 EXPECT_FALSE(rule.CanonicalizeSubKey("Beertopia", false, &sub_key)); 325 EXPECT_FALSE(rule.CanonicalizeSubKey("Beertopia", false, &sub_key));
351 EXPECT_EQ("", sub_key); 326 EXPECT_EQ("", sub_key);
352 } 327 }
353 328
354 struct LabelData { 329 struct LabelData {
355 LabelData(const std::string& data, int name_id, int error_id) 330 LabelData(const std::string& data, const std::string& name_type)
356 : data(data), name_id(name_id), error_id(error_id) {} 331 : data(data), name_type(name_type) {}
357 332
358 ~LabelData() {} 333 ~LabelData() {}
359 334
360 std::string data; 335 std::string data;
361 int name_id; 336 std::string name_type;
362 int error_id;
363 }; 337 };
364 338
365 // Tests for parsing the postal code name. 339 // Tests for parsing the postal code name.
366 class PostalCodeNameParseTest : public testing::TestWithParam<LabelData> { 340 class PostalCodeNameParseTest : public testing::TestWithParam<LabelData> {
367 protected: 341 protected:
368 Rule rule_; 342 Rule rule_;
369 }; 343 };
370 344
371 // Verifies that a postal code name is parsed correctly. 345 // Verifies that a postal code name is parsed correctly.
372 TEST_P(PostalCodeNameParseTest, ParsedCorrectly) { 346 TEST_P(PostalCodeNameParseTest, ParsedCorrectly) {
373 ASSERT_TRUE(rule_.ParseSerializedRule(GetParam().data)); 347 ASSERT_TRUE(rule_.ParseSerializedRule(GetParam().data));
374 EXPECT_EQ(GetParam().name_id, rule_.GetPostalCodeNameMessageId()); 348 EXPECT_EQ(GetParam().name_type, rule_.GetPostalCodeNameType());
375 EXPECT_EQ(GetParam().error_id, rule_.GetInvalidPostalCodeMessageId());
376 EXPECT_EQ(GetParam().error_id, rule_.GetInvalidFieldMessageId(POSTAL_CODE));
377 } 349 }
378 350
379 // Test parsing all postal code names. 351 // Test parsing all postal code names.
380 INSTANTIATE_TEST_CASE_P( 352 INSTANTIATE_TEST_CASE_P(
381 AllPostalCodeNames, PostalCodeNameParseTest, 353 AllPostalCodeNames, PostalCodeNameParseTest,
382 testing::Values( 354 testing::Values(
383 LabelData("{\"zip_name_type\":\"postal\"}", 355 LabelData("{\"zip_name_type\":\"postal\"}", "postal"),
384 IDS_LIBADDRESSINPUT_I18N_POSTAL_CODE_LABEL, 356 LabelData("{\"zip_name_type\":\"zip\"}", "zip")));
385 IDS_LIBADDRESSINPUT_I18N_INVALID_POSTAL_CODE_LABEL),
386 LabelData("{\"zip_name_type\":\"zip\"}",
387 IDS_LIBADDRESSINPUT_I18N_ZIP_CODE_LABEL,
388 IDS_LIBADDRESSINPUT_I18N_INVALID_ZIP_CODE_LABEL)));
389 357
390 // Tests for parsing the administrative area name. 358 // Tests for parsing the administrative area name.
391 class AdminAreaNameParseTest : public testing::TestWithParam<LabelData> { 359 class AdminAreaNameParseTest : public testing::TestWithParam<LabelData> {
392 protected: 360 protected:
393 Rule rule_; 361 Rule rule_;
394 }; 362 };
395 363
396 // Verifies that an administrative area name is parsed correctly. 364 // Verifies that an administrative area name is parsed correctly.
397 TEST_P(AdminAreaNameParseTest, ParsedCorrectly) { 365 TEST_P(AdminAreaNameParseTest, ParsedCorrectly) {
398 ASSERT_TRUE(rule_.ParseSerializedRule(GetParam().data)); 366 ASSERT_TRUE(rule_.ParseSerializedRule(GetParam().data));
399 EXPECT_EQ(GetParam().name_id, rule_.GetAdminAreaNameMessageId()); 367 EXPECT_EQ(GetParam().name_type, rule_.GetAdminAreaNameType());
400 EXPECT_EQ(GetParam().error_id, rule_.GetInvalidAdminAreaMessageId());
401 EXPECT_EQ(GetParam().error_id, rule_.GetInvalidFieldMessageId(ADMIN_AREA));
402 } 368 }
403 369
404 // Test parsing all administrative area names. 370 // Test parsing all administrative area names.
405 INSTANTIATE_TEST_CASE_P( 371 INSTANTIATE_TEST_CASE_P(
406 AllAdminAreaNames, AdminAreaNameParseTest, 372 AllAdminAreaNames, AdminAreaNameParseTest,
407 testing::Values( 373 testing::Values(
408 LabelData("{\"state_name_type\":\"area\"}", 374 LabelData("{\"state_name_type\":\"area\"}", "area"),
409 IDS_LIBADDRESSINPUT_I18N_AREA, 375 LabelData("{\"state_name_type\":\"county\"}", "county"),
410 IDS_LIBADDRESSINPUT_I18N_INVALID_AREA), 376 LabelData("{\"state_name_type\":\"department\"}", "department"),
411 LabelData("{\"state_name_type\":\"county\"}", 377 LabelData("{\"state_name_type\":\"district\"}", "district"),
412 IDS_LIBADDRESSINPUT_I18N_COUNTY_LABEL, 378 LabelData("{\"state_name_type\":\"do_si\"}", "do_si"),
413 IDS_LIBADDRESSINPUT_I18N_INVALID_COUNTY_LABEL), 379 LabelData("{\"state_name_type\":\"emirate\"}", "emirate"),
414 LabelData("{\"state_name_type\":\"department\"}", 380 LabelData("{\"state_name_type\":\"island\"}", "island"),
415 IDS_LIBADDRESSINPUT_I18N_DEPARTMENT, 381 LabelData("{\"state_name_type\":\"parish\"}", "parish"),
416 IDS_LIBADDRESSINPUT_I18N_INVALID_DEPARTMENT), 382 LabelData("{\"state_name_type\":\"prefecture\"}", "prefecture"),
417 LabelData("{\"state_name_type\":\"district\"}", 383 LabelData("{\"state_name_type\":\"province\"}", "province"),
418 IDS_LIBADDRESSINPUT_I18N_DEPENDENT_LOCALITY_LABEL, 384 LabelData("{\"state_name_type\":\"state\"}", "state")));
419 IDS_LIBADDRESSINPUT_I18N_INVALID_DEPENDENT_LOCALITY_LABEL),
420 LabelData("{\"state_name_type\":\"do_si\"}",
421 IDS_LIBADDRESSINPUT_I18N_DO_SI,
422 IDS_LIBADDRESSINPUT_I18N_INVALID_DO_SI),
423 LabelData("{\"state_name_type\":\"emirate\"}",
424 IDS_LIBADDRESSINPUT_I18N_EMIRATE,
425 IDS_LIBADDRESSINPUT_I18N_INVALID_EMIRATE),
426 LabelData("{\"state_name_type\":\"island\"}",
427 IDS_LIBADDRESSINPUT_I18N_ISLAND,
428 IDS_LIBADDRESSINPUT_I18N_INVALID_ISLAND),
429 LabelData("{\"state_name_type\":\"parish\"}",
430 IDS_LIBADDRESSINPUT_I18N_PARISH,
431 IDS_LIBADDRESSINPUT_I18N_INVALID_PARISH),
432 LabelData("{\"state_name_type\":\"prefecture\"}",
433 IDS_LIBADDRESSINPUT_I18N_PREFECTURE,
434 IDS_LIBADDRESSINPUT_I18N_INVALID_PREFECTURE),
435 LabelData("{\"state_name_type\":\"province\"}",
436 IDS_LIBADDRESSINPUT_I18N_PROVINCE,
437 IDS_LIBADDRESSINPUT_I18N_INVALID_PROVINCE),
438 LabelData("{\"state_name_type\":\"state\"}",
439 IDS_LIBADDRESSINPUT_I18N_STATE_LABEL,
440 IDS_LIBADDRESSINPUT_I18N_INVALID_STATE_LABEL)));
441 385
442 // Verifies that an address format does not contain consecutive lines with 386 // Verifies that an address format does not contain consecutive lines with
443 // multiple fields each. Such address format (e.g. {{ELEMENT, ELEMENT}, 387 // multiple fields each. Such address format (e.g. {{ELEMENT, ELEMENT},
444 // {ELEMENT, ELEMENT}}) will result in incorrect behavior of BuildComponents() 388 // {ELEMENT, ELEMENT}}) will result in incorrect behavior of BuildComponents()
445 // public API. 389 // public API.
446 TEST(RuleParseTest, ConsecutiveLinesWithMultipleFields) { 390 TEST(RuleParseTest, ConsecutiveLinesWithMultipleFields) {
447 const std::vector<std::string>& region_codes = 391 const std::vector<std::string>& region_codes =
448 RegionDataConstants::GetRegionCodes(); 392 RegionDataConstants::GetRegionCodes();
449 Rule rule; 393 Rule rule;
450 for (size_t i = 0; i < region_codes.size(); ++i) { 394 for (size_t i = 0; i < region_codes.size(); ++i) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 !line_it->at(i + 1).IsField() && 449 !line_it->at(i + 1).IsField() &&
506 line_it->at(i + 1).literal == " "; 450 line_it->at(i + 1).literal == " ";
507 EXPECT_TRUE(surrounded_by_newlines || surrounded_by_spaces); 451 EXPECT_TRUE(surrounded_by_newlines || surrounded_by_spaces);
508 } 452 }
509 } 453 }
510 } 454 }
511 } 455 }
512 } 456 }
513 457
514 } // namespace 458 } // namespace
OLDNEW
« no previous file with comments | « third_party/libaddressinput/chromium/cpp/test/address_ui_test.cc ('k') | third_party/libaddressinput/libaddressinput.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698