| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
| 6 #include "base/json_reader.h" | 6 #include "base/json_reader.h" |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 | 9 |
| 10 TEST(JSONReaderTest, Reading) { | 10 TEST(JSONReaderTest, Reading) { |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 // INF/-INF/NaN are not valid | 176 // INF/-INF/NaN are not valid |
| 177 root = NULL; | 177 root = NULL; |
| 178 ASSERT_FALSE(JSONReader::JsonToValue("1e1000", &root, false, false)); | 178 ASSERT_FALSE(JSONReader::JsonToValue("1e1000", &root, false, false)); |
| 179 ASSERT_FALSE(root); | 179 ASSERT_FALSE(root); |
| 180 root = NULL; | 180 root = NULL; |
| 181 ASSERT_FALSE(JSONReader::JsonToValue("-1e1000", &root, false, false)); | 181 ASSERT_FALSE(JSONReader::JsonToValue("-1e1000", &root, false, false)); |
| 182 ASSERT_FALSE(root); | 182 ASSERT_FALSE(root); |
| 183 root = NULL; | 183 root = NULL; |
| 184 ASSERT_FALSE(JSONReader::JsonToValue("NaN", &root, false, false)); | 184 ASSERT_FALSE(JSONReader::JsonToValue("NaN", &root, false, false)); |
| 185 ASSERT_FALSE(root); | 185 ASSERT_FALSE(root); |
| 186 root = NULL; |
| 187 ASSERT_FALSE(JSONReader::JsonToValue("nan", &root, false, false)); |
| 188 ASSERT_FALSE(root); |
| 189 root = NULL; |
| 190 ASSERT_FALSE(JSONReader::JsonToValue("inf", &root, false, false)); |
| 191 ASSERT_FALSE(root); |
| 186 | 192 |
| 187 // Invalid number formats | 193 // Invalid number formats |
| 188 root = NULL; | 194 root = NULL; |
| 189 ASSERT_FALSE(JSONReader::JsonToValue("4.3.1", &root, false, false)); | 195 ASSERT_FALSE(JSONReader::JsonToValue("4.3.1", &root, false, false)); |
| 190 ASSERT_FALSE(root); | 196 ASSERT_FALSE(root); |
| 191 root = NULL; | 197 root = NULL; |
| 192 ASSERT_FALSE(JSONReader::JsonToValue("4e3.1", &root, false, false)); | 198 ASSERT_FALSE(JSONReader::JsonToValue("4e3.1", &root, false, false)); |
| 193 ASSERT_FALSE(root); | 199 ASSERT_FALSE(root); |
| 194 | 200 |
| 195 // Test string parser | 201 // Test string parser |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 ASSERT_FALSE(JSONReader::JsonToValue("\"123\xc0\x81\"", &root, | 494 ASSERT_FALSE(JSONReader::JsonToValue("\"123\xc0\x81\"", &root, |
| 489 false, false)); | 495 false, false)); |
| 490 | 496 |
| 491 // Test invalid root objects. | 497 // Test invalid root objects. |
| 492 root = NULL; | 498 root = NULL; |
| 493 ASSERT_FALSE(JSONReader::Read("null", &root, false)); | 499 ASSERT_FALSE(JSONReader::Read("null", &root, false)); |
| 494 ASSERT_FALSE(JSONReader::Read("true", &root, false)); | 500 ASSERT_FALSE(JSONReader::Read("true", &root, false)); |
| 495 ASSERT_FALSE(JSONReader::Read("10", &root, false)); | 501 ASSERT_FALSE(JSONReader::Read("10", &root, false)); |
| 496 ASSERT_FALSE(JSONReader::Read("\"root\"", &root, false)); | 502 ASSERT_FALSE(JSONReader::Read("\"root\"", &root, false)); |
| 497 } | 503 } |
| 498 | |
| OLD | NEW |