95#ifndef GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_
96#define GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_
103#include "gtest/internal/gtest-port.h"
104#include "gtest/internal/gtest-internal.h"
131template <
typename T, TypeKind kTypeKind>
150 const ::testing::internal::string short_str = value.ShortDebugString();
151 const ::testing::internal::string pretty_str =
153 short_str : (
"\n" + value.DebugString());
154 *os << (
"<" + pretty_str +
">");
198template <
typename Char,
typename CharTraits,
typename T>
199::std::basic_ostream<Char, CharTraits>&
operator<<(
200 ::std::basic_ostream<Char, CharTraits>& os,
const T& x) {
201 TypeWithoutFormatter<T,
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) {
305 T* p, ::std::ostream* os) {
326 *os << reinterpret_cast<const void*>(
337 const T&
value, ::std::ostream* os) {
386inline void PrintTo(
char c, ::std::ostream* os) {
390 PrintTo(
static_cast<unsigned char>(c), os);
394inline void PrintTo(
bool x, ::std::ostream* os) {
395 *os << (x ?
"true" :
"false");
409inline void PrintTo(
char* s, ::std::ostream* os) {
415inline void PrintTo(
const signed char* s, ::std::ostream* os) {
418inline void PrintTo(
signed char* s, ::std::ostream* os) {
421inline void PrintTo(
const unsigned char* s, ::std::ostream* os) {
424inline void PrintTo(
unsigned char* s, ::std::ostream* os) {
433#if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)
436inline void PrintTo(
wchar_t* s, ::std::ostream* os) {
449 for (
size_t i = 1; i != count; i++) {
456#if GTEST_HAS_GLOBAL_STRING
458inline void PrintTo(const ::string& s, ::std::ostream* os) {
464inline void PrintTo(const ::std::string& s, ::std::ostream* os) {
469#if GTEST_HAS_GLOBAL_WSTRING
470GTEST_API_ void PrintWideStringTo(const ::wstring&s, ::std::ostream* os);
471inline void PrintTo(const ::wstring& s, ::std::ostream* os) {
472 PrintWideStringTo(s, os);
476#if GTEST_HAS_STD_WSTRING
477GTEST_API_ void PrintWideStringTo(const ::std::wstring&s, ::std::ostream* os);
478inline void PrintTo(const ::std::wstring& s, ::std::ostream* os) {
479 PrintWideStringTo(s, os);
483#if GTEST_HAS_TR1_TUPLE
490void PrintTupleTo(
const T& t, ::std::ostream* os);
497inline void PrintTo(const ::std::tr1::tuple<>& t, ::std::ostream* os) {
501template <
typename T1>
502void PrintTo(const ::std::tr1::tuple<T1>& t, ::std::ostream* os) {
506template <
typename T1,
typename T2>
507void PrintTo(const ::std::tr1::tuple<T1, T2>& t, ::std::ostream* os) {
511template <
typename T1,
typename T2,
typename T3>
512void PrintTo(const ::std::tr1::tuple<T1, T2, T3>& t, ::std::ostream* os) {
516template <
typename T1,
typename T2,
typename T3,
typename T4>
517void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4>& t, ::std::ostream* os) {
521template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
522void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5>& t,
523 ::std::ostream* os) {
527template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
529void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6>& t,
530 ::std::ostream* os) {
534template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
535 typename T6,
typename T7>
536void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7>& t,
537 ::std::ostream* os) {
541template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
542 typename T6,
typename T7,
typename T8>
543void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8>& t,
544 ::std::ostream* os) {
548template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
549 typename T6,
typename T7,
typename T8,
typename T9>
550void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9>& t,
551 ::std::ostream* os) {
555template <
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) {
565template <
typename T1,
typename T2>
579class UniversalPrinter {
584# pragma warning(push)
585# pragma warning(disable:4180)
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);
641template <
typename T,
size_t N>
646 static void Print(
const T (&a)[N], ::std::ostream* os) {
658# pragma warning(push)
659# pragma warning(disable:4180)
665 *os <<
"@" <<
reinterpret_cast<const void*
>(&
value) <<
" ";
694template <
typename T,
size_t N>
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
722class 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) {
759#if GTEST_HAS_TR1_TUPLE
760typedef ::std::vector<string> Strings;
771struct 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;
787 UniversalTersePrint(::std::tr1::get<N - 1>(t), &ss);
788 strings->push_back(ss.str());
794struct 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*) {}
807struct 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());
825void PrintTupleTo(
const T& t, ::std::ostream* os) {
827 TuplePrefixPrinter< ::std::tr1::tuple_size<T>::value>::
828 PrintPrefixTo(t, os);
835template <
typename Tuple>
836Strings UniversalTersePrintTupleFieldsToStrings(
const Tuple&
value) {
838 TuplePrefixPrinter< ::std::tr1::tuple_size<Tuple>::value>::
839 TersePrintPrefixToStrings(
value, &result);
848 ::std::stringstream ss;
static const bool value
Definition dsd/test/gtest/include/gtest/internal/gtest-internal.h:821
static void Print(const T &value, ::std::ostream *os)
Definition dsd/test/gtest/include/gtest/gtest-printers.h:662
static void Print(const T(&a)[N], ::std::ostream *os)
Definition dsd/test/gtest/include/gtest/gtest-printers.h:646
Definition mbelib/test/gtest/include/gtest/gtest-printers.h:579
static void Print(const T &value, ::std::ostream *os)
Definition dsd/test/gtest/include/gtest/gtest-printers.h:591
static void Print(const T &value, ::std::ostream *os)
Definition dsd/test/gtest/include/gtest/gtest-printers.h:690
static void Print(const T(&value)[N], ::std::ostream *os)
Definition dsd/test/gtest/include/gtest/gtest-printers.h:697
static void Print(char *str, ::std::ostream *os)
Definition dsd/test/gtest/include/gtest/gtest-printers.h:715
static void Print(const char *str, ::std::ostream *os)
Definition dsd/test/gtest/include/gtest/gtest-printers.h:704
static void Print(wchar_t *str, ::std::ostream *os)
Definition dsd/test/gtest/include/gtest/gtest-printers.h:737
Definition dsd/test/gtest/include/gtest/gtest-printers.h:681
static void Print(const T &value, ::std::ostream *os)
Definition dsd/test/gtest/include/gtest/gtest-printers.h:683
#define GTEST_API_
Definition dsd/test/gtest/include/gtest/internal/gtest-port.h:768
Definition dsd/test/gtest/include/gtest/gtest-printers.h:110
const size_t kProtobufOneLinerMaxLength
Definition dsd/test/gtest/include/gtest/gtest-printers.h:144
GTEST_API_ void PrintBytesInObjectTo(const unsigned char *obj_bytes, size_t count, ::std::ostream *os)
::std::basic_ostream< Char, CharTraits > & operator<<(::std::basic_ostream< Char, CharTraits > &os, const T &x)
Definition dsd/test/gtest/include/gtest/gtest-printers.h:199
TypeKind
Definition dsd/test/gtest/include/gtest/gtest-printers.h:120
@ kConvertibleToInteger
Definition dsd/test/gtest/include/gtest/gtest-printers.h:122
@ kOtherType
Definition dsd/test/gtest/include/gtest/gtest-printers.h:124
@ kProtobuf
Definition dsd/test/gtest/include/gtest/gtest-printers.h:121
Definition dsd/test/gmock/include/gmock/gmock-actions.h:60
bool_constant< true > true_type
Definition dsd/test/gtest/include/gtest/internal/gtest-port.h:1618
long long BiggestInt
Definition dsd/test/gtest/include/gtest/internal/gtest-port.h:1649
void UniversalPrint(const T &value, ::std::ostream *os)
Definition dsd/test/gtest/include/gtest/gtest-printers.h:752
GTEST_API_ void PrintStringTo(const ::std::string &s, ::std::ostream *os)
void PrintTo(const ReferenceWrapper< T > &ref, ::std::ostream *os)
Definition dsd/test/gmock/include/gmock/gmock-actions.h:846
bool_constant< false > false_type
Definition dsd/test/gtest/include/gtest/internal/gtest-port.h:1617
To ImplicitCast_(To x)
Definition dsd/test/gtest/include/gtest/internal/gtest-port.h:1098
const bool ImplicitlyConvertible< From, To >::value
Definition dsd/test/gtest/include/gtest/internal/gtest-internal.h:826
GTEST_API_ bool IsTrue(bool condition)
char IsNotContainer
Definition dsd/test/gtest/include/gtest/internal/gtest-internal.h:867
void DefaultPrintTo(IsContainer, false_type, const C &container, ::std::ostream *os)
Definition dsd/test/gtest/include/gtest/gtest-printers.h:269
IsContainer IsContainerTest(int, typename C::iterator *=NULL, typename C::const_iterator *=NULL)
Definition dsd/test/gtest/include/gtest/internal/gtest-internal.h:861
TypeWithSize< 8 >::UInt UInt64
Definition dsd/test/gtest/include/gtest/internal/gtest-port.h:1903
void PrintRawArrayTo(const T a[], size_t count, ::std::ostream *os)
Definition dsd/test/gtest/include/gtest/gtest-printers.h:447
void UniversalPrintArray(const T *begin, size_t len, ::std::ostream *os)
Definition dsd/test/gtest/include/gtest/gtest-printers.h:611
int IsContainer
Definition dsd/test/gtest/include/gtest/internal/gtest-internal.h:859
void UniversalTersePrint(const T &value, ::std::ostream *os)
Definition dsd/test/gtest/include/gtest/gtest-printers.h:743
Definition dsd/test/gtest/include/gtest/gtest-printers.h:213
void DefaultPrintNonContainerTo(const T &value, ::std::ostream *os)
Definition dsd/test/gtest/include/gtest/gtest-printers.h:218
Definition dsd/test/gmock/include/gmock/gmock-actions.h:49
::std::string PrintToString(const T &value)
Definition dsd/test/gtest/include/gtest/gtest-printers.h:847
static const bool value
Definition dsd/test/gtest/include/gtest/internal/gtest-port.h:1613
Definition dsd/test/gtest/include/gtest/internal/gtest-port.h:1621