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

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: Temporarily switch to staging URL. 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 scoped_ptr<Json> dict;
121 ASSERT_TRUE(json_->GetJsonValueForKey("dict", &dict));
122 ASSERT_TRUE(dict != NULL);
123
124 std::string string_value;
125 EXPECT_TRUE(dict->GetStringValueForKey("key", &string_value));
126 EXPECT_EQ("value", string_value);
127 }
128
129 TEST_F(JsonTest, GetMissingJsonValue) {
130 ASSERT_TRUE(json_->ParseObject("{\"dict\": {\"key\": \"value\"}}"));
131
132 scoped_ptr<Json> dict;
133 EXPECT_FALSE(json_->GetJsonValueForKey("not-dict", &dict));
134 EXPECT_TRUE(dict == NULL);
135 }
136
137 TEST_F(JsonTest, GetNullJsonValue) {
138 ASSERT_TRUE(json_->ParseObject("{\"dict\": {\"key\": \"value\"}}"));
139 EXPECT_TRUE(json_->GetJsonValueForKey("dict", NULL));
140 }
141
142
117 } // namespace 143 } // namespace
118 144
119 } // namespace addressinput 145 } // namespace addressinput
120 } // namespace i18n 146 } // namespace i18n
OLDNEW
« no previous file with comments | « third_party/libaddressinput/chromium/cpp/test/retriever_test.cc ('k') | third_party/libaddressinput/chromium/json.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698