#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&) { … }
}
TEST_F(FormatEntryPointTest, FormatStreamed) { … }
TEST_F(FormatEntryPointTest, FormatStreamedWithV) { … }
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
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;
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) { … }
}
ABSL_NAMESPACE_END
}
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) { … }
}
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) { … }