src/base/json/json_reader_unittest.cc
TEST(JSONReaderTest, InvalidSanity) {
  const char* const kInvalidJson[] = {
      "/* test *", "{\"foo\"", "{\"foo\":", "  [", "\"\\u123g\"", "{\n\"eh:\n}",
  };

  for (size_t i = 0; i < base::size(kInvalidJson); ++i) {
    LOG(INFO) << "Sanity test " << i << ": <" << kInvalidJson[i] << ">";
    JSONReader::ValueWithError root =
        JSONReader::ReadAndReturnValueWithError(kInvalidJson[i]);
    EXPECT_FALSE(root.value);
    EXPECT_NE("", root.error_message);
  }
}
// A smattering of invalid JSON designed to test specific portions of the
// parser implementation against buffer overflow. Best run with DCHECKs so
// that the one in NextChar fires.
A smattering of invalid JSON designed to test specific portions of the
parser implementation against buffer overflow. Best run with DCHECKs so
that the one in NextChar fires.
A smattering of invalid JSON designed to test specific portions of the parser implementation against buffer overflow . Best run with DCHECKs so that the one in NextChar fires .
TEST(JSONReaderTest, InvalidSanity) {
  const char* const kInvalidJson[] = {
      "/* test *", "{\"foo\"", "{\"foo\":", "  [", "\"\\u123g\"", "{\n\"eh:\n}",
  };
  for (size_t i = 0; i < base::size(kInvalidJson); ++i) {
    LOG(INFO) << "Sanity test " << i << ": <" << kInvalidJson[i] << ">";
    JSONReader::ValueWithError root =
        JSONReader::ReadAndReturnValueWithError(kInvalidJson[i]);
    EXPECT_FALSE(root.value);
    EXPECT_NE("", root.error_message);
  }
}
TEST ( JSONReaderTest , InvalidSanity ) { const char * const kInvalidJson [ ] = { " " , " \" \" " , " \" \" " , " " , " \" \\ \" " , " \n \" \n " , } ; for ( size_t i = 0 ; i < base :: size ( kInvalidJson ) ; ++ i ) { LOG ( INFO ) << " " << i << " " << kInvalidJson [ i ] << " " ; JSONReader :: ValueWithError root = JSONReader :: ReadAndReturnValueWithError ( kInvalidJson [ i ] ) ; EXPECT_FALSE ( root . value ) ; EXPECT_NE ( " " , root . error_message ) ; } }
A smattering of invalid JSON designed to test specific portions of the
parser implementation against buffer overflow.
A smattering of invalid JSON designed to test specific portions of the parser implementation against buffer overflow .