| 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| OLD | NEW |