chromium/base/test/values_test_util.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.

#include "base/test/values_test_util.h"

#include <optional>
#include <ostream>
#include <string_view>
#include <utility>

#include "base/files/file_util.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/memory/ptr_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/types/optional_util.h"
#include "base/values.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace base {

void ExpectDictBooleanValue(bool expected_value,
                            const Value::Dict& dict,
                            std::string_view path) {}

void ExpectDictIntegerValue(int expected_value,
                            const Value::Dict& dict,
                            std::string_view path) {}

void ExpectDictStringValue(std::string_view expected_value,
                           const Value::Dict& dict,
                           std::string_view path) {}

void ExpectDictValue(const Value::Dict& expected_value,
                     const Value::Dict& dict,
                     std::string_view path) {}

void ExpectDictValue(const Value& expected_value,
                     const Value::Dict& dict,
                     std::string_view path) {}

void ExpectStringValue(const std::string& expected_str, const Value& actual) {}

namespace test {

namespace {

std::string FormatAsJSON(ValueView value) {}

class DictionaryHasValueMatcher
    : public testing::MatcherInterface<const base::Value::Dict&> {};

class DictionaryHasValuesMatcher
    : public testing::MatcherInterface<const base::Value::Dict&> {};

// Attempts to parse `json` as JSON. Returns resulting Value on success, has an
// EXPECT failure and returns nullopt on failure. If `expected_type` is
// provided, treats `json` parsing as a Value of a different type as a failure.
//
std::optional<Value> ParseJsonHelper(std::string_view json,
                                     std::optional<Value::Type> expected_type) {}

}  // namespace

testing::Matcher<const base::Value::Dict&> DictionaryHasValue(
    const std::string& key,
    const base::Value& expected_value) {}

testing::Matcher<const base::Value::Dict&> DictionaryHasValues(
    const base::Value::Dict& template_value) {}

IsJsonMatcher::IsJsonMatcher(std::string_view json)
    :{}

IsJsonMatcher::IsJsonMatcher(const base::Value& value)
    :{}

IsJsonMatcher::IsJsonMatcher(const base::Value::Dict& value)
    :{}

IsJsonMatcher::IsJsonMatcher(const base::Value::List& value)
    :{}

IsJsonMatcher::IsJsonMatcher(const IsJsonMatcher& other)
    :{}

IsJsonMatcher& IsJsonMatcher::operator=(const IsJsonMatcher& other) {}

IsJsonMatcher::~IsJsonMatcher() = default;

bool IsJsonMatcher::MatchAndExplain(
    std::string_view json,
    testing::MatchResultListener* listener) const {}

bool IsJsonMatcher::MatchAndExplain(
    const base::Value& value,
    testing::MatchResultListener* /* listener */) const {}

bool IsJsonMatcher::MatchAndExplain(
    const base::Value::Dict& dict,
    testing::MatchResultListener* /* listener */) const {}

bool IsJsonMatcher::MatchAndExplain(
    const base::Value::List& list,
    testing::MatchResultListener* /* listener */) const {}

void IsJsonMatcher::DescribeTo(std::ostream* os) const {}

void IsJsonMatcher::DescribeNegationTo(std::ostream* os) const {}

Value ParseJson(std::string_view json) {}

Value::Dict ParseJsonDict(std::string_view json) {}

Value::List ParseJsonList(std::string_view json) {}

Value::Dict ParseJsonDictFromFile(const FilePath& json_file_path) {}

expected<void, WriteJsonError> WriteJsonFile(const FilePath& json_file_path,
                                             ValueView root) {}

}  // namespace test
}  // namespace base