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

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

Issue 140823005: [rac] Download country code data in a single HTTP request. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add comment. Created 6 years, 11 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,
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 } 107 }
108 108
109 TEST_F(JsonTest, StringIsNotValid) { 109 TEST_F(JsonTest, StringIsNotValid) {
110 EXPECT_FALSE(json_->ParseObject("\"value\"")); 110 EXPECT_FALSE(json_->ParseObject("\"value\""));
111 } 111 }
112 112
113 TEST_F(JsonTest, NumberIsNotValid) { 113 TEST_F(JsonTest, NumberIsNotValid) {
114 EXPECT_FALSE(json_->ParseObject("3")); 114 EXPECT_FALSE(json_->ParseObject("3"));
115 } 115 }
116 116
117 TEST_F(JsonTest, GetJsonValue) {
118 ASSERT_TRUE(json_->ParseObject("{\"dict\": {\"key\": \"value\"}}"));
119
120 Json* json_value = NULL;
121 ASSERT_TRUE(json_->GetJsonValueForKey("dict", &json_value));
122 scoped_ptr<Json> dict(json_value);
123 ASSERT_TRUE(dict != NULL);
124
125 std::string string_value;
126 EXPECT_TRUE(dict->GetStringValueForKey("key", &string_value));
127 EXPECT_EQ("value", string_value);
128 }
129
130 TEST_F(JsonTest, GetMissingJsonValue) {
131 ASSERT_TRUE(json_->ParseObject("{\"dict\": {\"key\": \"value\"}}"));
132
133 Json* json_value = NULL;
134 EXPECT_FALSE(json_->GetJsonValueForKey("not-dict", &json_value));
135 EXPECT_TRUE(json_value == NULL);
136 }
137
138 TEST_F(JsonTest, GetNullJsonValue) {
139 ASSERT_TRUE(json_->ParseObject("{\"dict\": {\"key\": \"value\"}}"));
140 EXPECT_TRUE(json_->GetJsonValueForKey("dict", NULL));
141 }
142
143
117 } // namespace 144 } // namespace
118 145
119 } // namespace addressinput 146 } // namespace addressinput
120 } // namespace i18n 147 } // namespace i18n
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698