chromium/third_party/abseil-cpp/absl/log/internal/test_matchers.cc

//
// Copyright 2022 The Abseil Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "absl/log/internal/test_matchers.h"

#include <ostream>
#include <sstream>
#include <string>
#include <type_traits>
#include <utility>

#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "absl/base/attributes.h"
#include "absl/base/config.h"
#include "absl/log/internal/test_helpers.h"
#include "absl/log/log_entry.h"
#include "absl/strings/string_view.h"
#include "absl/time/clock.h"
#include "absl/time/time.h"

namespace absl {
ABSL_NAMESPACE_BEGIN
namespace log_internal {
namespace {
_;
AllOf;
Ge;
HasSubstr;
MakeMatcher;
Matcher;
MatcherInterface;
MatchResultListener;
Not;
Property;
ResultOf;
Truly;

class AsStringImpl final
    : public MatcherInterface<absl::string_view> {};

class MatchesOstreamImpl final
    : public MatcherInterface<absl::string_view> {};
}  // namespace

Matcher<absl::string_view> AsString(
    const Matcher<const std::string&>& str_matcher) {}

Matcher<const absl::LogEntry&> SourceFilename(
    const Matcher<absl::string_view>& source_filename) {}

Matcher<const absl::LogEntry&> SourceBasename(
    const Matcher<absl::string_view>& source_basename) {}

Matcher<const absl::LogEntry&> SourceLine(
    const Matcher<int>& source_line) {}

Matcher<const absl::LogEntry&> Prefix(
    const Matcher<bool>& prefix) {}

Matcher<const absl::LogEntry&> LogSeverity(
    const Matcher<absl::LogSeverity>& log_severity) {}

Matcher<const absl::LogEntry&> Timestamp(
    const Matcher<absl::Time>& timestamp) {}

Matcher<absl::Time> InMatchWindow() {}

Matcher<const absl::LogEntry&> ThreadID(
    const Matcher<absl::LogEntry::tid_t>& tid) {}

Matcher<const absl::LogEntry&> TextMessageWithPrefixAndNewline(
    const Matcher<absl::string_view>&
        text_message_with_prefix_and_newline) {}

Matcher<const absl::LogEntry&> TextMessageWithPrefix(
    const Matcher<absl::string_view>& text_message_with_prefix) {}

Matcher<const absl::LogEntry&> TextMessage(
    const Matcher<absl::string_view>& text_message) {}

Matcher<const absl::LogEntry&> TextPrefix(
    const Matcher<absl::string_view>& text_prefix) {}
Matcher<const absl::LogEntry&> RawEncodedMessage(
    const Matcher<absl::string_view>& raw_encoded_message) {}

Matcher<const absl::LogEntry&> Verbosity(
    const Matcher<int>& verbosity) {}

Matcher<const absl::LogEntry&> Stacktrace(
    const Matcher<absl::string_view>& stacktrace) {}

Matcher<absl::string_view> MatchesOstream(
    const std::ostringstream& stream) {}

// We need to validate what is and isn't logged as the process dies due to
// `FATAL`, `QFATAL`, `CHECK`, etc., but assertions inside a death test
// subprocess don't directly affect the pass/fail status of the parent process.
// Instead, we use the mock actions `DeathTestExpectedLogging` and
// `DeathTestUnexpectedLogging` to write specific phrases to `stderr` that we
// can validate in the parent process using this matcher.
Matcher<const std::string&> DeathTestValidateExpectations() {}

}  // namespace log_internal
ABSL_NAMESPACE_END
}  // namespace absl