| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/json/json_parser.h" | 5 #include "base/json/json_parser.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 | 117 |
| 118 // Literal |null|. | 118 // Literal |null|. |
| 119 input = "null,|"; | 119 input = "null,|"; |
| 120 parser.reset(NewTestParser(input)); | 120 parser.reset(NewTestParser(input)); |
| 121 value = parser->ConsumeLiteral(); | 121 value = parser->ConsumeLiteral(); |
| 122 EXPECT_EQ('l', *parser->pos_); | 122 EXPECT_EQ('l', *parser->pos_); |
| 123 | 123 |
| 124 TestLastThree(parser.get()); | 124 TestLastThree(parser.get()); |
| 125 | 125 |
| 126 ASSERT_TRUE(value.get()); | 126 ASSERT_TRUE(value.get()); |
| 127 EXPECT_TRUE(value->IsType(Value::TYPE_NULL)); | 127 EXPECT_TRUE(value->IsType(Value::Type::NONE)); |
| 128 } | 128 } |
| 129 | 129 |
| 130 TEST_F(JSONParserTest, ConsumeNumbers) { | 130 TEST_F(JSONParserTest, ConsumeNumbers) { |
| 131 // Integer. | 131 // Integer. |
| 132 std::string input("1234,|"); | 132 std::string input("1234,|"); |
| 133 std::unique_ptr<JSONParser> parser(NewTestParser(input)); | 133 std::unique_ptr<JSONParser> parser(NewTestParser(input)); |
| 134 std::unique_ptr<Value> value(parser->ConsumeNumber()); | 134 std::unique_ptr<Value> value(parser->ConsumeNumber()); |
| 135 EXPECT_EQ('4', *parser->pos_); | 135 EXPECT_EQ('4', *parser->pos_); |
| 136 | 136 |
| 137 TestLastThree(parser.get()); | 137 TestLastThree(parser.get()); |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 NewTestParser(quoted_bogus_char, JSON_REPLACE_INVALID_CHARACTERS)); | 337 NewTestParser(quoted_bogus_char, JSON_REPLACE_INVALID_CHARACTERS)); |
| 338 std::unique_ptr<Value> value(parser->ConsumeString()); | 338 std::unique_ptr<Value> value(parser->ConsumeString()); |
| 339 ASSERT_TRUE(value.get()); | 339 ASSERT_TRUE(value.get()); |
| 340 std::string str; | 340 std::string str; |
| 341 EXPECT_TRUE(value->GetAsString(&str)); | 341 EXPECT_TRUE(value->GetAsString(&str)); |
| 342 EXPECT_EQ(kUnicodeReplacementString, str); | 342 EXPECT_EQ(kUnicodeReplacementString, str); |
| 343 } | 343 } |
| 344 | 344 |
| 345 } // namespace internal | 345 } // namespace internal |
| 346 } // namespace base | 346 } // namespace base |
| OLD | NEW |