chromium/third_party/abseil-cpp/absl/strings/str_format_test.cc

// Copyright 2020 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/strings/str_format.h"

#include <cerrno>
#include <cstdarg>
#include <cstdint>
#include <cstdio>
#include <ostream>
#include <sstream>
#include <string>
#include <type_traits>

#include "gtest/gtest.h"
#include "absl/base/config.h"
#include "absl/base/macros.h"
#include "absl/strings/cord.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h"
#include "absl/types/span.h"

namespace absl {
ABSL_NAMESPACE_BEGIN
namespace {
FormatArgImpl;

FormatEntryPointTest;

TEST_F(FormatEntryPointTest, Format) {}

TEST_F(FormatEntryPointTest, FormatWithV) {}

TEST_F(FormatEntryPointTest, UntypedFormat) {}

TEST_F(FormatEntryPointTest, StringFormat) {}

TEST_F(FormatEntryPointTest, StringFormatV) {}

TEST_F(FormatEntryPointTest, AppendFormat) {}

TEST_F(FormatEntryPointTest, AppendFormatWithV) {}

TEST_F(FormatEntryPointTest, AppendFormatFail) {}

TEST_F(FormatEntryPointTest, AppendFormatFailWithV) {}

TEST_F(FormatEntryPointTest, ManyArgs) {}

TEST_F(FormatEntryPointTest, Preparsed) {}

TEST_F(FormatEntryPointTest, PreparsedWithV) {}

TEST_F(FormatEntryPointTest, FormatCountCapture) {}

TEST_F(FormatEntryPointTest, FormatCountCaptureWithV) {}

TEST_F(FormatEntryPointTest, FormatCountCaptureWrongType) {}

TEST_F(FormatEntryPointTest, FormatCountCaptureWrongTypeWithV) {}

TEST_F(FormatEntryPointTest, FormatCountCaptureMultiple) {}

TEST_F(FormatEntryPointTest, FormatCountCaptureExample) {}

TEST_F(FormatEntryPointTest, FormatCountCaptureExampleWithV) {}

TEST_F(FormatEntryPointTest, Stream) {}

TEST_F(FormatEntryPointTest, StreamWithV) {}

TEST_F(FormatEntryPointTest, StreamOk) {}

TEST_F(FormatEntryPointTest, StreamOkWithV) {}

TEST_F(FormatEntryPointTest, StreamFail) {}

TEST_F(FormatEntryPointTest, StreamFailWithV) {}

std::string WithSnprintf(const char* fmt, ...) {}

TEST_F(FormatEntryPointTest, FloatPrecisionArg) {}
namespace streamed_test {
struct X {};
std::ostream& operator<<(std::ostream& os, const X&) {}
}  // streamed_test

TEST_F(FormatEntryPointTest, FormatStreamed) {}

TEST_F(FormatEntryPointTest, FormatStreamedWithV) {}

// Helper class that creates a temporary file and exposes a FILE* to it.
// It will close the file on destruction.
class TempFile {};

TEST_F(FormatEntryPointTest, FPrintF) {}

TEST_F(FormatEntryPointTest, FPrintFWithV) {}

TEST_F(FormatEntryPointTest, FPrintFError) {}

#ifdef __GLIBC__
TEST_F(FormatEntryPointTest, FprintfTooLarge) {}

TEST_F(FormatEntryPointTest, PrintF) {}

TEST_F(FormatEntryPointTest, PrintFWithV) {}
#endif  // __GLIBC__

TEST_F(FormatEntryPointTest, SNPrintF) {}

TEST_F(FormatEntryPointTest, SNPrintFWithV) {}

TEST(StrFormat, BehavesAsDocumented) {}

ExtendedParsedFormat;
ParsedFormatBase;

struct SummarizeConsumer {};

std::string SummarizeParsedFormat(const ParsedFormatBase& pc) {}

ParsedFormatTest;

TEST_F(ParsedFormatTest, SimpleChecked) {}

TEST_F(ParsedFormatTest, SimpleCheckedWithV) {}

TEST_F(ParsedFormatTest, SimpleUncheckedCorrect) {}

TEST_F(ParsedFormatTest, SimpleUncheckedCorrectWithV) {}

TEST_F(ParsedFormatTest, SimpleUncheckedIgnoredArgs) {}

TEST_F(ParsedFormatTest, SimpleUncheckedIgnoredArgsWithV) {}

TEST_F(ParsedFormatTest, SimpleUncheckedUnsupported) {}

TEST_F(ParsedFormatTest, SimpleUncheckedIncorrect) {}

TEST_F(ParsedFormatTest, SimpleUncheckedIncorrectWithV) {}

#if defined(__cpp_nontype_template_parameter_auto)

template <auto T>
std::true_type IsValidParsedFormatArgTest(ParsedFormat<T>*);

template <auto T>
std::false_type IsValidParsedFormatArgTest(...);

IsValidParsedFormatArg;

TEST_F(ParsedFormatTest, OnlyValidTypesAllowed) {}

TEST_F(ParsedFormatTest, ExtendedTyping) {}

TEST_F(ParsedFormatTest, ExtendedTypingWithV) {}
#endif

TEST_F(ParsedFormatTest, UncheckedCorrect) {}

TEST_F(ParsedFormatTest, UncheckedCorrectWithV) {}

TEST_F(ParsedFormatTest, UncheckedIgnoredArgs) {}

TEST_F(ParsedFormatTest, UncheckedIgnoredArgsWithV) {}

TEST_F(ParsedFormatTest, UncheckedMultipleTypes) {}

TEST_F(ParsedFormatTest, UncheckedIncorrect) {}

TEST_F(ParsedFormatTest, UncheckedIncorrectWithV) {}

TEST_F(ParsedFormatTest, RegressionMixPositional) {}

TEST_F(ParsedFormatTest, DisallowModifiersWithV) {}

FormatWrapperTest;

// Plain wrapper for StrFormat.
template <typename... Args>
std::string WrappedFormat(const absl::FormatSpec<Args...>& format,
                          const Args&... args) {}

TEST_F(FormatWrapperTest, ConstexprStringFormat) {}

TEST_F(FormatWrapperTest, ConstexprStringFormatWithV) {}

TEST_F(FormatWrapperTest, ParsedFormat) {}

TEST_F(FormatWrapperTest, ParsedFormatWithV) {}

}  // namespace
ABSL_NAMESPACE_END
}  // namespace absl

namespace {
FormatExtensionTest;

struct Point {};

TEST_F(FormatExtensionTest, AbslFormatConvertExample) {}

struct PointStringify {};

TEST_F(FormatExtensionTest, AbslStringifyExample) {}

struct PointStringifyUsingFormat {};

TEST_F(FormatExtensionTest, AbslStringifyExampleUsingFormat) {}

enum class EnumClassWithStringify {};

template <typename Sink>
void AbslStringify(Sink& sink, EnumClassWithStringify e) {}

enum EnumWithStringify {};

template <typename Sink>
void AbslStringify(Sink& sink, EnumWithStringify e) {}

TEST_F(FormatExtensionTest, AbslStringifyWithEnumWithV) {}

TEST_F(FormatExtensionTest, AbslStringifyEnumWithD) {}

enum class EnumWithLargerValue {};

template <typename Sink>
void AbslStringify(Sink& sink, EnumWithLargerValue e) {}

TEST_F(FormatExtensionTest, AbslStringifyEnumOtherSpecifiers) {}

}  // namespace

// Some codegen thunks that we can use to easily dump the generated assembly for
// different StrFormat calls.

std::string CodegenAbslStrFormatInt(int i) {}

std::string CodegenAbslStrFormatIntStringInt64(int i, const std::string& s,
                                               int64_t i64) {}

void CodegenAbslStrAppendFormatInt(std::string* out, int i) {}

void CodegenAbslStrAppendFormatIntStringInt64(std::string* out, int i,
                                              const std::string& s,
                                              int64_t i64) {}