OLD | NEW |
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, |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 | 322 |
323 TEST(RuleTest, ParseSubKeyTest) { | 323 TEST(RuleTest, ParseSubKeyTest) { |
324 i18n::addressinput::Rule rule; | 324 i18n::addressinput::Rule rule; |
325 ASSERT_TRUE(rule.ParseSerializedRule( | 325 ASSERT_TRUE(rule.ParseSerializedRule( |
326 "{ \"sub_keys\": \"FOO~BAR~BAZ\"," | 326 "{ \"sub_keys\": \"FOO~BAR~BAZ\"," |
327 " \"sub_names\": \"Foolandia~Bartopolis~Bazmonia\"," | 327 " \"sub_names\": \"Foolandia~Bartopolis~Bazmonia\"," |
328 " \"sub_lnames\": \"Foolandia2~Bartopolis2~Bazmonia2\" }")); | 328 " \"sub_lnames\": \"Foolandia2~Bartopolis2~Bazmonia2\" }")); |
329 EXPECT_EQ(3U, rule.GetSubKeys().size()); | 329 EXPECT_EQ(3U, rule.GetSubKeys().size()); |
330 | 330 |
331 std::string sub_key; | 331 std::string sub_key; |
332 EXPECT_TRUE(rule.CanonicalizeSubKey("BAR", &sub_key)); | 332 EXPECT_TRUE(rule.CanonicalizeSubKey("BAR", false, &sub_key)); |
333 EXPECT_EQ("BAR", sub_key); | 333 EXPECT_EQ("BAR", sub_key); |
334 sub_key.clear(); | 334 sub_key.clear(); |
335 | 335 |
336 EXPECT_TRUE(rule.CanonicalizeSubKey("Bartopolis", &sub_key)); | 336 EXPECT_TRUE(rule.CanonicalizeSubKey("Bartopolis", false, &sub_key)); |
337 EXPECT_EQ("BAR", sub_key); | 337 EXPECT_EQ("BAR", sub_key); |
338 sub_key.clear(); | 338 sub_key.clear(); |
339 | 339 |
340 EXPECT_TRUE(rule.CanonicalizeSubKey("Bartopolis2", &sub_key)); | 340 // Unlatinize. |
| 341 EXPECT_TRUE(rule.CanonicalizeSubKey("Bartopolis2", false, &sub_key)); |
341 EXPECT_EQ("BAR", sub_key); | 342 EXPECT_EQ("BAR", sub_key); |
342 sub_key.clear(); | 343 sub_key.clear(); |
343 | 344 |
344 EXPECT_FALSE(rule.CanonicalizeSubKey("Beertopia", &sub_key)); | 345 // Keep input latin. |
| 346 EXPECT_TRUE(rule.CanonicalizeSubKey("Bartopolis2", true, &sub_key)); |
| 347 EXPECT_EQ("Bartopolis2", sub_key); |
| 348 sub_key.clear(); |
| 349 |
| 350 EXPECT_FALSE(rule.CanonicalizeSubKey("Beertopia", false, &sub_key)); |
345 EXPECT_EQ("", sub_key); | 351 EXPECT_EQ("", sub_key); |
346 } | 352 } |
347 | 353 |
348 struct LabelData { | 354 struct LabelData { |
349 LabelData(const std::string& data, int name_id, int error_id) | 355 LabelData(const std::string& data, int name_id, int error_id) |
350 : data(data), name_id(name_id), error_id(error_id) {} | 356 : data(data), name_id(name_id), error_id(error_id) {} |
351 | 357 |
352 ~LabelData() {} | 358 ~LabelData() {} |
353 | 359 |
354 std::string data; | 360 std::string data; |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 !line_it->at(i + 1).IsField() && | 505 !line_it->at(i + 1).IsField() && |
500 line_it->at(i + 1).literal == " "; | 506 line_it->at(i + 1).literal == " "; |
501 EXPECT_TRUE(surrounded_by_newlines || surrounded_by_spaces); | 507 EXPECT_TRUE(surrounded_by_newlines || surrounded_by_spaces); |
502 } | 508 } |
503 } | 509 } |
504 } | 510 } |
505 } | 511 } |
506 } | 512 } |
507 | 513 |
508 } // namespace | 514 } // namespace |
OLD | NEW |