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>
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>
579 class UniversalPrinter {
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) {
634 const char* begin,
size_t len, ::std::ostream* os);
638 const wchar_t* begin,
size_t len, ::std::ostream* os);
641 template <
typename T,
size_t N>
646 static void Print(
const T (&
a)[
N], ::std::ostream* os) {
652 template <
typename T>
658 # pragma warning(push) // Saves the current warning state.
659 # pragma warning(disable:4180) // Temporarily disables warning 4180.
662 static void Print(
const T& value, ::std::ostream* os) {
665 *os <<
"@" <<
reinterpret_cast<const void*
>(&value) <<
" ";
672 # pragma warning(pop) // Restores the warning state.
680 template <
typename T>
683 static void Print(
const T& value, ::std::ostream* os) {
687 template <
typename T>
690 static void Print(
const T& value, ::std::ostream* os) {
694 template <
typename T,
size_t N>
697 static void Print(
const T (&value)[
N], ::std::ostream* os) {
704 static void Print(
const char* str, ::std::ostream* os) {
715 static void Print(
char* str, ::std::ostream* os) {
720 #if GTEST_HAS_STD_WSTRING
722 class UniversalTersePrinter<const wchar_t*> {
724 static void Print(
const wchar_t* str, ::std::ostream* os) {
737 static void Print(
wchar_t* str, ::std::ostream* os) {
742 template <
typename T>
751 template <
typename T>
759 #if GTEST_HAS_TR1_TUPLE
760 typedef ::std::vector<string> Strings;
771 struct TuplePrefixPrinter {
773 template <
typename Tuple>
774 static void PrintPrefixTo(
const Tuple& t, ::std::ostream* os) {
775 TuplePrefixPrinter<N - 1>::PrintPrefixTo(t, os);
777 UniversalPrinter<typename ::std::tr1::tuple_element<
N - 1, Tuple>::type>
778 ::Print(::std::tr1::get<N - 1>(t), os);
783 template <
typename Tuple>
784 static void TersePrintPrefixToStrings(
const Tuple& t, Strings* strings) {
785 TuplePrefixPrinter<N - 1>::TersePrintPrefixToStrings(t, strings);
786 ::std::stringstream ss;
788 strings->push_back(ss.str());
794 struct TuplePrefixPrinter<0> {
795 template <
typename Tuple>
796 static void PrintPrefixTo(
const Tuple&, ::std::ostream*) {}
798 template <
typename Tuple>
799 static void TersePrintPrefixToStrings(
const Tuple&, Strings*) {}
807 struct TuplePrefixPrinter<1> {
808 template <
typename Tuple>
809 static void PrintPrefixTo(
const Tuple& t, ::std::ostream* os) {
810 UniversalPrinter<typename ::std::tr1::tuple_element<0, Tuple>::type>::
811 Print(::std::tr1::get<0>(t), os);
814 template <
typename Tuple>
815 static void TersePrintPrefixToStrings(
const Tuple& t, Strings* strings) {
816 ::std::stringstream ss;
818 strings->push_back(ss.str());
824 template <
typename T>
825 void PrintTupleTo(
const T& t, ::std::ostream* os) {
827 TuplePrefixPrinter< ::std::tr1::tuple_size<T>::value>::
828 PrintPrefixTo(t, os);
835 template <
typename Tuple>
836 Strings UniversalTersePrintTupleFieldsToStrings(
const Tuple& value) {
838 TuplePrefixPrinter< ::std::tr1::tuple_size<Tuple>::value>::
839 TersePrintPrefixToStrings(value, &result);
842 #endif // GTEST_HAS_TR1_TUPLE
846 template <
typename T>
848 ::std::stringstream ss;
855 #endif // GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_
static void Print(const T &value,::std::ostream *os)
Definition: gtest-printers.h:683
GTEST_API_ bool IsTrue(bool condition)
Definition: gtest.cc:4648
Definition: gtest-printers.h:124
Definition: gtest-death-test.h:43
void PrintRawArrayTo(const T a[], size_t count,::std::ostream *os)
Definition: gtest-printers.h:447
static void Print(wchar_t *str,::std::ostream *os)
Definition: gtest-printers.h:737
Definition: gtest-printers.h:261
int IsContainer
Definition: gtest-internal.h:859
static void Print(const T &value,::std::ostream *os)
Definition: gtest-printers.h:690
GTEST_API_ void PrintStringTo(const ::std::string &s,::std::ostream *os)
::std::string PrintToString(const T &value)
Definition: gtest-printers.h:847
static void Print(const T(&value)[N],::std::ostream *os)
Definition: gtest-printers.h:697
void UniversalTersePrint(const T &value,::std::ostream *os)
Definition: gtest-printers.h:743
::std::string string
Definition: gtest-port.h:872
Definition: gtest-printers.h:681
void DefaultPrintNonContainerTo(const T &value,::std::ostream *os)
Definition: gtest-printers.h:218
Definition: gtest-port.h:1621
::std::wstring wstring
Definition: gtest-port.h:878
static void Print(const T(&a)[N],::std::ostream *os)
Definition: gtest-printers.h:646
static void Print(const T &value,::std::ostream *os)
Definition: gtest-printers.h:591
::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:768
static void Print(const T &value,::std::ostream *os)
Definition: gtest-printers.h:662
static void Print(const char *str,::std::ostream *os)
Definition: gtest-printers.h:704
const size_t kProtobufOneLinerMaxLength
Definition: gtest-printers.h:144
JLOOP2 NK jnz KLOOP2 mov C
Definition: mtxm_gen.h:10
TypeKind
Definition: gtest-printers.h:120
const T1 &f1 return GTEST_2_TUPLE_() T(f0, f1)
const double N
Definition: navstokes_cosines.cc:94
void UniversalPrint(const T &value,::std::ostream *os)
Definition: gtest-printers.h:752
FLOAT a(int j, FLOAT z)
Definition: y1.cc:86
long long BiggestInt
Definition: gtest-port.h:1649
GTEST_API_ void PrintBytesInObjectTo(const unsigned char *obj_bytes, size_t count,::std::ostream *os)
Definition: gtest-internal.h:779
Definition: gtest-printers.h:213
Definition: gtest-port.h:1611
void PrintTo(const T &value,::std::ostream *os)
Definition: gtest-printers.h:353
Definition: gtest-printers.h:122
char IsNotContainer
Definition: gtest-internal.h:867
static void Print(char *str,::std::ostream *os)
Definition: gtest-printers.h:715
Definition: gtest-internal.h:832
void UniversalPrintArray(const T *begin, size_t len,::std::ostream *os)
Definition: gtest-printers.h:611
TypeWithSize< 8 >::UInt UInt64
Definition: gtest-port.h:1903
Definition: gtest-printers.h:110
const double c
Definition: gfit.cc:200
void DefaultPrintTo(IsContainer, false_type, const C &container,::std::ostream *os)
Definition: gtest-printers.h:269
Definition: gtest-printers.h:121