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/json_reader.h" |
7 #include "base/scoped_ptr.h" | 7 #include "base/scoped_ptr.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 | 10 |
| 11 namespace base { |
| 12 |
11 TEST(JSONReaderTest, Reading) { | 13 TEST(JSONReaderTest, Reading) { |
12 // some whitespace checking | 14 // some whitespace checking |
13 scoped_ptr<Value> root; | 15 scoped_ptr<Value> root; |
14 root.reset(JSONReader().JsonToValue(" null ", false, false)); | 16 root.reset(JSONReader().JsonToValue(" null ", false, false)); |
15 ASSERT_TRUE(root.get()); | 17 ASSERT_TRUE(root.get()); |
16 ASSERT_TRUE(root->IsType(Value::TYPE_NULL)); | 18 ASSERT_TRUE(root->IsType(Value::TYPE_NULL)); |
17 | 19 |
18 // Invalid JSON string | 20 // Invalid JSON string |
19 root.reset(JSONReader().JsonToValue("nu", false, false)); | 21 root.reset(JSONReader().JsonToValue("nu", false, false)); |
20 ASSERT_FALSE(root.get()); | 22 ASSERT_FALSE(root.get()); |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 EXPECT_EQ(JSONReader::FormatErrorMessage(1, 7, JSONReader::kInvalidEscape), | 509 EXPECT_EQ(JSONReader::FormatErrorMessage(1, 7, JSONReader::kInvalidEscape), |
508 error_message); | 510 error_message); |
509 | 511 |
510 root.reset(JSONReader::ReadAndReturnError("[\"xxx\\q\"]", false, | 512 root.reset(JSONReader::ReadAndReturnError("[\"xxx\\q\"]", false, |
511 &error_message)); | 513 &error_message)); |
512 EXPECT_FALSE(root.get()); | 514 EXPECT_FALSE(root.get()); |
513 EXPECT_EQ(JSONReader::FormatErrorMessage(1, 7, JSONReader::kInvalidEscape), | 515 EXPECT_EQ(JSONReader::FormatErrorMessage(1, 7, JSONReader::kInvalidEscape), |
514 error_message); | 516 error_message); |
515 | 517 |
516 } | 518 } |
| 519 |
| 520 } // namespace base |
OLD | NEW |