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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 expected.push_back(static_cast<AddressField>(NEWLINE)); | 44 expected.push_back(static_cast<AddressField>(NEWLINE)); |
45 expected.push_back(STREET_ADDRESS); | 45 expected.push_back(STREET_ADDRESS); |
46 expected.push_back(static_cast<AddressField>(NEWLINE)); | 46 expected.push_back(static_cast<AddressField>(NEWLINE)); |
47 expected.push_back(POSTAL_CODE); | 47 expected.push_back(POSTAL_CODE); |
48 expected.push_back(LOCALITY); | 48 expected.push_back(LOCALITY); |
49 expected.push_back(static_cast<AddressField>(NEWLINE)); | 49 expected.push_back(static_cast<AddressField>(NEWLINE)); |
50 | 50 |
51 EXPECT_EQ(expected, actual); | 51 EXPECT_EQ(expected, actual); |
52 } | 52 } |
53 | 53 |
54 TEST(AddressFieldUtilTest, DoubleTokenPrefixIsIgnored) { | 54 TEST(AddressFieldUtilTest, DoubleTokenPrefixIsIgnoredInFormat) { |
55 std::vector<AddressField> actual; | 55 std::vector<AddressField> actual; |
56 ParseAddressFieldsFormat("%%R", &actual); | 56 ParseAddressFieldsFormat("%%R", &actual); |
57 std::vector<AddressField> expected(1, COUNTRY); | 57 std::vector<AddressField> expected(1, COUNTRY); |
58 EXPECT_EQ(expected, actual); | 58 EXPECT_EQ(expected, actual); |
59 } | 59 } |
60 | 60 |
61 TEST(AddressFieldUtilTest, PrefixWithoutTokenIsIgnored) { | 61 TEST(AddressFieldUtilTest, PrefixWithoutTokenIsIgnoredInFormat) { |
62 std::vector<AddressField> actual; | 62 std::vector<AddressField> actual; |
63 ParseAddressFieldsFormat("%", &actual); | 63 ParseAddressFieldsFormat("%", &actual); |
64 EXPECT_TRUE(actual.empty()); | 64 EXPECT_TRUE(actual.empty()); |
65 } | 65 } |
66 | 66 |
67 TEST(AddressFieldUtilTest, EmptyString) { | 67 TEST(AddressFieldUtilTest, EmptyStringFormat) { |
68 std::vector<AddressField> fields; | 68 std::vector<AddressField> fields; |
69 ParseAddressFieldsFormat(std::string(), &fields); | 69 ParseAddressFieldsFormat(std::string(), &fields); |
70 EXPECT_TRUE(fields.empty()); | 70 EXPECT_TRUE(fields.empty()); |
71 } | 71 } |
72 | 72 |
| 73 TEST(AddressFieldUtilTest, ParseRequiredFields) { |
| 74 std::vector<AddressField> actual; |
| 75 ParseAddressFieldsRequired("ONAZC", &actual); |
| 76 |
| 77 std::vector<AddressField> expected; |
| 78 expected.push_back(ORGANIZATION); |
| 79 expected.push_back(RECIPIENT); |
| 80 expected.push_back(STREET_ADDRESS); |
| 81 expected.push_back(POSTAL_CODE); |
| 82 expected.push_back(LOCALITY); |
| 83 |
| 84 EXPECT_EQ(expected, actual); |
| 85 } |
| 86 |
| 87 TEST(AddressFieldUtilTest, EmptyStringRequiredFields) { |
| 88 std::vector<AddressField> fields; |
| 89 ParseAddressFieldsRequired(std::string(), &fields); |
| 90 EXPECT_TRUE(fields.empty()); |
| 91 } |
| 92 |
73 } // namespace | 93 } // namespace |
OLD | NEW |