| Index: base/json/json_parser_unittest.cc
|
| diff --git a/base/json/json_parser_unittest.cc b/base/json/json_parser_unittest.cc
|
| index eacd1024993ce5d1924fde1273bbba317345434d..ab6875b4d282c20f0096bab327a1588d7b4a8bf0 100644
|
| --- a/base/json/json_parser_unittest.cc
|
| +++ b/base/json/json_parser_unittest.cc
|
| @@ -17,8 +17,9 @@ namespace internal {
|
|
|
| class JSONParserTest : public testing::Test {
|
| public:
|
| - JSONParser* NewTestParser(const std::string& input) {
|
| - JSONParser* parser = new JSONParser(JSON_PARSE_RFC);
|
| + JSONParser* NewTestParser(const std::string& input,
|
| + int options = JSON_PARSE_RFC) {
|
| + JSONParser* parser = new JSONParser(options);
|
| parser->start_pos_ = input.data();
|
| parser->pos_ = parser->start_pos_;
|
| parser->end_pos_ = parser->start_pos_ + input.length();
|
| @@ -328,5 +329,18 @@ TEST_F(JSONParserTest, DecodeNegativeEscapeSequence) {
|
| EXPECT_FALSE(JSONReader::Read("[\"\\u-00A\"]"));
|
| }
|
|
|
| +// Verifies invalid utf-8 characters are read back in as is.
|
| +TEST_F(JSONParserTest, KeepInvalidCharacters) {
|
| + const std::string bogus_char = "";
|
| + const std::string quoted_bogus_char = "\"" + bogus_char + "\"";
|
| + std::unique_ptr<JSONParser> parser(
|
| + NewTestParser(quoted_bogus_char, JSON_ALLOW_NON_UTF_STRINGS));
|
| + std::unique_ptr<Value> value(parser->ConsumeString());
|
| + ASSERT_TRUE(value.get());
|
| + std::string str;
|
| + EXPECT_TRUE(value->GetAsString(&str));
|
| + EXPECT_EQ(bogus_char, str);
|
| +}
|
| +
|
| } // namespace internal
|
| } // namespace base
|
|
|