100 #ifndef GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_ 101 #define GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_ 103 #include <functional> 108 #include <type_traits> 115 #include "absl/strings/string_view.h" 116 #include "absl/types/optional.h" 117 #include "absl/types/variant.h" 118 #endif // GTEST_HAS_ABSL 124 namespace internal2 {
139 kConvertibleToStringView,
149 template <
typename T, TypeKind kTypeKind>
155 reinterpret_cast<const void*>(&value)),
165 template <
typename T>
169 std::string pretty_str = value.ShortDebugString();
171 pretty_str =
"\n" + value.DebugString();
173 *os << (
"<" + pretty_str +
">");
177 template <
typename T>
194 template <
typename T>
230 template <
typename Char,
typename CharTraits,
typename T>
232 ::std::basic_ostream<Char, CharTraits>& os,
const T&
x) {
235 : std::is_convertible<
241 const T&, absl::string_view>
::value 242 ? kConvertibleToStringView
258 template <
typename T>
309 template <
typename ToPr
int,
typename OtherOperand>
318 template <
typename ToPr
int,
size_t N,
typename OtherOperand>
329 #define GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(CharType) \ 330 template <typename OtherOperand> \ 331 class FormatForComparison<CharType*, OtherOperand> { \ 333 static ::std::string Format(CharType* value) { \ 334 return ::testing::PrintToString(static_cast<const void*>(value)); \ 343 #undef GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_ 348 #define GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(CharType, OtherStringType) \ 350 class FormatForComparison<CharType*, OtherStringType> { \ 352 static ::std::string Format(CharType* value) { \ 353 return ::testing::PrintToString(value); \ 360 #if GTEST_HAS_STD_WSTRING 365 #undef GTEST_IMPL_FORMAT_C_STRING_AS_STRING_ 375 template <
typename T1,
typename T2>
377 const T1&
value,
const T2& ) {
388 template <
typename T>
391 template <
typename T>
404 template <
typename C>
406 const C& container, ::std::ostream* os) {
407 const size_t kMaxCount = 32;
410 for (
typename C::const_iterator it = container.begin();
411 it != container.end(); ++it, ++
count) {
414 if (count == kMaxCount) {
437 template <
typename T>
439 T*
p, ::std::ostream* os) {
449 template <
typename T>
451 T*
p, ::std::ostream* os) {
458 *os << reinterpret_cast<const void*>(
p);
464 template <
typename T>
466 const T&
value, ::std::ostream* os) {
481 template <
typename T>
504 (
sizeof(IsContainerTest<T>(0)) ==
sizeof(
IsContainer)) &&
522 inline void PrintTo(
char c, ::std::ostream* os) {
526 PrintTo(static_cast<unsigned char>(c), os);
531 *os << (x ?
"true" :
"false");
545 inline void PrintTo(
char* s, ::std::ostream* os) {
546 PrintTo(ImplicitCast_<const char*>(s), os);
551 inline void PrintTo(
const signed char* s, ::std::ostream* os) {
552 PrintTo(ImplicitCast_<const void*>(s), os);
554 inline void PrintTo(
signed char* s, ::std::ostream* os) {
555 PrintTo(ImplicitCast_<const void*>(s), os);
557 inline void PrintTo(
const unsigned char* s, ::std::ostream* os) {
558 PrintTo(ImplicitCast_<const void*>(s), os);
560 inline void PrintTo(
unsigned char* s, ::std::ostream* os) {
561 PrintTo(ImplicitCast_<const void*>(s), os);
569 #if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED) 572 inline void PrintTo(
wchar_t* s, ::std::ostream* os) {
573 PrintTo(ImplicitCast_<const wchar_t*>(s), os);
582 template <
typename T>
585 for (
size_t i = 1;
i !=
count;
i++) {
593 inline void PrintTo(const ::std::string& s, ::std::ostream* os) {
598 #if GTEST_HAS_STD_WSTRING 599 GTEST_API_ void PrintWideStringTo(const ::std::wstring&s, ::std::ostream* os);
600 inline void PrintTo(const ::std::wstring& s, ::std::ostream* os) {
601 PrintWideStringTo(s, os);
603 #endif // GTEST_HAS_STD_WSTRING 607 inline void PrintTo(absl::string_view sp, ::std::ostream* os) {
608 PrintTo(::std::string(sp), os);
610 #endif // GTEST_HAS_ABSL 612 inline void PrintTo(std::nullptr_t, ::std::ostream* os) { *os <<
"(nullptr)"; }
614 template <
typename T>
615 void PrintTo(std::reference_wrapper<T> ref, ::std::ostream* os) {
621 template <
typename T>
625 template <
typename T,
size_t I>
627 ::std::ostream* os) {
628 PrintTupleTo(t, std::integral_constant<size_t, I - 1>(), os);
635 std::get<I - 1>(t), os);
638 template <
typename... Types>
639 void PrintTo(const ::std::tuple<Types...>& t, ::std::ostream* os) {
641 PrintTupleTo(t, std::integral_constant<
size_t,
sizeof...(Types)>(), os);
646 template <
typename T1,
typename T2>
659 template <
typename T>
688 template <
typename T>
691 static void Print(const ::absl::optional<T>&
value, ::std::ostream* os) {
704 template <
typename... T>
707 static void Print(const ::absl::variant<T...>&
value, ::std::ostream* os) {
709 absl::visit(Visitor{os},
value);
715 template <
typename U>
716 void operator()(
const U&
u)
const {
717 *os <<
"'" << GetTypeName<U>() <<
"' with value ";
724 #endif // GTEST_HAS_ABSL 728 template <
typename T>
734 const size_t kThreshold = 18;
735 const size_t kChunkSize = 8;
739 if (len <= kThreshold) {
751 const char* begin,
size_t len, ::std::ostream* os);
755 const wchar_t* begin,
size_t len, ::std::ostream* os);
758 template <
typename T,
size_t N>
763 static void Print(
const T (&a)[N], ::std::ostream* os) {
769 template <
typename T>
779 *os <<
"@" <<
reinterpret_cast<const void*
>(&
value) <<
" ";
792 template <
typename T>
799 template <
typename T>
806 template <
typename T,
size_t N>
816 static void Print(
const char* str, ::std::ostream* os) {
817 if (str ==
nullptr) {
827 static void Print(
char* str, ::std::ostream* os) {
832 #if GTEST_HAS_STD_WSTRING 836 static void Print(
const wchar_t* str, ::std::ostream* os) {
837 if (str ==
nullptr) {
849 static void Print(
wchar_t* str, ::std::ostream* os) {
854 template <
typename T>
863 template <
typename T>
871 typedef ::std::vector< ::std::string>
Strings;
875 template <
typename Tuple>
878 template <
typename Tuple,
size_t I>
880 std::integral_constant<size_t, I>,
884 ::std::stringstream ss;
886 strings->push_back(ss.str());
892 template <
typename Tuple>
904 namespace internal2 {
905 template <
typename T>
907 const T&
value, ::std::ostream* os) {
913 template <
typename T>
915 ::std::stringstream ss;
927 #endif // GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_ static void Print(const T &value,::std::ostream *os)
Definition: gtest-printers.h:795
const char * p
Definition: gmock-matchers_test.cc:3613
void TersePrintPrefixToStrings(const Tuple &t, std::integral_constant< size_t, I >, Strings *strings)
Definition: gtest-printers.h:879
Definition: gtest-printers.h:396
void PrintTupleTo(const T &t, std::integral_constant< size_t, I >,::std::ostream *os)
Definition: gtest-printers.h:626
Definition: gtest-printers.h:142
Definition: gmock-actions.h:59
int * count
Definition: gmock_stress_test.cc:96
void DefaultPrintTo(WrapPrinterType< kPrintOther >, const T &value,::std::ostream *os)
Definition: gtest-printers.h:465
void PrintRawArrayTo(const T a[], size_t count,::std::ostream *os)
Definition: gtest-printers.h:583
static void Print(wchar_t *str,::std::ostream *os)
Definition: gtest-printers.h:849
#define GTEST_INTENTIONAL_CONST_COND_PUSH_()
Definition: gtest-port.h:711
#define GTEST_DISABLE_MSC_WARNINGS_POP_()
Definition: gtest-port.h:314
int IsContainer
Definition: gtest-internal.h:929
static void Print(const T &value,::std::ostream *os)
Definition: gtest-printers.h:802
GTEST_API_ void PrintStringTo(const ::std::string &s,::std::ostream *os)
::std::string PrintToString(const T &value)
Definition: gtest-printers.h:914
ct::core::ControlVector< control_dim > u
static void Print(const T(&value)[N],::std::ostream *os)
Definition: gtest-printers.h:809
void UniversalTersePrint(const T &value,::std::ostream *os)
Definition: gtest-printers.h:855
Definition: gtest-printers.h:793
std::string Print(const T &value)
Definition: googletest-printers-test.cc:233
void DefaultPrintNonContainerTo(const T &value,::std::ostream *os)
Definition: gtest-printers.h:259
::std::vector< ::std::string > Strings
Definition: gtest-printers.h:871
static void Print(const T(&a)[N],::std::ostream *os)
Definition: gtest-printers.h:763
::std::basic_ostream< Char, CharTraits > & operator<<(::std::basic_ostream< Char, CharTraits > &os, const T &x)
Definition: gtest-printers.h:231
#define GTEST_API_
Definition: gtest-port.h:759
static void Print(const char *str,::std::ostream *os)
Definition: gtest-printers.h:816
std::string FormatForComparisonFailureMessage(const T1 &value, const T2 &)
Definition: gtest-printers.h:376
int i
Definition: gmock-matchers_test.cc:711
usr bin c fPIC pthread std
Definition: link.txt:1
const size_t kProtobufOneLinerMaxLength
Definition: gtest-printers.h:163
#define GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(CharType, OtherStringType)
Definition: gtest-printers.h:348
TypeKind
Definition: gtest-printers.h:134
#define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings)
Definition: gtest-port.h:313
GTEST_API_ void UniversalPrintArray(const wchar_t *begin, size_t len,::std::ostream *os)
DefaultPrinterType
Definition: gtest-printers.h:394
Definition: gtest-printers.h:395
void UniversalPrint(const T &value,::std::ostream *os)
Definition: gtest-printers.h:864
long long BiggestInt
Definition: gtest-port.h:1964
Definition: gtest-printers.h:400
Definition: gtest-printers.h:389
GTEST_API_ void PrintBytesInObjectTo(const unsigned char *obj_bytes, size_t count,::std::ostream *os)
Definition: gtest-printers.h:254
Definition: gtest-printers.h:398
void PrintTo(const T &value,::std::ostream *os)
Definition: gtest-printers.h:482
int value
Definition: gmock-matchers_test.cc:657
#define GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(CharType)
Definition: gtest-printers.h:329
Definition: gtest-printers.h:136
Strings UniversalTersePrintTupleFieldsToStrings(const Tuple &value)
Definition: gtest-printers.h:893
int x
Definition: gmock-matchers_test.cc:3610
type
Definition: upload.py:443
static void Print(char *str,::std::ostream *os)
Definition: gtest-printers.h:827
const
Definition: upload.py:398
void PrintTo(const ::std::pair< T1, T2 > &value,::std::ostream *os)
Definition: gtest-printers.h:647
Definition: gtest-internal.h:992
Definition: gtest-printers.h:124
Definition: gtest-printers.h:397
#define GTEST_INTENTIONAL_CONST_COND_POP_()
Definition: gtest-port.h:713
Definition: gtest-printers.h:135