00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095 #ifndef GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_
00096 #define GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_
00097
00098 #include <ostream>
00099 #include <sstream>
00100 #include <string>
00101 #include <utility>
00102 #include <vector>
00103 #include "gtest/internal/gtest-port.h"
00104 #include "gtest/internal/gtest-internal.h"
00105
00106 #if GTEST_HAS_STD_TUPLE_
00107 # include <tuple>
00108 #endif
00109
00110 namespace testing {
00111
00112
00113
00114 namespace internal2 {
00115
00116
00117
00118 GTEST_API_ void PrintBytesInObjectTo(const unsigned char* obj_bytes,
00119 size_t count,
00120 ::std::ostream* os);
00121
00122
00123
00124 enum TypeKind {
00125 kProtobuf,
00126 kConvertibleToInteger,
00127
00128 kOtherType
00129 };
00130
00131
00132
00133
00134
00135 template <typename T, TypeKind kTypeKind>
00136 class TypeWithoutFormatter {
00137 public:
00138
00139 static void PrintValue(const T& value, ::std::ostream* os) {
00140 PrintBytesInObjectTo(reinterpret_cast<const unsigned char*>(&value),
00141 sizeof(value), os);
00142 }
00143 };
00144
00145
00146
00147
00148 const size_t kProtobufOneLinerMaxLength = 50;
00149
00150 template <typename T>
00151 class TypeWithoutFormatter<T, kProtobuf> {
00152 public:
00153 static void PrintValue(const T& value, ::std::ostream* os) {
00154 const ::testing::internal::string short_str = value.ShortDebugString();
00155 const ::testing::internal::string pretty_str =
00156 short_str.length() <= kProtobufOneLinerMaxLength ?
00157 short_str : ("\n" + value.DebugString());
00158 *os << ("<" + pretty_str + ">");
00159 }
00160 };
00161
00162 template <typename T>
00163 class TypeWithoutFormatter<T, kConvertibleToInteger> {
00164 public:
00165
00166
00167
00168
00169
00170
00171
00172 static void PrintValue(const T& value, ::std::ostream* os) {
00173 const internal::BiggestInt kBigInt = value;
00174 *os << kBigInt;
00175 }
00176 };
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202 template <typename Char, typename CharTraits, typename T>
00203 ::std::basic_ostream<Char, CharTraits>& operator<<(
00204 ::std::basic_ostream<Char, CharTraits>& os, const T& x) {
00205 TypeWithoutFormatter<T,
00206 (internal::IsAProtocolMessage<T>::value ? kProtobuf :
00207 internal::ImplicitlyConvertible<const T&, internal::BiggestInt>::value ?
00208 kConvertibleToInteger : kOtherType)>::PrintValue(x, &os);
00209 return os;
00210 }
00211
00212 }
00213 }
00214
00215
00216
00217 namespace testing_internal {
00218
00219
00220
00221 template <typename T>
00222 void DefaultPrintNonContainerTo(const T& value, ::std::ostream* os) {
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234 using namespace ::testing::internal2;
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249 *os << value;
00250 }
00251
00252 }
00253
00254 namespace testing {
00255 namespace internal {
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272 template <typename ToPrint, typename OtherOperand>
00273 class FormatForComparison {
00274 public:
00275 static ::std::string Format(const ToPrint& value) {
00276 return ::testing::PrintToString(value);
00277 }
00278 };
00279
00280
00281 template <typename ToPrint, size_t N, typename OtherOperand>
00282 class FormatForComparison<ToPrint[N], OtherOperand> {
00283 public:
00284 static ::std::string Format(const ToPrint* value) {
00285 return FormatForComparison<const ToPrint*, OtherOperand>::Format(value);
00286 }
00287 };
00288
00289
00290
00291
00292 #define GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(CharType) \
00293 template <typename OtherOperand> \
00294 class FormatForComparison<CharType*, OtherOperand> { \
00295 public: \
00296 static ::std::string Format(CharType* value) { \
00297 return ::testing::PrintToString(static_cast<const void*>(value)); \
00298 } \
00299 }
00300
00301 GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(char);
00302 GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const char);
00303 GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(wchar_t);
00304 GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const wchar_t);
00305
00306 #undef GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_
00307
00308
00309
00310
00311 #define GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(CharType, OtherStringType) \
00312 template <> \
00313 class FormatForComparison<CharType*, OtherStringType> { \
00314 public: \
00315 static ::std::string Format(CharType* value) { \
00316 return ::testing::PrintToString(value); \
00317 } \
00318 }
00319
00320 GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char, ::std::string);
00321 GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char, ::std::string);
00322
00323 #if GTEST_HAS_GLOBAL_STRING
00324 GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char, ::string);
00325 GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char, ::string);
00326 #endif
00327
00328 #if GTEST_HAS_GLOBAL_WSTRING
00329 GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(wchar_t, ::wstring);
00330 GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const wchar_t, ::wstring);
00331 #endif
00332
00333 #if GTEST_HAS_STD_WSTRING
00334 GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(wchar_t, ::std::wstring);
00335 GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const wchar_t, ::std::wstring);
00336 #endif
00337
00338 #undef GTEST_IMPL_FORMAT_C_STRING_AS_STRING_
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348 template <typename T1, typename T2>
00349 std::string FormatForComparisonFailureMessage(
00350 const T1& value, const T2& ) {
00351 return FormatForComparison<T1, T2>::Format(value);
00352 }
00353
00354
00355
00356
00357
00358
00359
00360
00361 template <typename T>
00362 class UniversalPrinter;
00363
00364 template <typename T>
00365 void UniversalPrint(const T& value, ::std::ostream* os);
00366
00367
00368
00369 template <typename C>
00370 void DefaultPrintTo(IsContainer ,
00371 false_type ,
00372 const C& container, ::std::ostream* os) {
00373 const size_t kMaxCount = 32;
00374 *os << '{';
00375 size_t count = 0;
00376 for (typename C::const_iterator it = container.begin();
00377 it != container.end(); ++it, ++count) {
00378 if (count > 0) {
00379 *os << ',';
00380 if (count == kMaxCount) {
00381 *os << " ...";
00382 break;
00383 }
00384 }
00385 *os << ' ';
00386
00387
00388 internal::UniversalPrint(*it, os);
00389 }
00390
00391 if (count > 0) {
00392 *os << ' ';
00393 }
00394 *os << '}';
00395 }
00396
00397
00398
00399
00400
00401
00402
00403 template <typename T>
00404 void DefaultPrintTo(IsNotContainer ,
00405 true_type ,
00406 T* p, ::std::ostream* os) {
00407 if (p == NULL) {
00408 *os << "NULL";
00409 } else {
00410
00411
00412
00413
00414
00415 if (IsTrue(ImplicitlyConvertible<T*, const void*>::value)) {
00416
00417
00418
00419 *os << p;
00420 } else {
00421
00422
00423
00424
00425
00426
00427 *os << reinterpret_cast<const void*>(
00428 reinterpret_cast<internal::UInt64>(p));
00429 }
00430 }
00431 }
00432
00433
00434
00435 template <typename T>
00436 void DefaultPrintTo(IsNotContainer ,
00437 false_type ,
00438 const T& value, ::std::ostream* os) {
00439 ::testing_internal::DefaultPrintNonContainerTo(value, os);
00440 }
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453 template <typename T>
00454 void PrintTo(const T& value, ::std::ostream* os) {
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477 DefaultPrintTo(IsContainerTest<T>(0), is_pointer<T>(), value, os);
00478 }
00479
00480
00481
00482
00483
00484
00485 GTEST_API_ void PrintTo(unsigned char c, ::std::ostream* os);
00486 GTEST_API_ void PrintTo(signed char c, ::std::ostream* os);
00487 inline void PrintTo(char c, ::std::ostream* os) {
00488
00489
00490
00491 PrintTo(static_cast<unsigned char>(c), os);
00492 }
00493
00494
00495 inline void PrintTo(bool x, ::std::ostream* os) {
00496 *os << (x ? "true" : "false");
00497 }
00498
00499
00500
00501
00502
00503
00504
00505
00506 GTEST_API_ void PrintTo(wchar_t wc, ::std::ostream* os);
00507
00508
00509 GTEST_API_ void PrintTo(const char* s, ::std::ostream* os);
00510 inline void PrintTo(char* s, ::std::ostream* os) {
00511 PrintTo(ImplicitCast_<const char*>(s), os);
00512 }
00513
00514
00515
00516 inline void PrintTo(const signed char* s, ::std::ostream* os) {
00517 PrintTo(ImplicitCast_<const void*>(s), os);
00518 }
00519 inline void PrintTo(signed char* s, ::std::ostream* os) {
00520 PrintTo(ImplicitCast_<const void*>(s), os);
00521 }
00522 inline void PrintTo(const unsigned char* s, ::std::ostream* os) {
00523 PrintTo(ImplicitCast_<const void*>(s), os);
00524 }
00525 inline void PrintTo(unsigned char* s, ::std::ostream* os) {
00526 PrintTo(ImplicitCast_<const void*>(s), os);
00527 }
00528
00529
00530
00531
00532
00533
00534 #if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)
00535
00536 GTEST_API_ void PrintTo(const wchar_t* s, ::std::ostream* os);
00537 inline void PrintTo(wchar_t* s, ::std::ostream* os) {
00538 PrintTo(ImplicitCast_<const wchar_t*>(s), os);
00539 }
00540 #endif
00541
00542
00543
00544
00545
00546
00547 template <typename T>
00548 void PrintRawArrayTo(const T a[], size_t count, ::std::ostream* os) {
00549 UniversalPrint(a[0], os);
00550 for (size_t i = 1; i != count; i++) {
00551 *os << ", ";
00552 UniversalPrint(a[i], os);
00553 }
00554 }
00555
00556
00557 #if GTEST_HAS_GLOBAL_STRING
00558 GTEST_API_ void PrintStringTo(const ::string&s, ::std::ostream* os);
00559 inline void PrintTo(const ::string& s, ::std::ostream* os) {
00560 PrintStringTo(s, os);
00561 }
00562 #endif // GTEST_HAS_GLOBAL_STRING
00563
00564 GTEST_API_ void PrintStringTo(const ::std::string&s, ::std::ostream* os);
00565 inline void PrintTo(const ::std::string& s, ::std::ostream* os) {
00566 PrintStringTo(s, os);
00567 }
00568
00569
00570 #if GTEST_HAS_GLOBAL_WSTRING
00571 GTEST_API_ void PrintWideStringTo(const ::wstring&s, ::std::ostream* os);
00572 inline void PrintTo(const ::wstring& s, ::std::ostream* os) {
00573 PrintWideStringTo(s, os);
00574 }
00575 #endif // GTEST_HAS_GLOBAL_WSTRING
00576
00577 #if GTEST_HAS_STD_WSTRING
00578 GTEST_API_ void PrintWideStringTo(const ::std::wstring&s, ::std::ostream* os);
00579 inline void PrintTo(const ::std::wstring& s, ::std::ostream* os) {
00580 PrintWideStringTo(s, os);
00581 }
00582 #endif // GTEST_HAS_STD_WSTRING
00583
00584 #if GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_
00585
00586
00587 template <typename T>
00588 void PrintTupleTo(const T& t, ::std::ostream* os);
00589 #endif // GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_
00590
00591 #if GTEST_HAS_TR1_TUPLE
00592
00593
00594
00595
00596
00597
00598
00599
00600 inline void PrintTo(const ::std::tr1::tuple<>& t, ::std::ostream* os) {
00601 PrintTupleTo(t, os);
00602 }
00603
00604 template <typename T1>
00605 void PrintTo(const ::std::tr1::tuple<T1>& t, ::std::ostream* os) {
00606 PrintTupleTo(t, os);
00607 }
00608
00609 template <typename T1, typename T2>
00610 void PrintTo(const ::std::tr1::tuple<T1, T2>& t, ::std::ostream* os) {
00611 PrintTupleTo(t, os);
00612 }
00613
00614 template <typename T1, typename T2, typename T3>
00615 void PrintTo(const ::std::tr1::tuple<T1, T2, T3>& t, ::std::ostream* os) {
00616 PrintTupleTo(t, os);
00617 }
00618
00619 template <typename T1, typename T2, typename T3, typename T4>
00620 void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4>& t, ::std::ostream* os) {
00621 PrintTupleTo(t, os);
00622 }
00623
00624 template <typename T1, typename T2, typename T3, typename T4, typename T5>
00625 void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5>& t,
00626 ::std::ostream* os) {
00627 PrintTupleTo(t, os);
00628 }
00629
00630 template <typename T1, typename T2, typename T3, typename T4, typename T5,
00631 typename T6>
00632 void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6>& t,
00633 ::std::ostream* os) {
00634 PrintTupleTo(t, os);
00635 }
00636
00637 template <typename T1, typename T2, typename T3, typename T4, typename T5,
00638 typename T6, typename T7>
00639 void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7>& t,
00640 ::std::ostream* os) {
00641 PrintTupleTo(t, os);
00642 }
00643
00644 template <typename T1, typename T2, typename T3, typename T4, typename T5,
00645 typename T6, typename T7, typename T8>
00646 void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8>& t,
00647 ::std::ostream* os) {
00648 PrintTupleTo(t, os);
00649 }
00650
00651 template <typename T1, typename T2, typename T3, typename T4, typename T5,
00652 typename T6, typename T7, typename T8, typename T9>
00653 void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9>& t,
00654 ::std::ostream* os) {
00655 PrintTupleTo(t, os);
00656 }
00657
00658 template <typename T1, typename T2, typename T3, typename T4, typename T5,
00659 typename T6, typename T7, typename T8, typename T9, typename T10>
00660 void PrintTo(
00661 const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>& t,
00662 ::std::ostream* os) {
00663 PrintTupleTo(t, os);
00664 }
00665 #endif // GTEST_HAS_TR1_TUPLE
00666
00667 #if GTEST_HAS_STD_TUPLE_
00668 template <typename... Types>
00669 void PrintTo(const ::std::tuple<Types...>& t, ::std::ostream* os) {
00670 PrintTupleTo(t, os);
00671 }
00672 #endif // GTEST_HAS_STD_TUPLE_
00673
00674
00675 template <typename T1, typename T2>
00676 void PrintTo(const ::std::pair<T1, T2>& value, ::std::ostream* os) {
00677 *os << '(';
00678
00679
00680 UniversalPrinter<T1>::Print(value.first, os);
00681 *os << ", ";
00682 UniversalPrinter<T2>::Print(value.second, os);
00683 *os << ')';
00684 }
00685
00686
00687
00688 template <typename T>
00689 class UniversalPrinter {
00690 public:
00691
00692
00693 GTEST_DISABLE_MSC_WARNINGS_PUSH_(4180)
00694
00695
00696
00697
00698 static void Print(const T& value, ::std::ostream* os) {
00699
00700
00701
00702
00703
00704
00705
00706
00707 PrintTo(value, os);
00708 }
00709
00710 GTEST_DISABLE_MSC_WARNINGS_POP_()
00711 };
00712
00713
00714
00715 template <typename T>
00716 void UniversalPrintArray(const T* begin, size_t len, ::std::ostream* os) {
00717 if (len == 0) {
00718 *os << "{}";
00719 } else {
00720 *os << "{ ";
00721 const size_t kThreshold = 18;
00722 const size_t kChunkSize = 8;
00723
00724
00725
00726
00727 if (len <= kThreshold) {
00728 PrintRawArrayTo(begin, len, os);
00729 } else {
00730 PrintRawArrayTo(begin, kChunkSize, os);
00731 *os << ", ..., ";
00732 PrintRawArrayTo(begin + len - kChunkSize, kChunkSize, os);
00733 }
00734 *os << " }";
00735 }
00736 }
00737
00738 GTEST_API_ void UniversalPrintArray(
00739 const char* begin, size_t len, ::std::ostream* os);
00740
00741
00742 GTEST_API_ void UniversalPrintArray(
00743 const wchar_t* begin, size_t len, ::std::ostream* os);
00744
00745
00746 template <typename T, size_t N>
00747 class UniversalPrinter<T[N]> {
00748 public:
00749
00750
00751 static void Print(const T (&a)[N], ::std::ostream* os) {
00752 UniversalPrintArray(a, N, os);
00753 }
00754 };
00755
00756
00757 template <typename T>
00758 class UniversalPrinter<T&> {
00759 public:
00760
00761
00762 GTEST_DISABLE_MSC_WARNINGS_PUSH_(4180)
00763
00764 static void Print(const T& value, ::std::ostream* os) {
00765
00766
00767 *os << "@" << reinterpret_cast<const void*>(&value) << " ";
00768
00769
00770 UniversalPrint(value, os);
00771 }
00772
00773 GTEST_DISABLE_MSC_WARNINGS_POP_()
00774 };
00775
00776
00777
00778
00779
00780 template <typename T>
00781 class UniversalTersePrinter {
00782 public:
00783 static void Print(const T& value, ::std::ostream* os) {
00784 UniversalPrint(value, os);
00785 }
00786 };
00787 template <typename T>
00788 class UniversalTersePrinter<T&> {
00789 public:
00790 static void Print(const T& value, ::std::ostream* os) {
00791 UniversalPrint(value, os);
00792 }
00793 };
00794 template <typename T, size_t N>
00795 class UniversalTersePrinter<T[N]> {
00796 public:
00797 static void Print(const T (&value)[N], ::std::ostream* os) {
00798 UniversalPrinter<T[N]>::Print(value, os);
00799 }
00800 };
00801 template <>
00802 class UniversalTersePrinter<const char*> {
00803 public:
00804 static void Print(const char* str, ::std::ostream* os) {
00805 if (str == NULL) {
00806 *os << "NULL";
00807 } else {
00808 UniversalPrint(string(str), os);
00809 }
00810 }
00811 };
00812 template <>
00813 class UniversalTersePrinter<char*> {
00814 public:
00815 static void Print(char* str, ::std::ostream* os) {
00816 UniversalTersePrinter<const char*>::Print(str, os);
00817 }
00818 };
00819
00820 #if GTEST_HAS_STD_WSTRING
00821 template <>
00822 class UniversalTersePrinter<const wchar_t*> {
00823 public:
00824 static void Print(const wchar_t* str, ::std::ostream* os) {
00825 if (str == NULL) {
00826 *os << "NULL";
00827 } else {
00828 UniversalPrint(::std::wstring(str), os);
00829 }
00830 }
00831 };
00832 #endif
00833
00834 template <>
00835 class UniversalTersePrinter<wchar_t*> {
00836 public:
00837 static void Print(wchar_t* str, ::std::ostream* os) {
00838 UniversalTersePrinter<const wchar_t*>::Print(str, os);
00839 }
00840 };
00841
00842 template <typename T>
00843 void UniversalTersePrint(const T& value, ::std::ostream* os) {
00844 UniversalTersePrinter<T>::Print(value, os);
00845 }
00846
00847
00848
00849
00850
00851 template <typename T>
00852 void UniversalPrint(const T& value, ::std::ostream* os) {
00853
00854
00855 typedef T T1;
00856 UniversalPrinter<T1>::Print(value, os);
00857 }
00858
00859 typedef ::std::vector<string> Strings;
00860
00861
00862
00863
00864
00865
00866
00867
00868 template <typename TupleT>
00869 struct TuplePolicy;
00870
00871 #if GTEST_HAS_TR1_TUPLE
00872 template <typename TupleT>
00873 struct TuplePolicy {
00874 typedef TupleT Tuple;
00875 static const size_t tuple_size = ::std::tr1::tuple_size<Tuple>::value;
00876
00877 template <size_t I>
00878 struct tuple_element : ::std::tr1::tuple_element<I, Tuple> {};
00879
00880 template <size_t I>
00881 static typename AddReference<
00882 const typename ::std::tr1::tuple_element<I, Tuple>::type>::type get(
00883 const Tuple& tuple) {
00884 return ::std::tr1::get<I>(tuple);
00885 }
00886 };
00887 template <typename TupleT>
00888 const size_t TuplePolicy<TupleT>::tuple_size;
00889 #endif // GTEST_HAS_TR1_TUPLE
00890
00891 #if GTEST_HAS_STD_TUPLE_
00892 template <typename... Types>
00893 struct TuplePolicy< ::std::tuple<Types...> > {
00894 typedef ::std::tuple<Types...> Tuple;
00895 static const size_t tuple_size = ::std::tuple_size<Tuple>::value;
00896
00897 template <size_t I>
00898 struct tuple_element : ::std::tuple_element<I, Tuple> {};
00899
00900 template <size_t I>
00901 static const typename ::std::tuple_element<I, Tuple>::type& get(
00902 const Tuple& tuple) {
00903 return ::std::get<I>(tuple);
00904 }
00905 };
00906 template <typename... Types>
00907 const size_t TuplePolicy< ::std::tuple<Types...> >::tuple_size;
00908 #endif // GTEST_HAS_STD_TUPLE_
00909
00910 #if GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_
00911
00912
00913
00914
00915
00916
00917
00918
00919 template <size_t N>
00920 struct TuplePrefixPrinter {
00921
00922 template <typename Tuple>
00923 static void PrintPrefixTo(const Tuple& t, ::std::ostream* os) {
00924 TuplePrefixPrinter<N - 1>::PrintPrefixTo(t, os);
00925 GTEST_INTENTIONAL_CONST_COND_PUSH_()
00926 if (N > 1) {
00927 GTEST_INTENTIONAL_CONST_COND_POP_()
00928 *os << ", ";
00929 }
00930 UniversalPrinter<
00931 typename TuplePolicy<Tuple>::template tuple_element<N - 1>::type>
00932 ::Print(TuplePolicy<Tuple>::template get<N - 1>(t), os);
00933 }
00934
00935
00936
00937 template <typename Tuple>
00938 static void TersePrintPrefixToStrings(const Tuple& t, Strings* strings) {
00939 TuplePrefixPrinter<N - 1>::TersePrintPrefixToStrings(t, strings);
00940 ::std::stringstream ss;
00941 UniversalTersePrint(TuplePolicy<Tuple>::template get<N - 1>(t), &ss);
00942 strings->push_back(ss.str());
00943 }
00944 };
00945
00946
00947 template <>
00948 struct TuplePrefixPrinter<0> {
00949 template <typename Tuple>
00950 static void PrintPrefixTo(const Tuple&, ::std::ostream*) {}
00951
00952 template <typename Tuple>
00953 static void TersePrintPrefixToStrings(const Tuple&, Strings*) {}
00954 };
00955
00956
00957
00958 template <typename Tuple>
00959 void PrintTupleTo(const Tuple& t, ::std::ostream* os) {
00960 *os << "(";
00961 TuplePrefixPrinter<TuplePolicy<Tuple>::tuple_size>::PrintPrefixTo(t, os);
00962 *os << ")";
00963 }
00964
00965
00966
00967
00968 template <typename Tuple>
00969 Strings UniversalTersePrintTupleFieldsToStrings(const Tuple& value) {
00970 Strings result;
00971 TuplePrefixPrinter<TuplePolicy<Tuple>::tuple_size>::
00972 TersePrintPrefixToStrings(value, &result);
00973 return result;
00974 }
00975 #endif // GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_
00976
00977 }
00978
00979 template <typename T>
00980 ::std::string PrintToString(const T& value) {
00981 ::std::stringstream ss;
00982 internal::UniversalTersePrinter<T>::Print(value, &ss);
00983 return ss.str();
00984 }
00985
00986 }
00987
00988
00989
00990
00991 #include "gtest/internal/custom/gtest-printers.h"
00992
00993 #endif // GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_