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

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

Issue 389863002: Remove Chrome's own version of libaddressinput in favor of the upstream. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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
(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 "region_data_constants.h"
16
17 #include <string>
18 #include <vector>
19
20 #include <gtest/gtest.h>
21
22 namespace {
23
24 using i18n::addressinput::RegionDataConstants;
25
26 // Returns AssertionSuccess if |data| begins with '{' and ends with '}'.
27 testing::AssertionResult HasCurlyBraces(const std::string& data) {
28 if (data.empty()) {
29 return testing::AssertionFailure() << "data is empty";
30 }
31 if (data[0] != '{') {
32 return testing::AssertionFailure() << data << " does not start with '{'";
33 }
34 if (data[data.length() - 1] != '}') {
35 return testing::AssertionFailure() << data << " does not end with '}'";
36 }
37 return testing::AssertionSuccess();
38 }
39
40 // Verifies that the default region data begins with '{' and ends with '}'.
41 TEST(DefaultRegionDataTest, DefaultRegionHasCurlyBraces) {
42 EXPECT_TRUE(HasCurlyBraces(RegionDataConstants::GetDefaultRegionData()));
43 }
44
45 TEST(RegionDataTest, RegionDataHasCertainProperties) {
46 const std::vector<std::string>& region_data_codes =
47 RegionDataConstants::GetRegionCodes();
48 for (size_t i = 0; i < region_data_codes.size(); ++i) {
49 SCOPED_TRACE("For region: " + region_data_codes[i]);
50 EXPECT_EQ(2U, region_data_codes[i].length());
51
52 const std::string& region_data = RegionDataConstants::GetRegionData(
53 region_data_codes[i]);
54
55 // Verifies that a region data value begins with '{' and end with '}', for
56 // example "{\"fmt\":\"%C%S\"}".
57 EXPECT_TRUE(HasCurlyBraces(region_data));
58
59 // Verifies that a region data value contains a "name" key, for example
60 // "{\"name\":\"SOUTH AFRICA\"}".
61 EXPECT_NE(std::string::npos, region_data.find("\"name\":"));
62 }
63 }
64
65 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698