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

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

Issue 110533002: [rac] Temporarily copy libaddressinput to Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Avoid redefinition of basictypes.h Created 7 years 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
(Empty)
1 // Copyright (C) 2013 Google Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (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
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #include "address_field_util.h"
16
17 #include <libaddressinput/address_field.h>
18
19 #include <string>
20 #include <vector>
21
22 #include <gtest/gtest.h>
23
24 namespace {
25
26 using i18n::addressinput::AddressField;
27 using i18n::addressinput::COUNTRY;
28 using i18n::addressinput::LOCALITY;
29 using i18n::addressinput::NEWLINE;
30 using i18n::addressinput::ORGANIZATION;
31 using i18n::addressinput::ParseAddressFieldsFormat;
32 using i18n::addressinput::POSTAL_CODE;
33 using i18n::addressinput::RECIPIENT;
34 using i18n::addressinput::STREET_ADDRESS;
35
36 TEST(AddressFieldUtilTest, ParseNewlineFormat) {
37 std::vector<AddressField> actual;
38 ParseAddressFieldsFormat("%O%n%N%n%A%nAX-%Z %C%nĂ…LAND", &actual);
39
40 std::vector<AddressField> expected;
41 expected.push_back(ORGANIZATION);
42 expected.push_back(static_cast<AddressField>(NEWLINE));
43 expected.push_back(RECIPIENT);
44 expected.push_back(static_cast<AddressField>(NEWLINE));
45 expected.push_back(STREET_ADDRESS);
46 expected.push_back(static_cast<AddressField>(NEWLINE));
47 expected.push_back(POSTAL_CODE);
48 expected.push_back(LOCALITY);
49 expected.push_back(static_cast<AddressField>(NEWLINE));
50
51 EXPECT_EQ(expected, actual);
52 }
53
54 TEST(AddressFieldUtilTest, DoubleTokenPrefixIsIgnored) {
55 std::vector<AddressField> actual;
56 ParseAddressFieldsFormat("%%R", &actual);
57 std::vector<AddressField> expected(1, COUNTRY);
58 EXPECT_EQ(expected, actual);
59 }
60
61 TEST(AddressFieldUtilTest, PrefixWithoutTokenIsIgnored) {
62 std::vector<AddressField> actual;
63 ParseAddressFieldsFormat("%", &actual);
64 EXPECT_TRUE(actual.empty());
65 }
66
67 TEST(AddressFieldUtilTest, EmptyString) {
68 std::vector<AddressField> fields;
69 ParseAddressFieldsFormat(std::string(), &fields);
70 EXPECT_TRUE(fields.empty());
71 }
72
73 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698