95 #ifndef GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_ 96 #define GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_ 110 namespace internal2 {
131 template <
typename T, TypeKind kTypeKind>
146 template <
typename T>
152 short_str.length() <= kProtobufOneLinerMaxLength ?
153 short_str : (
"\n" + value.DebugString());
154 *os << (
"<" + pretty_str +
">");
158 template <
typename T>
198 template <
typename Char,
typename CharTraits,
typename T>
200 ::std::basic_ostream<Char, CharTraits>& os,
const T& x) {
217 template <
typename T>
260 template <
typename T>
263 template <
typename T>
268 template <
typename C>
271 const C& container, ::std::ostream* os) {
272 const size_t kMaxCount = 32;
275 for (
typename C::const_iterator it = container.begin();
276 it != container.end(); ++it, ++count) {
279 if (count == kMaxCount) {
302 template <
typename T>
305 T* p, ::std::ostream* os) {
326 *os << reinterpret_cast<const void*>(
334 template <
typename T>
337 const T& value, ::std::ostream* os) {
352 template <
typename T>
386 inline void PrintTo(
char c, ::std::ostream* os) {
390 PrintTo(static_cast<unsigned char>(c), os);
394 inline void PrintTo(
bool x, ::std::ostream* os) {
395 *os << (x ?
"true" :
"false");
409 inline void PrintTo(
char* s, ::std::ostream* os) {
410 PrintTo(ImplicitCast_<const char*>(s), os);
415 inline void PrintTo(
const signed char* s, ::std::ostream* os) {
416 PrintTo(ImplicitCast_<const void*>(s), os);
418 inline void PrintTo(
signed char* s, ::std::ostream* os) {
419 PrintTo(ImplicitCast_<const void*>(s), os);
421 inline void PrintTo(
const unsigned char* s, ::std::ostream* os) {
422 PrintTo(ImplicitCast_<const void*>(s), os);
424 inline void PrintTo(
unsigned char* s, ::std::ostream* os) {
425 PrintTo(ImplicitCast_<const void*>(s), os);
433 #if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED) 436 inline void PrintTo(
wchar_t* s, ::std::ostream* os) {
437 PrintTo(ImplicitCast_<const wchar_t*>(s), os);
446 template <
typename T>
449 for (
size_t i = 1; i != count; i++) {
456 #if GTEST_HAS_GLOBAL_STRING 461 #endif // GTEST_HAS_GLOBAL_STRING 469 #if GTEST_HAS_GLOBAL_WSTRING 472 PrintWideStringTo(s, os);
474 #endif // GTEST_HAS_GLOBAL_WSTRING 476 #if GTEST_HAS_STD_WSTRING 479 PrintWideStringTo(s, os);
481 #endif // GTEST_HAS_STD_WSTRING 483 #if GTEST_HAS_TR1_TUPLE 489 template <
typename T>
490 void PrintTupleTo(
const T& t, ::std::ostream* os);
497 inline void PrintTo(const ::std::tr1::tuple<>& t, ::std::ostream* os) {
501 template <
typename T1>
502 void PrintTo(const ::std::tr1::tuple<T1>& t, ::std::ostream* os) {
506 template <
typename T1,
typename T2>
507 void PrintTo(const ::std::tr1::tuple<T1, T2>& t, ::std::ostream* os) {
511 template <
typename T1,
typename T2,
typename T3>
512 void PrintTo(const ::std::tr1::tuple<T1, T2, T3>& t, ::std::ostream* os) {
516 template <
typename T1,
typename T2,
typename T3,
typename T4>
517 void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4>& t, ::std::ostream* os) {
521 template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
522 void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5>& t,
523 ::std::ostream* os) {
527 template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
529 void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6>& t,
530 ::std::ostream* os) {
534 template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
535 typename T6,
typename T7>
536 void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7>& t,
537 ::std::ostream* os) {
541 template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
542 typename T6,
typename T7,
typename T8>
543 void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8>& t,
544 ::std::ostream* os) {
548 template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
549 typename T6,
typename T7,
typename T8,
typename T9>
550 void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9>& t,
551 ::std::ostream* os) {
555 template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
556 typename T6,
typename T7,
typename T8,
typename T9,
typename T10>
558 const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>& t,
559 ::std::ostream* os) {
562 #endif // GTEST_HAS_TR1_TUPLE 565 template <
typename T1,
typename T2>
566 void PrintTo(const ::std::pair<T1, T2>& value, ::std::ostream* os) {
578 template <
typename T>
584 # pragma warning(push) // Saves the current warning state. 585 # pragma warning(disable:4180) // Temporarily disables warning 4180. 591 static void Print(
const T& value, ::std::ostream* os) {
604 # pragma warning(pop) // Restores the warning state. 610 template <
typename T>
616 const size_t kThreshold = 18;
617 const size_t kChunkSize = 8;
622 if (len <= kThreshold) {
638 template <
typename T,
size_t N>
643 static void Print(
const T (&a)[
N], ::std::ostream* os) {
649 template <
typename T>
655 # pragma warning(push) // Saves the current warning state. 656 # pragma warning(disable:4180) // Temporarily disables warning 4180. 659 static void Print(
const T& value, ::std::ostream* os) {
662 *os <<
"@" <<
reinterpret_cast<const void*
>(&value) <<
" ";
669 # pragma warning(pop) // Restores the warning state. 676 template <
typename T>
695 template <
typename T>
700 #if GTEST_HAS_TR1_TUPLE 701 typedef ::std::vector<string> Strings;
712 struct TuplePrefixPrinter {
714 template <
typename Tuple>
715 static void PrintPrefixTo(
const Tuple& t, ::std::ostream* os) {
716 TuplePrefixPrinter<N - 1>::PrintPrefixTo(t, os);
719 ::Print(::std::tr1::get<N - 1>(t), os);
724 template <
typename Tuple>
725 static void TersePrintPrefixToStrings(
const Tuple& t, Strings* strings) {
726 TuplePrefixPrinter<N - 1>::TersePrintPrefixToStrings(t, strings);
727 ::std::stringstream ss;
729 strings->push_back(ss.str());
735 struct TuplePrefixPrinter<0> {
736 template <
typename Tuple>
737 static void PrintPrefixTo(
const Tuple&, ::std::ostream*) {}
739 template <
typename Tuple>
740 static void TersePrintPrefixToStrings(
const Tuple&, Strings*) {}
748 struct TuplePrefixPrinter<1> {
749 template <
typename Tuple>
750 static void PrintPrefixTo(
const Tuple& t, ::std::ostream* os) {
752 Print(::std::tr1::get<0>(t), os);
755 template <
typename Tuple>
756 static void TersePrintPrefixToStrings(
const Tuple& t, Strings* strings) {
757 ::std::stringstream ss;
759 strings->push_back(ss.str());
765 template <
typename T>
766 void PrintTupleTo(
const T& t, ::std::ostream* os) {
768 TuplePrefixPrinter< ::std::tr1::tuple_size<T>::value>::
769 PrintPrefixTo(t, os);
776 template <
typename Tuple>
777 Strings UniversalTersePrintTupleFieldsToStrings(
const Tuple& value) {
779 TuplePrefixPrinter< ::std::tr1::tuple_size<Tuple>::value>::
780 TersePrintPrefixToStrings(value, &result);
783 #endif // GTEST_HAS_TR1_TUPLE 787 template <
typename T>
789 ::std::stringstream ss;
796 #endif // GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_ Definition: gtest-internal.h:847
GTEST_API_ bool IsTrue(bool condition)
Definition: gtest.cc:4531
Definition: gtest-printers.h:124
Definition: gmock-actions.h:49
void PrintRawArrayTo(const T a[], size_t count,::std::ostream *os)
Definition: gtest-printers.h:447
int IsContainer
Definition: gtest-internal.h:927
GTEST_API_ void PrintStringTo(const ::std::string &s,::std::ostream *os)
::std::string PrintToString(const T &value)
Definition: gtest-printers.h:788
void UniversalTersePrint(const T &value,::std::ostream *os)
Definition: gtest-printers.h:677
::std::string string
Definition: gtest-port.h:756
void DefaultPrintNonContainerTo(const T &value,::std::ostream *os)
Definition: gtest-printers.h:218
Definition: gtest-port.h:1473
Definition: InputPrereqs.h:107
::std::wstring wstring
Definition: gtest-port.h:762
::std::basic_ostream< Char, CharTraits > & operator<<(::std::basic_ostream< Char, CharTraits > &os, const T &x)
Definition: gtest-printers.h:199
#define GTEST_API_
Definition: gtest-port.h:662
Definition: InputPrereqs.h:104
void DefaultPrintTo(IsNotContainer, false_type, const T &value,::std::ostream *os)
Definition: gtest-printers.h:335
const size_t kProtobufOneLinerMaxLength
Definition: gtest-printers.h:144
static void Print(const T(&a)[N],::std::ostream *os)
Definition: gtest-printers.h:643
void UniversalTersePrint(char *str,::std::ostream *os)
Definition: gtest-printers.h:687
static void Print(const T &value,::std::ostream *os)
Definition: gtest-printers.h:591
TypeKind
Definition: gtest-printers.h:120
GTEST_API_ void UniversalPrintArray(const char *begin, size_t len,::std::ostream *os)
void UniversalPrint(const T &value,::std::ostream *os)
Definition: gtest-printers.h:696
long long BiggestInt
Definition: gtest-port.h:1501
GTEST_API_ void PrintBytesInObjectTo(const unsigned char *obj_bytes, size_t count,::std::ostream *os)
Definition: gtest-printers.h:213
Definition: InputPrereqs.h:78
Definition: gtest-port.h:1463
Definition: gtest-internal.h:900
Definition: gtest-printers.h:122
char IsNotContainer
Definition: gtest-internal.h:935
void PrintTo(const ::std::pair< T1, T2 > &value,::std::ostream *os)
Definition: gtest-printers.h:566
TypeWithSize< 8 >::UInt UInt64
Definition: gtest-port.h:1735
Definition: gtest-printers.h:261
static void Print(const T &value,::std::ostream *os)
Definition: gtest-printers.h:659
Definition: gtest-printers.h:110
Definition: gtest-printers.h:121