chromium/base/json/json_reader_unittest.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40284755): Remove this and spanify to fix the errors.
#pragma allow_unsafe_buffers
#endif

#include "base/json/json_reader.h"

#include <stddef.h>

#include <cmath>
#include <string_view>
#include <utility>

#include "base/base_paths.h"
#include "base/features.h"
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/path_service.h"
#include "base/rust_buildflags.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/gmock_expected_support.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/values.h"
#include "build/build_config.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace {

// MSan will do a better job detecting over-read errors if the input is not
// nul-terminated on the heap. This will copy |input| to a new buffer owned by
// |owner|, returning a std::string_view to |owner|.
std::string_view MakeNotNullTerminatedInput(const char* input,
                                            std::unique_ptr<char[]>* owner) {}

}  // namespace

namespace base {

class JSONReaderTest : public testing::TestWithParam<bool> {};

TEST_P(JSONReaderTest, Whitespace) {}

TEST_P(JSONReaderTest, InvalidString) {}

TEST_P(JSONReaderTest, SimpleBool) {}

TEST_P(JSONReaderTest, EmbeddedComments) {}

TEST_P(JSONReaderTest, Ints) {}

TEST_P(JSONReaderTest, NonDecimalNumbers) {}

TEST_P(JSONReaderTest, NumberZero) {}

TEST_P(JSONReaderTest, LargeIntPromotion) {}

TEST_P(JSONReaderTest, LargerIntIsLossy) {}

TEST_P(JSONReaderTest, Doubles) {}

TEST_P(JSONReaderTest, FractionalNumbers) {}

TEST_P(JSONReaderTest, ExponentialNumbers) {}

TEST_P(JSONReaderTest, InvalidInfNAN) {}

TEST_P(JSONReaderTest, InvalidNumbers) {}

TEST_P(JSONReaderTest, Zeroes) {}

TEST_P(JSONReaderTest, SimpleString) {}

TEST_P(JSONReaderTest, EmptyString) {}

TEST_P(JSONReaderTest, BasicStringEscapes) {}

TEST_P(JSONReaderTest, UnicodeEscapes) {}

TEST_P(JSONReaderTest, InvalidStrings) {}

TEST_P(JSONReaderTest, BasicArray) {}

TEST_P(JSONReaderTest, EmptyArray) {}

TEST_P(JSONReaderTest, CompleteArray) {}

TEST_P(JSONReaderTest, NestedArrays) {}

TEST_P(JSONReaderTest, InvalidArrays) {}

TEST_P(JSONReaderTest, ArrayTrailingComma) {}

TEST_P(JSONReaderTest, ArrayTrailingCommaNoEmptyElements) {}

TEST_P(JSONReaderTest, EmptyDictionary) {}

TEST_P(JSONReaderTest, CompleteDictionary) {}

TEST_P(JSONReaderTest, NestedDictionaries) {}

TEST_P(JSONReaderTest, DictionaryKeysWithPeriods) {}

TEST_P(JSONReaderTest, DuplicateKeys) {}

TEST_P(JSONReaderTest, InvalidDictionaries) {}

TEST_P(JSONReaderTest, StackOverflow) {}

TEST_P(JSONReaderTest, UTF8Input) {}

TEST_P(JSONReaderTest, InvalidUTF8Input) {}

TEST_P(JSONReaderTest, UTF16Escapes) {}

TEST_P(JSONReaderTest, InvalidUTF16Escapes) {}

TEST_P(JSONReaderTest, LiteralRoots) {}

TEST_P(JSONReaderTest, ReadFromFile) {}

// Tests that the root of a JSON object can be deleted safely while its
// children outlive it.
TEST_P(JSONReaderTest, StringOptimizations) {}

// 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_P(JSONReaderTest, InvalidSanity) {}

TEST_P(JSONReaderTest, IllegalTrailingNull) {}

TEST_P(JSONReaderTest, ASCIIControlCodes) {}

TEST_P(JSONReaderTest, MaxNesting) {}

TEST_P(JSONReaderTest, Decode4ByteUtf8Char) {}

TEST_P(JSONReaderTest, DecodeUnicodeNonCharacter) {}

TEST_P(JSONReaderTest, DecodeNegativeEscapeSequence) {}

// Verifies invalid code points are replaced.
TEST_P(JSONReaderTest, ReplaceInvalidCharacters) {}

TEST_P(JSONReaderTest, ReplaceInvalidUTF16EscapeSequence) {}

TEST_P(JSONReaderTest, ParseNumberErrors) {}

TEST_P(JSONReaderTest, UnterminatedInputs) {}

TEST_P(JSONReaderTest, LineColumnCounting) {}

TEST_P(JSONReaderTest, ChromiumExtensions) {}

// For every control character, place it unescaped in a string and ensure that:
// a) It doesn't parse with JSON_PARSE_RFC
// b) It doesn't parse with JSON_PARSE_CHROMIUM_EXTENSIONS
// c) It does parse with JSON_ALLOW_CONTROL_CHARS
TEST_P(JSONReaderTest, UnescapedControls) {}

TEST_P(JSONReaderTest, UsingRust) {}

INSTANTIATE_TEST_SUITE_P();

}  // namespace base