95 #ifndef GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_ 96 #define GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_ 106 #if GTEST_HAS_STD_TUPLE_ 114 namespace internal2 {
135 template <
typename T, TypeKind kTypeKind>
150 template <
typename T>
156 short_str.length() <= kProtobufOneLinerMaxLength ?
157 short_str : (
"\n" + value.DebugString());
158 *os << (
"<" + pretty_str +
">");
162 template <
typename T>
202 template <
typename Char,
typename CharTraits,
typename T>
204 ::std::basic_ostream<Char, CharTraits>& os,
const T& x) {
221 template <
typename T>
272 template <
typename ToPr
int,
typename OtherOperand>
281 template <
typename ToPr
int,
size_t N,
typename OtherOperand>
292 #define GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(CharType) \ 293 template <typename OtherOperand> \ 294 class FormatForComparison<CharType*, OtherOperand> { \ 296 static ::std::string Format(CharType* value) { \ 297 return ::testing::PrintToString(static_cast<const void*>(value)); \ 306 #undef GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_ 311 #define GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(CharType, OtherStringType) \ 313 class FormatForComparison<CharType*, OtherStringType> { \ 315 static ::std::string Format(CharType* value) { \ 316 return ::testing::PrintToString(value); \ 323 #if GTEST_HAS_GLOBAL_STRING 328 #if GTEST_HAS_GLOBAL_WSTRING 333 #if GTEST_HAS_STD_WSTRING 338 #undef GTEST_IMPL_FORMAT_C_STRING_AS_STRING_ 348 template <
typename T1,
typename T2>
350 const T1& value,
const T2& ) {
361 template <
typename T>
364 template <
typename T>
369 template <
typename C>
372 const C& container, ::std::ostream* os) {
373 const size_t kMaxCount = 32;
376 for (
typename C::const_iterator it = container.begin();
377 it != container.end(); ++it, ++
count) {
380 if (count == kMaxCount) {
403 template <
typename T>
406 T* p, ::std::ostream* os) {
427 *os << reinterpret_cast<const void*>(
435 template <
typename T>
438 const T& value, ::std::ostream* os) {
453 template <
typename T>
454 void PrintTo(
const T& value, ::std::ostream* os) {
487 inline void PrintTo(
char c, ::std::ostream* os) {
491 PrintTo(static_cast<unsigned char>(c), os);
495 inline void PrintTo(
bool x, ::std::ostream* os) {
496 *os << (x ?
"true" :
"false");
510 inline void PrintTo(
char* s, ::std::ostream* os) {
511 PrintTo(ImplicitCast_<const char*>(s), os);
516 inline void PrintTo(
const signed char* s, ::std::ostream* os) {
517 PrintTo(ImplicitCast_<const void*>(s), os);
519 inline void PrintTo(
signed char* s, ::std::ostream* os) {
520 PrintTo(ImplicitCast_<const void*>(s), os);
522 inline void PrintTo(
const unsigned char* s, ::std::ostream* os) {
523 PrintTo(ImplicitCast_<const void*>(s), os);
525 inline void PrintTo(
unsigned char* s, ::std::ostream* os) {
526 PrintTo(ImplicitCast_<const void*>(s), os);
534 #if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED) 537 inline void PrintTo(
wchar_t* s, ::std::ostream* os) {
538 PrintTo(ImplicitCast_<const wchar_t*>(s), os);
547 template <
typename T>
550 for (
size_t i = 1; i !=
count; i++) {
557 #if GTEST_HAS_GLOBAL_STRING 562 #endif // GTEST_HAS_GLOBAL_STRING 570 #if GTEST_HAS_GLOBAL_WSTRING 573 PrintWideStringTo(s, os);
575 #endif // GTEST_HAS_GLOBAL_WSTRING 577 #if GTEST_HAS_STD_WSTRING 580 PrintWideStringTo(s, os);
582 #endif // GTEST_HAS_STD_WSTRING 584 #if GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_ 587 template <
typename T>
588 void PrintTupleTo(
const T& t, ::std::ostream* os);
589 #endif // GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_ 591 #if GTEST_HAS_TR1_TUPLE 600 inline void PrintTo(const ::std::tr1::tuple<>& t, ::std::ostream* os) {
604 template <
typename T1>
605 void PrintTo(const ::std::tr1::tuple<T1>& t, ::std::ostream* os) {
609 template <
typename T1,
typename T2>
610 void PrintTo(const ::std::tr1::tuple<T1, T2>& t, ::std::ostream* os) {
614 template <
typename T1,
typename T2,
typename T3>
615 void PrintTo(const ::std::tr1::tuple<T1, T2, T3>& t, ::std::ostream* os) {
619 template <
typename T1,
typename T2,
typename T3,
typename T4>
620 void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4>& t, ::std::ostream* os) {
624 template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
625 void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5>& t,
626 ::std::ostream* os) {
630 template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
632 void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6>& t,
633 ::std::ostream* os) {
637 template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
638 typename T6,
typename T7>
639 void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7>& t,
640 ::std::ostream* os) {
644 template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
645 typename T6,
typename T7,
typename T8>
646 void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8>& t,
647 ::std::ostream* os) {
651 template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
652 typename T6,
typename T7,
typename T8,
typename T9>
653 void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9>& t,
654 ::std::ostream* os) {
658 template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
659 typename T6,
typename T7,
typename T8,
typename T9,
typename T10>
661 const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>& t,
662 ::std::ostream* os) {
665 #endif // GTEST_HAS_TR1_TUPLE 667 #if GTEST_HAS_STD_TUPLE_ 668 template <
typename... Types>
669 void PrintTo(const ::std::tuple<Types...>& t, ::std::ostream* os) {
672 #endif // GTEST_HAS_STD_TUPLE_ 675 template <
typename T1,
typename T2>
676 void PrintTo(const ::std::pair<T1, T2>& value, ::std::ostream* os) {
688 template <
typename T>
715 template <
typename T>
721 const size_t kThreshold = 18;
722 const size_t kChunkSize = 8;
727 if (len <= kThreshold) {
739 const char* begin,
size_t len, ::std::ostream* os);
743 const wchar_t* begin,
size_t len, ::std::ostream* os);
746 template <
typename T,
size_t N>
751 static void Print(
const T (&a)[N], ::std::ostream* os) {
757 template <
typename T>
767 *os <<
"@" <<
reinterpret_cast<const void*
>(&value) <<
" ";
780 template <
typename T>
783 static void Print(
const T& value, ::std::ostream* os) {
787 template <
typename T>
790 static void Print(
const T& value, ::std::ostream* os) {
794 template <
typename T,
size_t N>
797 static void Print(
const T (&value)[N], ::std::ostream* os) {
804 static void Print(
const char* str, ::std::ostream* os) {
815 static void Print(
char* str, ::std::ostream* os) {
820 #if GTEST_HAS_STD_WSTRING 824 static void Print(
const wchar_t* str, ::std::ostream* os) {
837 static void Print(
wchar_t* str, ::std::ostream* os) {
842 template <
typename T>
851 template <
typename T>
868 template <
typename TupleT>
871 #if GTEST_HAS_TR1_TUPLE 872 template <
typename TupleT>
874 typedef TupleT Tuple;
883 const Tuple& tuple) {
884 return ::std::tr1::get<I>(tuple);
887 template <
typename TupleT>
889 #endif // GTEST_HAS_TR1_TUPLE 891 #if GTEST_HAS_STD_TUPLE_ 892 template <
typename... Types>
894 typedef ::std::tuple<Types...> Tuple;
895 static const size_t tuple_size = ::std::tuple_size<Tuple>::value;
898 struct tuple_element : ::std::tuple_element<I, Tuple> {};
902 const Tuple& tuple) {
903 return ::std::get<I>(tuple);
906 template <
typename... Types>
907 const size_t TuplePolicy< ::std::tuple<Types...> >::tuple_size;
908 #endif // GTEST_HAS_STD_TUPLE_ 910 #if GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_ 920 struct TuplePrefixPrinter {
922 template <
typename Tuple>
923 static void PrintPrefixTo(
const Tuple& t, ::std::ostream* os) {
924 TuplePrefixPrinter<N - 1>::PrintPrefixTo(t, os);
937 template <
typename Tuple>
938 static void TersePrintPrefixToStrings(
const Tuple& t, Strings* strings) {
939 TuplePrefixPrinter<N - 1>::TersePrintPrefixToStrings(t, strings);
940 ::std::stringstream ss;
942 strings->push_back(ss.str());
948 struct TuplePrefixPrinter<0> {
949 template <
typename Tuple>
950 static void PrintPrefixTo(
const Tuple&, ::std::ostream*) {}
952 template <
typename Tuple>
953 static void TersePrintPrefixToStrings(
const Tuple&, Strings*) {}
958 template <
typename Tuple>
959 void PrintTupleTo(
const Tuple& t, ::std::ostream* os) {
961 TuplePrefixPrinter<TuplePolicy<Tuple>::tuple_size>::PrintPrefixTo(t, os);
968 template <
typename Tuple>
969 Strings UniversalTersePrintTupleFieldsToStrings(
const Tuple& value) {
971 TuplePrefixPrinter<TuplePolicy<Tuple>::tuple_size>::
972 TersePrintPrefixToStrings(value, &result);
975 #endif // GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_ 979 template <
typename T>
981 ::std::stringstream ss;
993 #endif // GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_ Definition: gtest-internal.h:855
GTEST_API_ void PrintBytesInObjectTo(const unsigned char *obj_bytes, size_t count, ::std::ostream *os)
Definition: gtest-printers.h:128
Definition: gmock-actions.h:53
GTEST_API_ void UniversalPrintArray(const wchar_t *begin, size_t len, ::std::ostream *os)
int * count
Definition: gmock_stress_test.cc:176
#define GTEST_INTENTIONAL_CONST_COND_PUSH_()
Definition: gtest-port.h:897
#define GTEST_DISABLE_MSC_WARNINGS_POP_()
Definition: gtest-port.h:318
int IsContainer
Definition: gtest-internal.h:930
GTEST_API_ bool IsTrue(bool condition)
::std::string PrintToString(const T &value)
Definition: gtest-printers.h:980
Definition: gtest-internal.h:830
GTEST_API_ void PrintStringTo(const ::std::string &s, ::std::ostream *os)
::std::string string
Definition: gtest-port.h:1097
Definition: gtest-port.h:2213
::std::wstring wstring
Definition: gtest-port.h:1103
Definition: CapabilityConfiguration.h:190
::std::basic_ostream< Char, CharTraits > & operator<<(::std::basic_ostream< Char, CharTraits > &os, const T &x)
Definition: gtest-printers.h:203
#define GTEST_API_
Definition: gtest-port.h:934
static void Print(const char *str, ::std::ostream *os)
Definition: gtest-printers.h:804
void DefaultPrintTo(IsNotContainer, false_type, const T &value, ::std::ostream *os)
Definition: gtest-printers.h:436
std::string FormatForComparisonFailureMessage(const T1 &value, const T2 &)
Definition: gtest-printers.h:349
static void Print(wchar_t *str, ::std::ostream *os)
Definition: gtest-printers.h:837
Definition: gtest-tuple.h:796
Definition: gtest-printers.h:781
const size_t kProtobufOneLinerMaxLength
Definition: gtest-printers.h:148
void PrintTo(const ::std::pair< T1, T2 > &value, ::std::ostream *os)
Definition: gtest-printers.h:676
Definition: gtest-printers.h:869
#define GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(CharType, OtherStringType)
Definition: gtest-printers.h:311
TypeKind
Definition: gtest-printers.h:124
#define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings)
Definition: gtest-port.h:317
static void Print(const T &value, ::std::ostream *os)
Definition: gtest-printers.h:790
string Print(const T &value)
Definition: gtest-printers_test.cc:235
void UniversalTersePrint(const T &value, ::std::ostream *os)
Definition: gtest-printers.h:843
void DefaultPrintNonContainerTo(const T &value, ::std::ostream *os)
Definition: gtest-printers.h:222
long long BiggestInt
Definition: gtest-port.h:2241
static void Print(const T &value, ::std::ostream *os)
Definition: gtest-printers.h:783
void PrintRawArrayTo(const T a[], size_t count, ::std::ostream *os)
Definition: gtest-printers.h:548
Definition: gtest-printers.h:217
Definition: gtest-port.h:2203
Definition: gtest-internal.h:903
#define GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(CharType)
Definition: gtest-printers.h:292
Definition: gtest-printers.h:126
char IsNotContainer
Definition: gtest-internal.h:938
Definition: gtest-tuple.h:738
type
Definition: upload.py:443
::std::vector< string > Strings
Definition: gtest-printers.h:859
const
Definition: upload.py:398
TypeWithSize< 8 >::UInt UInt64
Definition: gtest-port.h:2497
static void Print(const T(&a)[N], ::std::ostream *os)
Definition: gtest-printers.h:751
Definition: gtest-printers.h:362
static void Print(const T(&value)[N], ::std::ostream *os)
Definition: gtest-printers.h:797
Definition: gtest-printers.h:114
static void Print(char *str, ::std::ostream *os)
Definition: gtest-printers.h:815
#define GTEST_INTENTIONAL_CONST_COND_POP_()
Definition: gtest-port.h:899
void UniversalPrint(const T &value, ::std::ostream *os)
Definition: gtest-printers.h:852
Definition: gtest-printers.h:125