You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1197 lines
140 KiB
1197 lines
140 KiB
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
<title>LCOV - test.info - /usr/include/gtest/gtest-printers.h</title>
|
|
<link rel="stylesheet" type="text/css" href="../../../gcov.css">
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
<tr><td class="title">LCOV - code coverage report</td></tr>
|
|
<tr><td class="ruler"><img src="../../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
|
|
<tr>
|
|
<td width="100%">
|
|
<table cellpadding=1 border=0 width="100%">
|
|
<tr>
|
|
<td width="10%" class="headerItem">Current view:</td>
|
|
<td width="35%" class="headerValue"><a href="../../../index.html">top level</a> - <a href="index.html">usr/include/gtest</a> - gtest-printers.h<span style="font-size: 80%;"> (source / <a href="gtest-printers.h.func-sort-c.html">functions</a>)</span></td>
|
|
<td width="5%"></td>
|
|
<td width="15%"></td>
|
|
<td width="10%" class="headerCovTableHead">Hit</td>
|
|
<td width="10%" class="headerCovTableHead">Total</td>
|
|
<td width="15%" class="headerCovTableHead">Coverage</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="headerItem">Test:</td>
|
|
<td class="headerValue">test.info</td>
|
|
<td></td>
|
|
<td class="headerItem">Lines:</td>
|
|
<td class="headerCovTableEntry">0</td>
|
|
<td class="headerCovTableEntry">29</td>
|
|
<td class="headerCovTableEntryLo">0.0 %</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="headerItem">Date:</td>
|
|
<td class="headerValue">2022-06-07 00:30:42</td>
|
|
<td></td>
|
|
<td class="headerItem">Functions:</td>
|
|
<td class="headerCovTableEntry">0</td>
|
|
<td class="headerCovTableEntry">16</td>
|
|
<td class="headerCovTableEntryLo">0.0 %</td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td></td>
|
|
<td></td>
|
|
<td class="headerItem">Branches:</td>
|
|
<td class="headerCovTableEntry">0</td>
|
|
<td class="headerCovTableEntry">10</td>
|
|
<td class="headerCovTableEntryLo">0.0 %</td>
|
|
</tr>
|
|
<tr><td><img src="../../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr><td class="ruler"><img src="../../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
</table>
|
|
|
|
<table cellpadding=0 cellspacing=0 border=0>
|
|
<tr>
|
|
<td><br></td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<pre class="sourceHeading"> Branch data Line data Source code</pre>
|
|
<pre class="source">
|
|
<a name="1"><span class="lineNum"> 1 </span> : : // Copyright 2007, Google Inc.</a>
|
|
<a name="2"><span class="lineNum"> 2 </span> : : // All rights reserved.</a>
|
|
<a name="3"><span class="lineNum"> 3 </span> : : //</a>
|
|
<a name="4"><span class="lineNum"> 4 </span> : : // Redistribution and use in source and binary forms, with or without</a>
|
|
<a name="5"><span class="lineNum"> 5 </span> : : // modification, are permitted provided that the following conditions are</a>
|
|
<a name="6"><span class="lineNum"> 6 </span> : : // met:</a>
|
|
<a name="7"><span class="lineNum"> 7 </span> : : //</a>
|
|
<a name="8"><span class="lineNum"> 8 </span> : : // * Redistributions of source code must retain the above copyright</a>
|
|
<a name="9"><span class="lineNum"> 9 </span> : : // notice, this list of conditions and the following disclaimer.</a>
|
|
<a name="10"><span class="lineNum"> 10 </span> : : // * Redistributions in binary form must reproduce the above</a>
|
|
<a name="11"><span class="lineNum"> 11 </span> : : // copyright notice, this list of conditions and the following disclaimer</a>
|
|
<a name="12"><span class="lineNum"> 12 </span> : : // in the documentation and/or other materials provided with the</a>
|
|
<a name="13"><span class="lineNum"> 13 </span> : : // distribution.</a>
|
|
<a name="14"><span class="lineNum"> 14 </span> : : // * Neither the name of Google Inc. nor the names of its</a>
|
|
<a name="15"><span class="lineNum"> 15 </span> : : // contributors may be used to endorse or promote products derived from</a>
|
|
<a name="16"><span class="lineNum"> 16 </span> : : // this software without specific prior written permission.</a>
|
|
<a name="17"><span class="lineNum"> 17 </span> : : //</a>
|
|
<a name="18"><span class="lineNum"> 18 </span> : : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS</a>
|
|
<a name="19"><span class="lineNum"> 19 </span> : : // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT</a>
|
|
<a name="20"><span class="lineNum"> 20 </span> : : // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR</a>
|
|
<a name="21"><span class="lineNum"> 21 </span> : : // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT</a>
|
|
<a name="22"><span class="lineNum"> 22 </span> : : // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</a>
|
|
<a name="23"><span class="lineNum"> 23 </span> : : // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</a>
|
|
<a name="24"><span class="lineNum"> 24 </span> : : // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,</a>
|
|
<a name="25"><span class="lineNum"> 25 </span> : : // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY</a>
|
|
<a name="26"><span class="lineNum"> 26 </span> : : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT</a>
|
|
<a name="27"><span class="lineNum"> 27 </span> : : // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE</a>
|
|
<a name="28"><span class="lineNum"> 28 </span> : : // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</a>
|
|
<a name="29"><span class="lineNum"> 29 </span> : : </a>
|
|
<a name="30"><span class="lineNum"> 30 </span> : : </a>
|
|
<a name="31"><span class="lineNum"> 31 </span> : : // Google Test - The Google C++ Testing and Mocking Framework</a>
|
|
<a name="32"><span class="lineNum"> 32 </span> : : //</a>
|
|
<a name="33"><span class="lineNum"> 33 </span> : : // This file implements a universal value printer that can print a</a>
|
|
<a name="34"><span class="lineNum"> 34 </span> : : // value of any type T:</a>
|
|
<a name="35"><span class="lineNum"> 35 </span> : : //</a>
|
|
<a name="36"><span class="lineNum"> 36 </span> : : // void ::testing::internal::UniversalPrinter<T>::Print(value, ostream_ptr);</a>
|
|
<a name="37"><span class="lineNum"> 37 </span> : : //</a>
|
|
<a name="38"><span class="lineNum"> 38 </span> : : // A user can teach this function how to print a class type T by</a>
|
|
<a name="39"><span class="lineNum"> 39 </span> : : // defining either operator<<() or PrintTo() in the namespace that</a>
|
|
<a name="40"><span class="lineNum"> 40 </span> : : // defines T. More specifically, the FIRST defined function in the</a>
|
|
<a name="41"><span class="lineNum"> 41 </span> : : // following list will be used (assuming T is defined in namespace</a>
|
|
<a name="42"><span class="lineNum"> 42 </span> : : // foo):</a>
|
|
<a name="43"><span class="lineNum"> 43 </span> : : //</a>
|
|
<a name="44"><span class="lineNum"> 44 </span> : : // 1. foo::PrintTo(const T&, ostream*)</a>
|
|
<a name="45"><span class="lineNum"> 45 </span> : : // 2. operator<<(ostream&, const T&) defined in either foo or the</a>
|
|
<a name="46"><span class="lineNum"> 46 </span> : : // global namespace.</a>
|
|
<a name="47"><span class="lineNum"> 47 </span> : : //</a>
|
|
<a name="48"><span class="lineNum"> 48 </span> : : // However if T is an STL-style container then it is printed element-wise</a>
|
|
<a name="49"><span class="lineNum"> 49 </span> : : // unless foo::PrintTo(const T&, ostream*) is defined. Note that</a>
|
|
<a name="50"><span class="lineNum"> 50 </span> : : // operator<<() is ignored for container types.</a>
|
|
<a name="51"><span class="lineNum"> 51 </span> : : //</a>
|
|
<a name="52"><span class="lineNum"> 52 </span> : : // If none of the above is defined, it will print the debug string of</a>
|
|
<a name="53"><span class="lineNum"> 53 </span> : : // the value if it is a protocol buffer, or print the raw bytes in the</a>
|
|
<a name="54"><span class="lineNum"> 54 </span> : : // value otherwise.</a>
|
|
<a name="55"><span class="lineNum"> 55 </span> : : //</a>
|
|
<a name="56"><span class="lineNum"> 56 </span> : : // To aid debugging: when T is a reference type, the address of the</a>
|
|
<a name="57"><span class="lineNum"> 57 </span> : : // value is also printed; when T is a (const) char pointer, both the</a>
|
|
<a name="58"><span class="lineNum"> 58 </span> : : // pointer value and the NUL-terminated string it points to are</a>
|
|
<a name="59"><span class="lineNum"> 59 </span> : : // printed.</a>
|
|
<a name="60"><span class="lineNum"> 60 </span> : : //</a>
|
|
<a name="61"><span class="lineNum"> 61 </span> : : // We also provide some convenient wrappers:</a>
|
|
<a name="62"><span class="lineNum"> 62 </span> : : //</a>
|
|
<a name="63"><span class="lineNum"> 63 </span> : : // // Prints a value to a string. For a (const or not) char</a>
|
|
<a name="64"><span class="lineNum"> 64 </span> : : // // pointer, the NUL-terminated string (but not the pointer) is</a>
|
|
<a name="65"><span class="lineNum"> 65 </span> : : // // printed.</a>
|
|
<a name="66"><span class="lineNum"> 66 </span> : : // std::string ::testing::PrintToString(const T& value);</a>
|
|
<a name="67"><span class="lineNum"> 67 </span> : : //</a>
|
|
<a name="68"><span class="lineNum"> 68 </span> : : // // Prints a value tersely: for a reference type, the referenced</a>
|
|
<a name="69"><span class="lineNum"> 69 </span> : : // // value (but not the address) is printed; for a (const or not) char</a>
|
|
<a name="70"><span class="lineNum"> 70 </span> : : // // pointer, the NUL-terminated string (but not the pointer) is</a>
|
|
<a name="71"><span class="lineNum"> 71 </span> : : // // printed.</a>
|
|
<a name="72"><span class="lineNum"> 72 </span> : : // void ::testing::internal::UniversalTersePrint(const T& value, ostream*);</a>
|
|
<a name="73"><span class="lineNum"> 73 </span> : : //</a>
|
|
<a name="74"><span class="lineNum"> 74 </span> : : // // Prints value using the type inferred by the compiler. The difference</a>
|
|
<a name="75"><span class="lineNum"> 75 </span> : : // // from UniversalTersePrint() is that this function prints both the</a>
|
|
<a name="76"><span class="lineNum"> 76 </span> : : // // pointer and the NUL-terminated string for a (const or not) char pointer.</a>
|
|
<a name="77"><span class="lineNum"> 77 </span> : : // void ::testing::internal::UniversalPrint(const T& value, ostream*);</a>
|
|
<a name="78"><span class="lineNum"> 78 </span> : : //</a>
|
|
<a name="79"><span class="lineNum"> 79 </span> : : // // Prints the fields of a tuple tersely to a string vector, one</a>
|
|
<a name="80"><span class="lineNum"> 80 </span> : : // // element for each field. Tuple support must be enabled in</a>
|
|
<a name="81"><span class="lineNum"> 81 </span> : : // // gtest-port.h.</a>
|
|
<a name="82"><span class="lineNum"> 82 </span> : : // std::vector<string> UniversalTersePrintTupleFieldsToStrings(</a>
|
|
<a name="83"><span class="lineNum"> 83 </span> : : // const Tuple& value);</a>
|
|
<a name="84"><span class="lineNum"> 84 </span> : : //</a>
|
|
<a name="85"><span class="lineNum"> 85 </span> : : // Known limitation:</a>
|
|
<a name="86"><span class="lineNum"> 86 </span> : : //</a>
|
|
<a name="87"><span class="lineNum"> 87 </span> : : // The print primitives print the elements of an STL-style container</a>
|
|
<a name="88"><span class="lineNum"> 88 </span> : : // using the compiler-inferred type of *iter where iter is a</a>
|
|
<a name="89"><span class="lineNum"> 89 </span> : : // const_iterator of the container. When const_iterator is an input</a>
|
|
<a name="90"><span class="lineNum"> 90 </span> : : // iterator but not a forward iterator, this inferred type may not</a>
|
|
<a name="91"><span class="lineNum"> 91 </span> : : // match value_type, and the print output may be incorrect. In</a>
|
|
<a name="92"><span class="lineNum"> 92 </span> : : // practice, this is rarely a problem as for most containers</a>
|
|
<a name="93"><span class="lineNum"> 93 </span> : : // const_iterator is a forward iterator. We'll fix this if there's an</a>
|
|
<a name="94"><span class="lineNum"> 94 </span> : : // actual need for it. Note that this fix cannot rely on value_type</a>
|
|
<a name="95"><span class="lineNum"> 95 </span> : : // being defined as many user-defined container types don't have</a>
|
|
<a name="96"><span class="lineNum"> 96 </span> : : // value_type.</a>
|
|
<a name="97"><span class="lineNum"> 97 </span> : : </a>
|
|
<a name="98"><span class="lineNum"> 98 </span> : : // GOOGLETEST_CM0001 DO NOT DELETE</a>
|
|
<a name="99"><span class="lineNum"> 99 </span> : : </a>
|
|
<a name="100"><span class="lineNum"> 100 </span> : : #ifndef GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_</a>
|
|
<a name="101"><span class="lineNum"> 101 </span> : : #define GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_</a>
|
|
<a name="102"><span class="lineNum"> 102 </span> : : </a>
|
|
<a name="103"><span class="lineNum"> 103 </span> : : #include <ostream> // NOLINT</a>
|
|
<a name="104"><span class="lineNum"> 104 </span> : : #include <sstream></a>
|
|
<a name="105"><span class="lineNum"> 105 </span> : : #include <string></a>
|
|
<a name="106"><span class="lineNum"> 106 </span> : : #include <utility></a>
|
|
<a name="107"><span class="lineNum"> 107 </span> : : #include <vector></a>
|
|
<a name="108"><span class="lineNum"> 108 </span> : : #include "gtest/internal/gtest-port.h"</a>
|
|
<a name="109"><span class="lineNum"> 109 </span> : : #include "gtest/internal/gtest-internal.h"</a>
|
|
<a name="110"><span class="lineNum"> 110 </span> : : </a>
|
|
<a name="111"><span class="lineNum"> 111 </span> : : #if GTEST_HAS_STD_TUPLE_</a>
|
|
<a name="112"><span class="lineNum"> 112 </span> : : # include <tuple></a>
|
|
<a name="113"><span class="lineNum"> 113 </span> : : #endif</a>
|
|
<a name="114"><span class="lineNum"> 114 </span> : : </a>
|
|
<a name="115"><span class="lineNum"> 115 </span> : : #if GTEST_HAS_ABSL</a>
|
|
<a name="116"><span class="lineNum"> 116 </span> : : #include "absl/strings/string_view.h"</a>
|
|
<a name="117"><span class="lineNum"> 117 </span> : : #include "absl/types/optional.h"</a>
|
|
<a name="118"><span class="lineNum"> 118 </span> : : #include "absl/types/variant.h"</a>
|
|
<a name="119"><span class="lineNum"> 119 </span> : : #endif // GTEST_HAS_ABSL</a>
|
|
<a name="120"><span class="lineNum"> 120 </span> : : </a>
|
|
<a name="121"><span class="lineNum"> 121 </span> : : namespace testing {</a>
|
|
<a name="122"><span class="lineNum"> 122 </span> : : </a>
|
|
<a name="123"><span class="lineNum"> 123 </span> : : // Definitions in the 'internal' and 'internal2' name spaces are</a>
|
|
<a name="124"><span class="lineNum"> 124 </span> : : // subject to change without notice. DO NOT USE THEM IN USER CODE!</a>
|
|
<a name="125"><span class="lineNum"> 125 </span> : : namespace internal2 {</a>
|
|
<a name="126"><span class="lineNum"> 126 </span> : : </a>
|
|
<a name="127"><span class="lineNum"> 127 </span> : : // Prints the given number of bytes in the given object to the given</a>
|
|
<a name="128"><span class="lineNum"> 128 </span> : : // ostream.</a>
|
|
<a name="129"><span class="lineNum"> 129 </span> : : GTEST_API_ void PrintBytesInObjectTo(const unsigned char* obj_bytes,</a>
|
|
<a name="130"><span class="lineNum"> 130 </span> : : size_t count,</a>
|
|
<a name="131"><span class="lineNum"> 131 </span> : : ::std::ostream* os);</a>
|
|
<a name="132"><span class="lineNum"> 132 </span> : : </a>
|
|
<a name="133"><span class="lineNum"> 133 </span> : : // For selecting which printer to use when a given type has neither <<</a>
|
|
<a name="134"><span class="lineNum"> 134 </span> : : // nor PrintTo().</a>
|
|
<a name="135"><span class="lineNum"> 135 </span> : : enum TypeKind {</a>
|
|
<a name="136"><span class="lineNum"> 136 </span> : : kProtobuf, // a protobuf type</a>
|
|
<a name="137"><span class="lineNum"> 137 </span> : : kConvertibleToInteger, // a type implicitly convertible to BiggestInt</a>
|
|
<a name="138"><span class="lineNum"> 138 </span> : : // (e.g. a named or unnamed enum type)</a>
|
|
<a name="139"><span class="lineNum"> 139 </span> : : #if GTEST_HAS_ABSL</a>
|
|
<a name="140"><span class="lineNum"> 140 </span> : : kConvertibleToStringView, // a type implicitly convertible to</a>
|
|
<a name="141"><span class="lineNum"> 141 </span> : : // absl::string_view</a>
|
|
<a name="142"><span class="lineNum"> 142 </span> : : #endif</a>
|
|
<a name="143"><span class="lineNum"> 143 </span> : : kOtherType // anything else</a>
|
|
<a name="144"><span class="lineNum"> 144 </span> : : };</a>
|
|
<a name="145"><span class="lineNum"> 145 </span> : : </a>
|
|
<a name="146"><span class="lineNum"> 146 </span> : : // TypeWithoutFormatter<T, kTypeKind>::PrintValue(value, os) is called</a>
|
|
<a name="147"><span class="lineNum"> 147 </span> : : // by the universal printer to print a value of type T when neither</a>
|
|
<a name="148"><span class="lineNum"> 148 </span> : : // operator<< nor PrintTo() is defined for T, where kTypeKind is the</a>
|
|
<a name="149"><span class="lineNum"> 149 </span> : : // "kind" of T as defined by enum TypeKind.</a>
|
|
<a name="150"><span class="lineNum"> 150 </span> : : template <typename T, TypeKind kTypeKind></a>
|
|
<a name="151"><span class="lineNum"> 151 </span> : : class TypeWithoutFormatter {</a>
|
|
<a name="152"><span class="lineNum"> 152 </span> : : public:</a>
|
|
<a name="153"><span class="lineNum"> 153 </span> : : // This default version is called when kTypeKind is kOtherType.</a>
|
|
<a name="154"><span class="lineNum"> 154 </span> : : static void PrintValue(const T& value, ::std::ostream* os) {</a>
|
|
<a name="155"><span class="lineNum"> 155 </span> : : PrintBytesInObjectTo(static_cast<const unsigned char*>(</a>
|
|
<a name="156"><span class="lineNum"> 156 </span> : : reinterpret_cast<const void*>(&value)),</a>
|
|
<a name="157"><span class="lineNum"> 157 </span> : : sizeof(value), os);</a>
|
|
<a name="158"><span class="lineNum"> 158 </span> : : }</a>
|
|
<a name="159"><span class="lineNum"> 159 </span> : : };</a>
|
|
<a name="160"><span class="lineNum"> 160 </span> : : </a>
|
|
<a name="161"><span class="lineNum"> 161 </span> : : // We print a protobuf using its ShortDebugString() when the string</a>
|
|
<a name="162"><span class="lineNum"> 162 </span> : : // doesn't exceed this many characters; otherwise we print it using</a>
|
|
<a name="163"><span class="lineNum"> 163 </span> : : // DebugString() for better readability.</a>
|
|
<a name="164"><span class="lineNum"> 164 </span> : : const size_t kProtobufOneLinerMaxLength = 50;</a>
|
|
<a name="165"><span class="lineNum"> 165 </span> : : </a>
|
|
<a name="166"><span class="lineNum"> 166 </span> : : template <typename T></a>
|
|
<a name="167"><span class="lineNum"> 167 </span> : : class TypeWithoutFormatter<T, kProtobuf> {</a>
|
|
<a name="168"><span class="lineNum"> 168 </span> : : public:</a>
|
|
<a name="169"><span class="lineNum"> 169 </span> : : static void PrintValue(const T& value, ::std::ostream* os) {</a>
|
|
<a name="170"><span class="lineNum"> 170 </span> : : std::string pretty_str = value.ShortDebugString();</a>
|
|
<a name="171"><span class="lineNum"> 171 </span> : : if (pretty_str.length() > kProtobufOneLinerMaxLength) {</a>
|
|
<a name="172"><span class="lineNum"> 172 </span> : : pretty_str = "\n" + value.DebugString();</a>
|
|
<a name="173"><span class="lineNum"> 173 </span> : : }</a>
|
|
<a name="174"><span class="lineNum"> 174 </span> : : *os << ("<" + pretty_str + ">");</a>
|
|
<a name="175"><span class="lineNum"> 175 </span> : : }</a>
|
|
<a name="176"><span class="lineNum"> 176 </span> : : };</a>
|
|
<a name="177"><span class="lineNum"> 177 </span> : : </a>
|
|
<a name="178"><span class="lineNum"> 178 </span> : : template <typename T></a>
|
|
<a name="179"><span class="lineNum"> 179 </span> : : class TypeWithoutFormatter<T, kConvertibleToInteger> {</a>
|
|
<a name="180"><span class="lineNum"> 180 </span> : : public:</a>
|
|
<a name="181"><span class="lineNum"> 181 </span> : : // Since T has no << operator or PrintTo() but can be implicitly</a>
|
|
<a name="182"><span class="lineNum"> 182 </span> : : // converted to BiggestInt, we print it as a BiggestInt.</a>
|
|
<a name="183"><span class="lineNum"> 183 </span> : : //</a>
|
|
<a name="184"><span class="lineNum"> 184 </span> : : // Most likely T is an enum type (either named or unnamed), in which</a>
|
|
<a name="185"><span class="lineNum"> 185 </span> : : // case printing it as an integer is the desired behavior. In case</a>
|
|
<a name="186"><span class="lineNum"> 186 </span> : : // T is not an enum, printing it as an integer is the best we can do</a>
|
|
<a name="187"><span class="lineNum"> 187 </span> : : // given that it has no user-defined printer.</a>
|
|
<a name="188"><span class="lineNum"> 188 </span> : : static void PrintValue(const T& value, ::std::ostream* os) {</a>
|
|
<a name="189"><span class="lineNum"> 189 </span> : : const internal::BiggestInt kBigInt = value;</a>
|
|
<a name="190"><span class="lineNum"> 190 </span> : : *os << kBigInt;</a>
|
|
<a name="191"><span class="lineNum"> 191 </span> : : }</a>
|
|
<a name="192"><span class="lineNum"> 192 </span> : : };</a>
|
|
<a name="193"><span class="lineNum"> 193 </span> : : </a>
|
|
<a name="194"><span class="lineNum"> 194 </span> : : #if GTEST_HAS_ABSL</a>
|
|
<a name="195"><span class="lineNum"> 195 </span> : : template <typename T></a>
|
|
<a name="196"><span class="lineNum"> 196 </span> : : class TypeWithoutFormatter<T, kConvertibleToStringView> {</a>
|
|
<a name="197"><span class="lineNum"> 197 </span> : : public:</a>
|
|
<a name="198"><span class="lineNum"> 198 </span> : : // Since T has neither operator<< nor PrintTo() but can be implicitly</a>
|
|
<a name="199"><span class="lineNum"> 199 </span> : : // converted to absl::string_view, we print it as a absl::string_view.</a>
|
|
<a name="200"><span class="lineNum"> 200 </span> : : //</a>
|
|
<a name="201"><span class="lineNum"> 201 </span> : : // Note: the implementation is further below, as it depends on</a>
|
|
<a name="202"><span class="lineNum"> 202 </span> : : // internal::PrintTo symbol which is defined later in the file.</a>
|
|
<a name="203"><span class="lineNum"> 203 </span> : : static void PrintValue(const T& value, ::std::ostream* os);</a>
|
|
<a name="204"><span class="lineNum"> 204 </span> : : };</a>
|
|
<a name="205"><span class="lineNum"> 205 </span> : : #endif</a>
|
|
<a name="206"><span class="lineNum"> 206 </span> : : </a>
|
|
<a name="207"><span class="lineNum"> 207 </span> : : // Prints the given value to the given ostream. If the value is a</a>
|
|
<a name="208"><span class="lineNum"> 208 </span> : : // protocol message, its debug string is printed; if it's an enum or</a>
|
|
<a name="209"><span class="lineNum"> 209 </span> : : // of a type implicitly convertible to BiggestInt, it's printed as an</a>
|
|
<a name="210"><span class="lineNum"> 210 </span> : : // integer; otherwise the bytes in the value are printed. This is</a>
|
|
<a name="211"><span class="lineNum"> 211 </span> : : // what UniversalPrinter<T>::Print() does when it knows nothing about</a>
|
|
<a name="212"><span class="lineNum"> 212 </span> : : // type T and T has neither << operator nor PrintTo().</a>
|
|
<a name="213"><span class="lineNum"> 213 </span> : : //</a>
|
|
<a name="214"><span class="lineNum"> 214 </span> : : // A user can override this behavior for a class type Foo by defining</a>
|
|
<a name="215"><span class="lineNum"> 215 </span> : : // a << operator in the namespace where Foo is defined.</a>
|
|
<a name="216"><span class="lineNum"> 216 </span> : : //</a>
|
|
<a name="217"><span class="lineNum"> 217 </span> : : // We put this operator in namespace 'internal2' instead of 'internal'</a>
|
|
<a name="218"><span class="lineNum"> 218 </span> : : // to simplify the implementation, as much code in 'internal' needs to</a>
|
|
<a name="219"><span class="lineNum"> 219 </span> : : // use << in STL, which would conflict with our own << were it defined</a>
|
|
<a name="220"><span class="lineNum"> 220 </span> : : // in 'internal'.</a>
|
|
<a name="221"><span class="lineNum"> 221 </span> : : //</a>
|
|
<a name="222"><span class="lineNum"> 222 </span> : : // Note that this operator<< takes a generic std::basic_ostream<Char,</a>
|
|
<a name="223"><span class="lineNum"> 223 </span> : : // CharTraits> type instead of the more restricted std::ostream. If</a>
|
|
<a name="224"><span class="lineNum"> 224 </span> : : // we define it to take an std::ostream instead, we'll get an</a>
|
|
<a name="225"><span class="lineNum"> 225 </span> : : // "ambiguous overloads" compiler error when trying to print a type</a>
|
|
<a name="226"><span class="lineNum"> 226 </span> : : // Foo that supports streaming to std::basic_ostream<Char,</a>
|
|
<a name="227"><span class="lineNum"> 227 </span> : : // CharTraits>, as the compiler cannot tell whether</a>
|
|
<a name="228"><span class="lineNum"> 228 </span> : : // operator<<(std::ostream&, const T&) or</a>
|
|
<a name="229"><span class="lineNum"> 229 </span> : : // operator<<(std::basic_stream<Char, CharTraits>, const Foo&) is more</a>
|
|
<a name="230"><span class="lineNum"> 230 </span> : : // specific.</a>
|
|
<a name="231"><span class="lineNum"> 231 </span> : : template <typename Char, typename CharTraits, typename T></a>
|
|
<a name="232"><span class="lineNum"> 232 </span> : : ::std::basic_ostream<Char, CharTraits>& operator<<(</a>
|
|
<a name="233"><span class="lineNum"> 233 </span> : : ::std::basic_ostream<Char, CharTraits>& os, const T& x) {</a>
|
|
<a name="234"><span class="lineNum"> 234 </span> : : TypeWithoutFormatter<T, (internal::IsAProtocolMessage<T>::value</a>
|
|
<a name="235"><span class="lineNum"> 235 </span> : : ? kProtobuf</a>
|
|
<a name="236"><span class="lineNum"> 236 </span> : : : internal::ImplicitlyConvertible<</a>
|
|
<a name="237"><span class="lineNum"> 237 </span> : : const T&, internal::BiggestInt>::value</a>
|
|
<a name="238"><span class="lineNum"> 238 </span> : : ? kConvertibleToInteger</a>
|
|
<a name="239"><span class="lineNum"> 239 </span> : : :</a>
|
|
<a name="240"><span class="lineNum"> 240 </span> : : #if GTEST_HAS_ABSL</a>
|
|
<a name="241"><span class="lineNum"> 241 </span> : : internal::ImplicitlyConvertible<</a>
|
|
<a name="242"><span class="lineNum"> 242 </span> : : const T&, absl::string_view>::value</a>
|
|
<a name="243"><span class="lineNum"> 243 </span> : : ? kConvertibleToStringView</a>
|
|
<a name="244"><span class="lineNum"> 244 </span> : : :</a>
|
|
<a name="245"><span class="lineNum"> 245 </span> : : #endif</a>
|
|
<a name="246"><span class="lineNum"> 246 </span> : : kOtherType)>::PrintValue(x, &os);</a>
|
|
<a name="247"><span class="lineNum"> 247 </span> : : return os;</a>
|
|
<a name="248"><span class="lineNum"> 248 </span> : : }</a>
|
|
<a name="249"><span class="lineNum"> 249 </span> : : </a>
|
|
<a name="250"><span class="lineNum"> 250 </span> : : } // namespace internal2</a>
|
|
<a name="251"><span class="lineNum"> 251 </span> : : } // namespace testing</a>
|
|
<a name="252"><span class="lineNum"> 252 </span> : : </a>
|
|
<a name="253"><span class="lineNum"> 253 </span> : : // This namespace MUST NOT BE NESTED IN ::testing, or the name look-up</a>
|
|
<a name="254"><span class="lineNum"> 254 </span> : : // magic needed for implementing UniversalPrinter won't work.</a>
|
|
<a name="255"><span class="lineNum"> 255 </span> : : namespace testing_internal {</a>
|
|
<a name="256"><span class="lineNum"> 256 </span> : : </a>
|
|
<a name="257"><span class="lineNum"> 257 </span> : : // Used to print a value that is not an STL-style container when the</a>
|
|
<a name="258"><span class="lineNum"> 258 </span> : : // user doesn't define PrintTo() for it.</a>
|
|
<a name="259"><span class="lineNum"> 259 </span> : : template <typename T></a>
|
|
<a name="260"><span class="lineNum"> 260 </span> :<span class="lineNoCov"> 0 : void DefaultPrintNonContainerTo(const T& value, ::std::ostream* os) {</span></a>
|
|
<a name="261"><span class="lineNum"> 261 </span> : : // With the following statement, during unqualified name lookup,</a>
|
|
<a name="262"><span class="lineNum"> 262 </span> : : // testing::internal2::operator<< appears as if it was declared in</a>
|
|
<a name="263"><span class="lineNum"> 263 </span> : : // the nearest enclosing namespace that contains both</a>
|
|
<a name="264"><span class="lineNum"> 264 </span> : : // ::testing_internal and ::testing::internal2, i.e. the global</a>
|
|
<a name="265"><span class="lineNum"> 265 </span> : : // namespace. For more details, refer to the C++ Standard section</a>
|
|
<a name="266"><span class="lineNum"> 266 </span> : : // 7.3.4-1 [namespace.udir]. This allows us to fall back onto</a>
|
|
<a name="267"><span class="lineNum"> 267 </span> : : // testing::internal2::operator<< in case T doesn't come with a <<</a>
|
|
<a name="268"><span class="lineNum"> 268 </span> : : // operator.</a>
|
|
<a name="269"><span class="lineNum"> 269 </span> : : //</a>
|
|
<a name="270"><span class="lineNum"> 270 </span> : : // We cannot write 'using ::testing::internal2::operator<<;', which</a>
|
|
<a name="271"><span class="lineNum"> 271 </span> : : // gcc 3.3 fails to compile due to a compiler bug.</a>
|
|
<a name="272"><span class="lineNum"> 272 </span> : : using namespace ::testing::internal2; // NOLINT</a>
|
|
<a name="273"><span class="lineNum"> 273 </span> : : </a>
|
|
<a name="274"><span class="lineNum"> 274 </span> : : // Assuming T is defined in namespace foo, in the next statement,</a>
|
|
<a name="275"><span class="lineNum"> 275 </span> : : // the compiler will consider all of:</a>
|
|
<a name="276"><span class="lineNum"> 276 </span> : : //</a>
|
|
<a name="277"><span class="lineNum"> 277 </span> : : // 1. foo::operator<< (thanks to Koenig look-up),</a>
|
|
<a name="278"><span class="lineNum"> 278 </span> : : // 2. ::operator<< (as the current namespace is enclosed in ::),</a>
|
|
<a name="279"><span class="lineNum"> 279 </span> : : // 3. testing::internal2::operator<< (thanks to the using statement above).</a>
|
|
<a name="280"><span class="lineNum"> 280 </span> : : //</a>
|
|
<a name="281"><span class="lineNum"> 281 </span> : : // The operator<< whose type matches T best will be picked.</a>
|
|
<a name="282"><span class="lineNum"> 282 </span> : : //</a>
|
|
<a name="283"><span class="lineNum"> 283 </span> : : // We deliberately allow #2 to be a candidate, as sometimes it's</a>
|
|
<a name="284"><span class="lineNum"> 284 </span> : : // impossible to define #1 (e.g. when foo is ::std, defining</a>
|
|
<a name="285"><span class="lineNum"> 285 </span> : : // anything in it is undefined behavior unless you are a compiler</a>
|
|
<a name="286"><span class="lineNum"> 286 </span> : : // vendor.).</a>
|
|
<a name="287"><span class="lineNum"> 287 </span> :<span class="lineNoCov"> 0 : *os << value;</span></a>
|
|
<a name="288"><span class="lineNum"> 288 </span> :<span class="lineNoCov"> 0 : }</span></a>
|
|
<a name="289"><span class="lineNum"> 289 </span> : : </a>
|
|
<a name="290"><span class="lineNum"> 290 </span> : : } // namespace testing_internal</a>
|
|
<a name="291"><span class="lineNum"> 291 </span> : : </a>
|
|
<a name="292"><span class="lineNum"> 292 </span> : : namespace testing {</a>
|
|
<a name="293"><span class="lineNum"> 293 </span> : : namespace internal {</a>
|
|
<a name="294"><span class="lineNum"> 294 </span> : : </a>
|
|
<a name="295"><span class="lineNum"> 295 </span> : : // FormatForComparison<ToPrint, OtherOperand>::Format(value) formats a</a>
|
|
<a name="296"><span class="lineNum"> 296 </span> : : // value of type ToPrint that is an operand of a comparison assertion</a>
|
|
<a name="297"><span class="lineNum"> 297 </span> : : // (e.g. ASSERT_EQ). OtherOperand is the type of the other operand in</a>
|
|
<a name="298"><span class="lineNum"> 298 </span> : : // the comparison, and is used to help determine the best way to</a>
|
|
<a name="299"><span class="lineNum"> 299 </span> : : // format the value. In particular, when the value is a C string</a>
|
|
<a name="300"><span class="lineNum"> 300 </span> : : // (char pointer) and the other operand is an STL string object, we</a>
|
|
<a name="301"><span class="lineNum"> 301 </span> : : // want to format the C string as a string, since we know it is</a>
|
|
<a name="302"><span class="lineNum"> 302 </span> : : // compared by value with the string object. If the value is a char</a>
|
|
<a name="303"><span class="lineNum"> 303 </span> : : // pointer but the other operand is not an STL string object, we don't</a>
|
|
<a name="304"><span class="lineNum"> 304 </span> : : // know whether the pointer is supposed to point to a NUL-terminated</a>
|
|
<a name="305"><span class="lineNum"> 305 </span> : : // string, and thus want to print it as a pointer to be safe.</a>
|
|
<a name="306"><span class="lineNum"> 306 </span> : : //</a>
|
|
<a name="307"><span class="lineNum"> 307 </span> : : // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.</a>
|
|
<a name="308"><span class="lineNum"> 308 </span> : : </a>
|
|
<a name="309"><span class="lineNum"> 309 </span> : : // The default case.</a>
|
|
<a name="310"><span class="lineNum"> 310 </span> : : template <typename ToPrint, typename OtherOperand></a>
|
|
<a name="311"><span class="lineNum"> 311 </span> : : class FormatForComparison {</a>
|
|
<a name="312"><span class="lineNum"> 312 </span> : : public:</a>
|
|
<a name="313"><span class="lineNum"> 313 </span> :<span class="lineNoCov"> 0 : static ::std::string Format(const ToPrint& value) {</span></a>
|
|
<a name="314"><span class="lineNum"> 314 </span> :<span class="lineNoCov"> 0 : return ::testing::PrintToString(value);</span></a>
|
|
<a name="315"><span class="lineNum"> 315 </span> : : }</a>
|
|
<a name="316"><span class="lineNum"> 316 </span> : : };</a>
|
|
<a name="317"><span class="lineNum"> 317 </span> : : </a>
|
|
<a name="318"><span class="lineNum"> 318 </span> : : // Array.</a>
|
|
<a name="319"><span class="lineNum"> 319 </span> : : template <typename ToPrint, size_t N, typename OtherOperand></a>
|
|
<a name="320"><span class="lineNum"> 320 </span> : : class FormatForComparison<ToPrint[N], OtherOperand> {</a>
|
|
<a name="321"><span class="lineNum"> 321 </span> : : public:</a>
|
|
<a name="322"><span class="lineNum"> 322 </span> : : static ::std::string Format(const ToPrint* value) {</a>
|
|
<a name="323"><span class="lineNum"> 323 </span> : : return FormatForComparison<const ToPrint*, OtherOperand>::Format(value);</a>
|
|
<a name="324"><span class="lineNum"> 324 </span> : : }</a>
|
|
<a name="325"><span class="lineNum"> 325 </span> : : };</a>
|
|
<a name="326"><span class="lineNum"> 326 </span> : : </a>
|
|
<a name="327"><span class="lineNum"> 327 </span> : : // By default, print C string as pointers to be safe, as we don't know</a>
|
|
<a name="328"><span class="lineNum"> 328 </span> : : // whether they actually point to a NUL-terminated string.</a>
|
|
<a name="329"><span class="lineNum"> 329 </span> : : </a>
|
|
<a name="330"><span class="lineNum"> 330 </span> : : #define GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(CharType) \</a>
|
|
<a name="331"><span class="lineNum"> 331 </span> : : template <typename OtherOperand> \</a>
|
|
<a name="332"><span class="lineNum"> 332 </span> : : class FormatForComparison<CharType*, OtherOperand> { \</a>
|
|
<a name="333"><span class="lineNum"> 333 </span> : : public: \</a>
|
|
<a name="334"><span class="lineNum"> 334 </span> : : static ::std::string Format(CharType* value) { \</a>
|
|
<a name="335"><span class="lineNum"> 335 </span> : : return ::testing::PrintToString(static_cast<const void*>(value)); \</a>
|
|
<a name="336"><span class="lineNum"> 336 </span> : : } \</a>
|
|
<a name="337"><span class="lineNum"> 337 </span> : : }</a>
|
|
<a name="338"><span class="lineNum"> 338 </span> : : </a>
|
|
<a name="339"><span class="lineNum"> 339 </span> : : GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(char);</a>
|
|
<a name="340"><span class="lineNum"> 340 </span> : : GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const char);</a>
|
|
<a name="341"><span class="lineNum"> 341 </span> : : GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(wchar_t);</a>
|
|
<a name="342"><span class="lineNum"> 342 </span> : : GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const wchar_t);</a>
|
|
<a name="343"><span class="lineNum"> 343 </span> : : </a>
|
|
<a name="344"><span class="lineNum"> 344 </span> : : #undef GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_</a>
|
|
<a name="345"><span class="lineNum"> 345 </span> : : </a>
|
|
<a name="346"><span class="lineNum"> 346 </span> : : // If a C string is compared with an STL string object, we know it's meant</a>
|
|
<a name="347"><span class="lineNum"> 347 </span> : : // to point to a NUL-terminated string, and thus can print it as a string.</a>
|
|
<a name="348"><span class="lineNum"> 348 </span> : : </a>
|
|
<a name="349"><span class="lineNum"> 349 </span> : : #define GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(CharType, OtherStringType) \</a>
|
|
<a name="350"><span class="lineNum"> 350 </span> : : template <> \</a>
|
|
<a name="351"><span class="lineNum"> 351 </span> : : class FormatForComparison<CharType*, OtherStringType> { \</a>
|
|
<a name="352"><span class="lineNum"> 352 </span> : : public: \</a>
|
|
<a name="353"><span class="lineNum"> 353 </span> : : static ::std::string Format(CharType* value) { \</a>
|
|
<a name="354"><span class="lineNum"> 354 </span> : : return ::testing::PrintToString(value); \</a>
|
|
<a name="355"><span class="lineNum"> 355 </span> : : } \</a>
|
|
<a name="356"><span class="lineNum"> 356 </span> : : }</a>
|
|
<a name="357"><span class="lineNum"> 357 </span> : : </a>
|
|
<a name="358"><span class="lineNum"> 358 </span> : : GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char, ::std::string);</a>
|
|
<a name="359"><span class="lineNum"> 359 </span> : : GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char, ::std::string);</a>
|
|
<a name="360"><span class="lineNum"> 360 </span> : : </a>
|
|
<a name="361"><span class="lineNum"> 361 </span> : : #if GTEST_HAS_GLOBAL_STRING</a>
|
|
<a name="362"><span class="lineNum"> 362 </span> : : GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char, ::string);</a>
|
|
<a name="363"><span class="lineNum"> 363 </span> : : GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char, ::string);</a>
|
|
<a name="364"><span class="lineNum"> 364 </span> : : #endif</a>
|
|
<a name="365"><span class="lineNum"> 365 </span> : : </a>
|
|
<a name="366"><span class="lineNum"> 366 </span> : : #if GTEST_HAS_GLOBAL_WSTRING</a>
|
|
<a name="367"><span class="lineNum"> 367 </span> : : GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(wchar_t, ::wstring);</a>
|
|
<a name="368"><span class="lineNum"> 368 </span> : : GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const wchar_t, ::wstring);</a>
|
|
<a name="369"><span class="lineNum"> 369 </span> : : #endif</a>
|
|
<a name="370"><span class="lineNum"> 370 </span> : : </a>
|
|
<a name="371"><span class="lineNum"> 371 </span> : : #if GTEST_HAS_STD_WSTRING</a>
|
|
<a name="372"><span class="lineNum"> 372 </span> : : GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(wchar_t, ::std::wstring);</a>
|
|
<a name="373"><span class="lineNum"> 373 </span> : : GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const wchar_t, ::std::wstring);</a>
|
|
<a name="374"><span class="lineNum"> 374 </span> : : #endif</a>
|
|
<a name="375"><span class="lineNum"> 375 </span> : : </a>
|
|
<a name="376"><span class="lineNum"> 376 </span> : : #undef GTEST_IMPL_FORMAT_C_STRING_AS_STRING_</a>
|
|
<a name="377"><span class="lineNum"> 377 </span> : : </a>
|
|
<a name="378"><span class="lineNum"> 378 </span> : : // Formats a comparison assertion (e.g. ASSERT_EQ, EXPECT_LT, and etc)</a>
|
|
<a name="379"><span class="lineNum"> 379 </span> : : // operand to be used in a failure message. The type (but not value)</a>
|
|
<a name="380"><span class="lineNum"> 380 </span> : : // of the other operand may affect the format. This allows us to</a>
|
|
<a name="381"><span class="lineNum"> 381 </span> : : // print a char* as a raw pointer when it is compared against another</a>
|
|
<a name="382"><span class="lineNum"> 382 </span> : : // char* or void*, and print it as a C string when it is compared</a>
|
|
<a name="383"><span class="lineNum"> 383 </span> : : // against an std::string object, for example.</a>
|
|
<a name="384"><span class="lineNum"> 384 </span> : : //</a>
|
|
<a name="385"><span class="lineNum"> 385 </span> : : // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.</a>
|
|
<a name="386"><span class="lineNum"> 386 </span> : : template <typename T1, typename T2></a>
|
|
<a name="387"><span class="lineNum"> 387 </span> :<span class="lineNoCov"> 0 : std::string FormatForComparisonFailureMessage(</span></a>
|
|
<a name="388"><span class="lineNum"> 388 </span> : : const T1& value, const T2& /* other_operand */) {</a>
|
|
<a name="389"><span class="lineNum"> 389 </span> :<span class="lineNoCov"> 0 : return FormatForComparison<T1, T2>::Format(value);</span></a>
|
|
<a name="390"><span class="lineNum"> 390 </span> : : }</a>
|
|
<a name="391"><span class="lineNum"> 391 </span> : : </a>
|
|
<a name="392"><span class="lineNum"> 392 </span> : : // UniversalPrinter<T>::Print(value, ostream_ptr) prints the given</a>
|
|
<a name="393"><span class="lineNum"> 393 </span> : : // value to the given ostream. The caller must ensure that</a>
|
|
<a name="394"><span class="lineNum"> 394 </span> : : // 'ostream_ptr' is not NULL, or the behavior is undefined.</a>
|
|
<a name="395"><span class="lineNum"> 395 </span> : : //</a>
|
|
<a name="396"><span class="lineNum"> 396 </span> : : // We define UniversalPrinter as a class template (as opposed to a</a>
|
|
<a name="397"><span class="lineNum"> 397 </span> : : // function template), as we need to partially specialize it for</a>
|
|
<a name="398"><span class="lineNum"> 398 </span> : : // reference types, which cannot be done with function templates.</a>
|
|
<a name="399"><span class="lineNum"> 399 </span> : : template <typename T></a>
|
|
<a name="400"><span class="lineNum"> 400 </span> : : class UniversalPrinter;</a>
|
|
<a name="401"><span class="lineNum"> 401 </span> : : </a>
|
|
<a name="402"><span class="lineNum"> 402 </span> : : template <typename T></a>
|
|
<a name="403"><span class="lineNum"> 403 </span> : : void UniversalPrint(const T& value, ::std::ostream* os);</a>
|
|
<a name="404"><span class="lineNum"> 404 </span> : : </a>
|
|
<a name="405"><span class="lineNum"> 405 </span> : : enum DefaultPrinterType {</a>
|
|
<a name="406"><span class="lineNum"> 406 </span> : : kPrintContainer,</a>
|
|
<a name="407"><span class="lineNum"> 407 </span> : : kPrintPointer,</a>
|
|
<a name="408"><span class="lineNum"> 408 </span> : : kPrintFunctionPointer,</a>
|
|
<a name="409"><span class="lineNum"> 409 </span> : : kPrintOther,</a>
|
|
<a name="410"><span class="lineNum"> 410 </span> : : };</a>
|
|
<a name="411"><span class="lineNum"> 411 </span> : : template <DefaultPrinterType type> struct WrapPrinterType {};</a>
|
|
<a name="412"><span class="lineNum"> 412 </span> : : </a>
|
|
<a name="413"><span class="lineNum"> 413 </span> : : // Used to print an STL-style container when the user doesn't define</a>
|
|
<a name="414"><span class="lineNum"> 414 </span> : : // a PrintTo() for it.</a>
|
|
<a name="415"><span class="lineNum"> 415 </span> : : template <typename C></a>
|
|
<a name="416"><span class="lineNum"> 416 </span> : : void DefaultPrintTo(WrapPrinterType<kPrintContainer> /* dummy */,</a>
|
|
<a name="417"><span class="lineNum"> 417 </span> : : const C& container, ::std::ostream* os) {</a>
|
|
<a name="418"><span class="lineNum"> 418 </span> : : const size_t kMaxCount = 32; // The maximum number of elements to print.</a>
|
|
<a name="419"><span class="lineNum"> 419 </span> : : *os << '{';</a>
|
|
<a name="420"><span class="lineNum"> 420 </span> : : size_t count = 0;</a>
|
|
<a name="421"><span class="lineNum"> 421 </span> : : for (typename C::const_iterator it = container.begin();</a>
|
|
<a name="422"><span class="lineNum"> 422 </span> : : it != container.end(); ++it, ++count) {</a>
|
|
<a name="423"><span class="lineNum"> 423 </span> : : if (count > 0) {</a>
|
|
<a name="424"><span class="lineNum"> 424 </span> : : *os << ',';</a>
|
|
<a name="425"><span class="lineNum"> 425 </span> : : if (count == kMaxCount) { // Enough has been printed.</a>
|
|
<a name="426"><span class="lineNum"> 426 </span> : : *os << " ...";</a>
|
|
<a name="427"><span class="lineNum"> 427 </span> : : break;</a>
|
|
<a name="428"><span class="lineNum"> 428 </span> : : }</a>
|
|
<a name="429"><span class="lineNum"> 429 </span> : : }</a>
|
|
<a name="430"><span class="lineNum"> 430 </span> : : *os << ' ';</a>
|
|
<a name="431"><span class="lineNum"> 431 </span> : : // We cannot call PrintTo(*it, os) here as PrintTo() doesn't</a>
|
|
<a name="432"><span class="lineNum"> 432 </span> : : // handle *it being a native array.</a>
|
|
<a name="433"><span class="lineNum"> 433 </span> : : internal::UniversalPrint(*it, os);</a>
|
|
<a name="434"><span class="lineNum"> 434 </span> : : }</a>
|
|
<a name="435"><span class="lineNum"> 435 </span> : : </a>
|
|
<a name="436"><span class="lineNum"> 436 </span> : : if (count > 0) {</a>
|
|
<a name="437"><span class="lineNum"> 437 </span> : : *os << ' ';</a>
|
|
<a name="438"><span class="lineNum"> 438 </span> : : }</a>
|
|
<a name="439"><span class="lineNum"> 439 </span> : : *os << '}';</a>
|
|
<a name="440"><span class="lineNum"> 440 </span> : : }</a>
|
|
<a name="441"><span class="lineNum"> 441 </span> : : </a>
|
|
<a name="442"><span class="lineNum"> 442 </span> : : // Used to print a pointer that is neither a char pointer nor a member</a>
|
|
<a name="443"><span class="lineNum"> 443 </span> : : // pointer, when the user doesn't define PrintTo() for it. (A member</a>
|
|
<a name="444"><span class="lineNum"> 444 </span> : : // variable pointer or member function pointer doesn't really point to</a>
|
|
<a name="445"><span class="lineNum"> 445 </span> : : // a location in the address space. Their representation is</a>
|
|
<a name="446"><span class="lineNum"> 446 </span> : : // implementation-defined. Therefore they will be printed as raw</a>
|
|
<a name="447"><span class="lineNum"> 447 </span> : : // bytes.)</a>
|
|
<a name="448"><span class="lineNum"> 448 </span> : : template <typename T></a>
|
|
<a name="449"><span class="lineNum"> 449 </span> : : void DefaultPrintTo(WrapPrinterType<kPrintPointer> /* dummy */,</a>
|
|
<a name="450"><span class="lineNum"> 450 </span> : : T* p, ::std::ostream* os) {</a>
|
|
<a name="451"><span class="lineNum"> 451 </span> : : if (p == NULL) {</a>
|
|
<a name="452"><span class="lineNum"> 452 </span> : : *os << "NULL";</a>
|
|
<a name="453"><span class="lineNum"> 453 </span> : : } else {</a>
|
|
<a name="454"><span class="lineNum"> 454 </span> : : // T is not a function type. We just call << to print p,</a>
|
|
<a name="455"><span class="lineNum"> 455 </span> : : // relying on ADL to pick up user-defined << for their pointer</a>
|
|
<a name="456"><span class="lineNum"> 456 </span> : : // types, if any.</a>
|
|
<a name="457"><span class="lineNum"> 457 </span> : : *os << p;</a>
|
|
<a name="458"><span class="lineNum"> 458 </span> : : }</a>
|
|
<a name="459"><span class="lineNum"> 459 </span> : : }</a>
|
|
<a name="460"><span class="lineNum"> 460 </span> : : template <typename T></a>
|
|
<a name="461"><span class="lineNum"> 461 </span> : : void DefaultPrintTo(WrapPrinterType<kPrintFunctionPointer> /* dummy */,</a>
|
|
<a name="462"><span class="lineNum"> 462 </span> : : T* p, ::std::ostream* os) {</a>
|
|
<a name="463"><span class="lineNum"> 463 </span> : : if (p == NULL) {</a>
|
|
<a name="464"><span class="lineNum"> 464 </span> : : *os << "NULL";</a>
|
|
<a name="465"><span class="lineNum"> 465 </span> : : } else {</a>
|
|
<a name="466"><span class="lineNum"> 466 </span> : : // T is a function type, so '*os << p' doesn't do what we want</a>
|
|
<a name="467"><span class="lineNum"> 467 </span> : : // (it just prints p as bool). We want to print p as a const</a>
|
|
<a name="468"><span class="lineNum"> 468 </span> : : // void*.</a>
|
|
<a name="469"><span class="lineNum"> 469 </span> : : *os << reinterpret_cast<const void*>(p);</a>
|
|
<a name="470"><span class="lineNum"> 470 </span> : : }</a>
|
|
<a name="471"><span class="lineNum"> 471 </span> : : }</a>
|
|
<a name="472"><span class="lineNum"> 472 </span> : : </a>
|
|
<a name="473"><span class="lineNum"> 473 </span> : : // Used to print a non-container, non-pointer value when the user</a>
|
|
<a name="474"><span class="lineNum"> 474 </span> : : // doesn't define PrintTo() for it.</a>
|
|
<a name="475"><span class="lineNum"> 475 </span> : : template <typename T></a>
|
|
<a name="476"><span class="lineNum"> 476 </span> :<span class="lineNoCov"> 0 : void DefaultPrintTo(WrapPrinterType<kPrintOther> /* dummy */,</span></a>
|
|
<a name="477"><span class="lineNum"> 477 </span> : : const T& value, ::std::ostream* os) {</a>
|
|
<a name="478"><span class="lineNum"> 478 </span> :<span class="lineNoCov"> 0 : ::testing_internal::DefaultPrintNonContainerTo(value, os);</span></a>
|
|
<a name="479"><span class="lineNum"> 479 </span> :<span class="lineNoCov"> 0 : }</span></a>
|
|
<a name="480"><span class="lineNum"> 480 </span> : : </a>
|
|
<a name="481"><span class="lineNum"> 481 </span> : : // Prints the given value using the << operator if it has one;</a>
|
|
<a name="482"><span class="lineNum"> 482 </span> : : // otherwise prints the bytes in it. This is what</a>
|
|
<a name="483"><span class="lineNum"> 483 </span> : : // UniversalPrinter<T>::Print() does when PrintTo() is not specialized</a>
|
|
<a name="484"><span class="lineNum"> 484 </span> : : // or overloaded for type T.</a>
|
|
<a name="485"><span class="lineNum"> 485 </span> : : //</a>
|
|
<a name="486"><span class="lineNum"> 486 </span> : : // A user can override this behavior for a class type Foo by defining</a>
|
|
<a name="487"><span class="lineNum"> 487 </span> : : // an overload of PrintTo() in the namespace where Foo is defined. We</a>
|
|
<a name="488"><span class="lineNum"> 488 </span> : : // give the user this option as sometimes defining a << operator for</a>
|
|
<a name="489"><span class="lineNum"> 489 </span> : : // Foo is not desirable (e.g. the coding style may prevent doing it,</a>
|
|
<a name="490"><span class="lineNum"> 490 </span> : : // or there is already a << operator but it doesn't do what the user</a>
|
|
<a name="491"><span class="lineNum"> 491 </span> : : // wants).</a>
|
|
<a name="492"><span class="lineNum"> 492 </span> : : template <typename T></a>
|
|
<a name="493"><span class="lineNum"> 493 </span> :<span class="lineNoCov"> 0 : void PrintTo(const T& value, ::std::ostream* os) {</span></a>
|
|
<a name="494"><span class="lineNum"> 494 </span> : : // DefaultPrintTo() is overloaded. The type of its first argument</a>
|
|
<a name="495"><span class="lineNum"> 495 </span> : : // determines which version will be picked.</a>
|
|
<a name="496"><span class="lineNum"> 496 </span> : : //</a>
|
|
<a name="497"><span class="lineNum"> 497 </span> : : // Note that we check for container types here, prior to we check</a>
|
|
<a name="498"><span class="lineNum"> 498 </span> : : // for protocol message types in our operator<<. The rationale is:</a>
|
|
<a name="499"><span class="lineNum"> 499 </span> : : //</a>
|
|
<a name="500"><span class="lineNum"> 500 </span> : : // For protocol messages, we want to give people a chance to</a>
|
|
<a name="501"><span class="lineNum"> 501 </span> : : // override Google Mock's format by defining a PrintTo() or</a>
|
|
<a name="502"><span class="lineNum"> 502 </span> : : // operator<<. For STL containers, other formats can be</a>
|
|
<a name="503"><span class="lineNum"> 503 </span> : : // incompatible with Google Mock's format for the container</a>
|
|
<a name="504"><span class="lineNum"> 504 </span> : : // elements; therefore we check for container types here to ensure</a>
|
|
<a name="505"><span class="lineNum"> 505 </span> : : // that our format is used.</a>
|
|
<a name="506"><span class="lineNum"> 506 </span> : : //</a>
|
|
<a name="507"><span class="lineNum"> 507 </span> : : // Note that MSVC and clang-cl do allow an implicit conversion from</a>
|
|
<a name="508"><span class="lineNum"> 508 </span> : : // pointer-to-function to pointer-to-object, but clang-cl warns on it.</a>
|
|
<a name="509"><span class="lineNum"> 509 </span> : : // So don't use ImplicitlyConvertible if it can be helped since it will</a>
|
|
<a name="510"><span class="lineNum"> 510 </span> : : // cause this warning, and use a separate overload of DefaultPrintTo for</a>
|
|
<a name="511"><span class="lineNum"> 511 </span> : : // function pointers so that the `*os << p` in the object pointer overload</a>
|
|
<a name="512"><span class="lineNum"> 512 </span> : : // doesn't cause that warning either.</a>
|
|
<a name="513"><span class="lineNum"> 513 </span> [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov"> 0 : DefaultPrintTo(</span></a>
|
|
<a name="514"><span class="lineNum"> 514 </span> : : WrapPrinterType <</a>
|
|
<a name="515"><span class="lineNum"> 515 </span> : : (sizeof(IsContainerTest<T>(0)) == sizeof(IsContainer)) &&</a>
|
|
<a name="516"><span class="lineNum"> 516 </span> : : !IsRecursiveContainer<T>::value</a>
|
|
<a name="517"><span class="lineNum"> 517 </span> : : ? kPrintContainer</a>
|
|
<a name="518"><span class="lineNum"> 518 </span> : : : !is_pointer<T>::value</a>
|
|
<a name="519"><span class="lineNum"> 519 </span> : : ? kPrintOther</a>
|
|
<a name="520"><span class="lineNum"> 520 </span> : : #if GTEST_LANG_CXX11</a>
|
|
<a name="521"><span class="lineNum"> 521 </span> : : : std::is_function<typename std::remove_pointer<T>::type>::value</a>
|
|
<a name="522"><span class="lineNum"> 522 </span> : : #else</a>
|
|
<a name="523"><span class="lineNum"> 523 </span> : : : !internal::ImplicitlyConvertible<T, const void*>::value</a>
|
|
<a name="524"><span class="lineNum"> 524 </span> : : #endif</a>
|
|
<a name="525"><span class="lineNum"> 525 </span> : : ? kPrintFunctionPointer</a>
|
|
<a name="526"><span class="lineNum"> 526 </span> : : : kPrintPointer > (),</a>
|
|
<a name="527"><span class="lineNum"> 527 </span> : : value, os);</a>
|
|
<a name="528"><span class="lineNum"> 528 </span> :<span class="lineNoCov"> 0 : }</span></a>
|
|
<a name="529"><span class="lineNum"> 529 </span> : : </a>
|
|
<a name="530"><span class="lineNum"> 530 </span> : : // The following list of PrintTo() overloads tells</a>
|
|
<a name="531"><span class="lineNum"> 531 </span> : : // UniversalPrinter<T>::Print() how to print standard types (built-in</a>
|
|
<a name="532"><span class="lineNum"> 532 </span> : : // types, strings, plain arrays, and pointers).</a>
|
|
<a name="533"><span class="lineNum"> 533 </span> : : </a>
|
|
<a name="534"><span class="lineNum"> 534 </span> : : // Overloads for various char types.</a>
|
|
<a name="535"><span class="lineNum"> 535 </span> : : GTEST_API_ void PrintTo(unsigned char c, ::std::ostream* os);</a>
|
|
<a name="536"><span class="lineNum"> 536 </span> : : GTEST_API_ void PrintTo(signed char c, ::std::ostream* os);</a>
|
|
<a name="537"><span class="lineNum"> 537 </span> : : inline void PrintTo(char c, ::std::ostream* os) {</a>
|
|
<a name="538"><span class="lineNum"> 538 </span> : : // When printing a plain char, we always treat it as unsigned. This</a>
|
|
<a name="539"><span class="lineNum"> 539 </span> : : // way, the output won't be affected by whether the compiler thinks</a>
|
|
<a name="540"><span class="lineNum"> 540 </span> : : // char is signed or not.</a>
|
|
<a name="541"><span class="lineNum"> 541 </span> : : PrintTo(static_cast<unsigned char>(c), os);</a>
|
|
<a name="542"><span class="lineNum"> 542 </span> : : }</a>
|
|
<a name="543"><span class="lineNum"> 543 </span> : : </a>
|
|
<a name="544"><span class="lineNum"> 544 </span> : : // Overloads for other simple built-in types.</a>
|
|
<a name="545"><span class="lineNum"> 545 </span> :<span class="lineNoCov"> 0 : inline void PrintTo(bool x, ::std::ostream* os) {</span></a>
|
|
<a name="546"><span class="lineNum"> 546 </span> [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov"> 0 : *os << (x ? "true" : "false");</span></a>
|
|
<a name="547"><span class="lineNum"> 547 </span> :<span class="lineNoCov"> 0 : }</span></a>
|
|
<a name="548"><span class="lineNum"> 548 </span> : : </a>
|
|
<a name="549"><span class="lineNum"> 549 </span> : : // Overload for wchar_t type.</a>
|
|
<a name="550"><span class="lineNum"> 550 </span> : : // Prints a wchar_t as a symbol if it is printable or as its internal</a>
|
|
<a name="551"><span class="lineNum"> 551 </span> : : // code otherwise and also as its decimal code (except for L'\0').</a>
|
|
<a name="552"><span class="lineNum"> 552 </span> : : // The L'\0' char is printed as "L'\\0'". The decimal code is printed</a>
|
|
<a name="553"><span class="lineNum"> 553 </span> : : // as signed integer when wchar_t is implemented by the compiler</a>
|
|
<a name="554"><span class="lineNum"> 554 </span> : : // as a signed type and is printed as an unsigned integer when wchar_t</a>
|
|
<a name="555"><span class="lineNum"> 555 </span> : : // is implemented as an unsigned type.</a>
|
|
<a name="556"><span class="lineNum"> 556 </span> : : GTEST_API_ void PrintTo(wchar_t wc, ::std::ostream* os);</a>
|
|
<a name="557"><span class="lineNum"> 557 </span> : : </a>
|
|
<a name="558"><span class="lineNum"> 558 </span> : : // Overloads for C strings.</a>
|
|
<a name="559"><span class="lineNum"> 559 </span> : : GTEST_API_ void PrintTo(const char* s, ::std::ostream* os);</a>
|
|
<a name="560"><span class="lineNum"> 560 </span> : : inline void PrintTo(char* s, ::std::ostream* os) {</a>
|
|
<a name="561"><span class="lineNum"> 561 </span> : : PrintTo(ImplicitCast_<const char*>(s), os);</a>
|
|
<a name="562"><span class="lineNum"> 562 </span> : : }</a>
|
|
<a name="563"><span class="lineNum"> 563 </span> : : </a>
|
|
<a name="564"><span class="lineNum"> 564 </span> : : // signed/unsigned char is often used for representing binary data, so</a>
|
|
<a name="565"><span class="lineNum"> 565 </span> : : // we print pointers to it as void* to be safe.</a>
|
|
<a name="566"><span class="lineNum"> 566 </span> : : inline void PrintTo(const signed char* s, ::std::ostream* os) {</a>
|
|
<a name="567"><span class="lineNum"> 567 </span> : : PrintTo(ImplicitCast_<const void*>(s), os);</a>
|
|
<a name="568"><span class="lineNum"> 568 </span> : : }</a>
|
|
<a name="569"><span class="lineNum"> 569 </span> : : inline void PrintTo(signed char* s, ::std::ostream* os) {</a>
|
|
<a name="570"><span class="lineNum"> 570 </span> : : PrintTo(ImplicitCast_<const void*>(s), os);</a>
|
|
<a name="571"><span class="lineNum"> 571 </span> : : }</a>
|
|
<a name="572"><span class="lineNum"> 572 </span> : : inline void PrintTo(const unsigned char* s, ::std::ostream* os) {</a>
|
|
<a name="573"><span class="lineNum"> 573 </span> : : PrintTo(ImplicitCast_<const void*>(s), os);</a>
|
|
<a name="574"><span class="lineNum"> 574 </span> : : }</a>
|
|
<a name="575"><span class="lineNum"> 575 </span> : : inline void PrintTo(unsigned char* s, ::std::ostream* os) {</a>
|
|
<a name="576"><span class="lineNum"> 576 </span> : : PrintTo(ImplicitCast_<const void*>(s), os);</a>
|
|
<a name="577"><span class="lineNum"> 577 </span> : : }</a>
|
|
<a name="578"><span class="lineNum"> 578 </span> : : </a>
|
|
<a name="579"><span class="lineNum"> 579 </span> : : // MSVC can be configured to define wchar_t as a typedef of unsigned</a>
|
|
<a name="580"><span class="lineNum"> 580 </span> : : // short. It defines _NATIVE_WCHAR_T_DEFINED when wchar_t is a native</a>
|
|
<a name="581"><span class="lineNum"> 581 </span> : : // type. When wchar_t is a typedef, defining an overload for const</a>
|
|
<a name="582"><span class="lineNum"> 582 </span> : : // wchar_t* would cause unsigned short* be printed as a wide string,</a>
|
|
<a name="583"><span class="lineNum"> 583 </span> : : // possibly causing invalid memory accesses.</a>
|
|
<a name="584"><span class="lineNum"> 584 </span> : : #if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)</a>
|
|
<a name="585"><span class="lineNum"> 585 </span> : : // Overloads for wide C strings</a>
|
|
<a name="586"><span class="lineNum"> 586 </span> : : GTEST_API_ void PrintTo(const wchar_t* s, ::std::ostream* os);</a>
|
|
<a name="587"><span class="lineNum"> 587 </span> : : inline void PrintTo(wchar_t* s, ::std::ostream* os) {</a>
|
|
<a name="588"><span class="lineNum"> 588 </span> : : PrintTo(ImplicitCast_<const wchar_t*>(s), os);</a>
|
|
<a name="589"><span class="lineNum"> 589 </span> : : }</a>
|
|
<a name="590"><span class="lineNum"> 590 </span> : : #endif</a>
|
|
<a name="591"><span class="lineNum"> 591 </span> : : </a>
|
|
<a name="592"><span class="lineNum"> 592 </span> : : // Overload for C arrays. Multi-dimensional arrays are printed</a>
|
|
<a name="593"><span class="lineNum"> 593 </span> : : // properly.</a>
|
|
<a name="594"><span class="lineNum"> 594 </span> : : </a>
|
|
<a name="595"><span class="lineNum"> 595 </span> : : // Prints the given number of elements in an array, without printing</a>
|
|
<a name="596"><span class="lineNum"> 596 </span> : : // the curly braces.</a>
|
|
<a name="597"><span class="lineNum"> 597 </span> : : template <typename T></a>
|
|
<a name="598"><span class="lineNum"> 598 </span> : : void PrintRawArrayTo(const T a[], size_t count, ::std::ostream* os) {</a>
|
|
<a name="599"><span class="lineNum"> 599 </span> : : UniversalPrint(a[0], os);</a>
|
|
<a name="600"><span class="lineNum"> 600 </span> : : for (size_t i = 1; i != count; i++) {</a>
|
|
<a name="601"><span class="lineNum"> 601 </span> : : *os << ", ";</a>
|
|
<a name="602"><span class="lineNum"> 602 </span> : : UniversalPrint(a[i], os);</a>
|
|
<a name="603"><span class="lineNum"> 603 </span> : : }</a>
|
|
<a name="604"><span class="lineNum"> 604 </span> : : }</a>
|
|
<a name="605"><span class="lineNum"> 605 </span> : : </a>
|
|
<a name="606"><span class="lineNum"> 606 </span> : : // Overloads for ::string and ::std::string.</a>
|
|
<a name="607"><span class="lineNum"> 607 </span> : : #if GTEST_HAS_GLOBAL_STRING</a>
|
|
<a name="608"><span class="lineNum"> 608 </span> : : GTEST_API_ void PrintStringTo(const ::string&s, ::std::ostream* os);</a>
|
|
<a name="609"><span class="lineNum"> 609 </span> : : inline void PrintTo(const ::string& s, ::std::ostream* os) {</a>
|
|
<a name="610"><span class="lineNum"> 610 </span> : : PrintStringTo(s, os);</a>
|
|
<a name="611"><span class="lineNum"> 611 </span> : : }</a>
|
|
<a name="612"><span class="lineNum"> 612 </span> : : #endif // GTEST_HAS_GLOBAL_STRING</a>
|
|
<a name="613"><span class="lineNum"> 613 </span> : : </a>
|
|
<a name="614"><span class="lineNum"> 614 </span> : : GTEST_API_ void PrintStringTo(const ::std::string&s, ::std::ostream* os);</a>
|
|
<a name="615"><span class="lineNum"> 615 </span> : : inline void PrintTo(const ::std::string& s, ::std::ostream* os) {</a>
|
|
<a name="616"><span class="lineNum"> 616 </span> : : PrintStringTo(s, os);</a>
|
|
<a name="617"><span class="lineNum"> 617 </span> : : }</a>
|
|
<a name="618"><span class="lineNum"> 618 </span> : : </a>
|
|
<a name="619"><span class="lineNum"> 619 </span> : : // Overloads for ::wstring and ::std::wstring.</a>
|
|
<a name="620"><span class="lineNum"> 620 </span> : : #if GTEST_HAS_GLOBAL_WSTRING</a>
|
|
<a name="621"><span class="lineNum"> 621 </span> : : GTEST_API_ void PrintWideStringTo(const ::wstring&s, ::std::ostream* os);</a>
|
|
<a name="622"><span class="lineNum"> 622 </span> : : inline void PrintTo(const ::wstring& s, ::std::ostream* os) {</a>
|
|
<a name="623"><span class="lineNum"> 623 </span> : : PrintWideStringTo(s, os);</a>
|
|
<a name="624"><span class="lineNum"> 624 </span> : : }</a>
|
|
<a name="625"><span class="lineNum"> 625 </span> : : #endif // GTEST_HAS_GLOBAL_WSTRING</a>
|
|
<a name="626"><span class="lineNum"> 626 </span> : : </a>
|
|
<a name="627"><span class="lineNum"> 627 </span> : : #if GTEST_HAS_STD_WSTRING</a>
|
|
<a name="628"><span class="lineNum"> 628 </span> : : GTEST_API_ void PrintWideStringTo(const ::std::wstring&s, ::std::ostream* os);</a>
|
|
<a name="629"><span class="lineNum"> 629 </span> : : inline void PrintTo(const ::std::wstring& s, ::std::ostream* os) {</a>
|
|
<a name="630"><span class="lineNum"> 630 </span> : : PrintWideStringTo(s, os);</a>
|
|
<a name="631"><span class="lineNum"> 631 </span> : : }</a>
|
|
<a name="632"><span class="lineNum"> 632 </span> : : #endif // GTEST_HAS_STD_WSTRING</a>
|
|
<a name="633"><span class="lineNum"> 633 </span> : : </a>
|
|
<a name="634"><span class="lineNum"> 634 </span> : : #if GTEST_HAS_ABSL</a>
|
|
<a name="635"><span class="lineNum"> 635 </span> : : // Overload for absl::string_view.</a>
|
|
<a name="636"><span class="lineNum"> 636 </span> : : inline void PrintTo(absl::string_view sp, ::std::ostream* os) {</a>
|
|
<a name="637"><span class="lineNum"> 637 </span> : : PrintTo(::std::string(sp), os);</a>
|
|
<a name="638"><span class="lineNum"> 638 </span> : : }</a>
|
|
<a name="639"><span class="lineNum"> 639 </span> : : #endif // GTEST_HAS_ABSL</a>
|
|
<a name="640"><span class="lineNum"> 640 </span> : : </a>
|
|
<a name="641"><span class="lineNum"> 641 </span> : : #if GTEST_LANG_CXX11</a>
|
|
<a name="642"><span class="lineNum"> 642 </span> : : inline void PrintTo(std::nullptr_t, ::std::ostream* os) { *os << "(nullptr)"; }</a>
|
|
<a name="643"><span class="lineNum"> 643 </span> : : #endif // GTEST_LANG_CXX11</a>
|
|
<a name="644"><span class="lineNum"> 644 </span> : : </a>
|
|
<a name="645"><span class="lineNum"> 645 </span> : : #if GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_</a>
|
|
<a name="646"><span class="lineNum"> 646 </span> : : // Helper function for printing a tuple. T must be instantiated with</a>
|
|
<a name="647"><span class="lineNum"> 647 </span> : : // a tuple type.</a>
|
|
<a name="648"><span class="lineNum"> 648 </span> : : template <typename T></a>
|
|
<a name="649"><span class="lineNum"> 649 </span> : : void PrintTupleTo(const T& t, ::std::ostream* os);</a>
|
|
<a name="650"><span class="lineNum"> 650 </span> : : #endif // GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_</a>
|
|
<a name="651"><span class="lineNum"> 651 </span> : : </a>
|
|
<a name="652"><span class="lineNum"> 652 </span> : : #if GTEST_HAS_TR1_TUPLE</a>
|
|
<a name="653"><span class="lineNum"> 653 </span> : : // Overload for ::std::tr1::tuple. Needed for printing function arguments,</a>
|
|
<a name="654"><span class="lineNum"> 654 </span> : : // which are packed as tuples.</a>
|
|
<a name="655"><span class="lineNum"> 655 </span> : : </a>
|
|
<a name="656"><span class="lineNum"> 656 </span> : : // Overloaded PrintTo() for tuples of various arities. We support</a>
|
|
<a name="657"><span class="lineNum"> 657 </span> : : // tuples of up-to 10 fields. The following implementation works</a>
|
|
<a name="658"><span class="lineNum"> 658 </span> : : // regardless of whether tr1::tuple is implemented using the</a>
|
|
<a name="659"><span class="lineNum"> 659 </span> : : // non-standard variadic template feature or not.</a>
|
|
<a name="660"><span class="lineNum"> 660 </span> : : </a>
|
|
<a name="661"><span class="lineNum"> 661 </span> : : inline void PrintTo(const ::std::tr1::tuple<>& t, ::std::ostream* os) {</a>
|
|
<a name="662"><span class="lineNum"> 662 </span> : : PrintTupleTo(t, os);</a>
|
|
<a name="663"><span class="lineNum"> 663 </span> : : }</a>
|
|
<a name="664"><span class="lineNum"> 664 </span> : : </a>
|
|
<a name="665"><span class="lineNum"> 665 </span> : : template <typename T1></a>
|
|
<a name="666"><span class="lineNum"> 666 </span> : : void PrintTo(const ::std::tr1::tuple<T1>& t, ::std::ostream* os) {</a>
|
|
<a name="667"><span class="lineNum"> 667 </span> : : PrintTupleTo(t, os);</a>
|
|
<a name="668"><span class="lineNum"> 668 </span> : : }</a>
|
|
<a name="669"><span class="lineNum"> 669 </span> : : </a>
|
|
<a name="670"><span class="lineNum"> 670 </span> : : template <typename T1, typename T2></a>
|
|
<a name="671"><span class="lineNum"> 671 </span> : : void PrintTo(const ::std::tr1::tuple<T1, T2>& t, ::std::ostream* os) {</a>
|
|
<a name="672"><span class="lineNum"> 672 </span> : : PrintTupleTo(t, os);</a>
|
|
<a name="673"><span class="lineNum"> 673 </span> : : }</a>
|
|
<a name="674"><span class="lineNum"> 674 </span> : : </a>
|
|
<a name="675"><span class="lineNum"> 675 </span> : : template <typename T1, typename T2, typename T3></a>
|
|
<a name="676"><span class="lineNum"> 676 </span> : : void PrintTo(const ::std::tr1::tuple<T1, T2, T3>& t, ::std::ostream* os) {</a>
|
|
<a name="677"><span class="lineNum"> 677 </span> : : PrintTupleTo(t, os);</a>
|
|
<a name="678"><span class="lineNum"> 678 </span> : : }</a>
|
|
<a name="679"><span class="lineNum"> 679 </span> : : </a>
|
|
<a name="680"><span class="lineNum"> 680 </span> : : template <typename T1, typename T2, typename T3, typename T4></a>
|
|
<a name="681"><span class="lineNum"> 681 </span> : : void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4>& t, ::std::ostream* os) {</a>
|
|
<a name="682"><span class="lineNum"> 682 </span> : : PrintTupleTo(t, os);</a>
|
|
<a name="683"><span class="lineNum"> 683 </span> : : }</a>
|
|
<a name="684"><span class="lineNum"> 684 </span> : : </a>
|
|
<a name="685"><span class="lineNum"> 685 </span> : : template <typename T1, typename T2, typename T3, typename T4, typename T5></a>
|
|
<a name="686"><span class="lineNum"> 686 </span> : : void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5>& t,</a>
|
|
<a name="687"><span class="lineNum"> 687 </span> : : ::std::ostream* os) {</a>
|
|
<a name="688"><span class="lineNum"> 688 </span> : : PrintTupleTo(t, os);</a>
|
|
<a name="689"><span class="lineNum"> 689 </span> : : }</a>
|
|
<a name="690"><span class="lineNum"> 690 </span> : : </a>
|
|
<a name="691"><span class="lineNum"> 691 </span> : : template <typename T1, typename T2, typename T3, typename T4, typename T5,</a>
|
|
<a name="692"><span class="lineNum"> 692 </span> : : typename T6></a>
|
|
<a name="693"><span class="lineNum"> 693 </span> : : void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6>& t,</a>
|
|
<a name="694"><span class="lineNum"> 694 </span> : : ::std::ostream* os) {</a>
|
|
<a name="695"><span class="lineNum"> 695 </span> : : PrintTupleTo(t, os);</a>
|
|
<a name="696"><span class="lineNum"> 696 </span> : : }</a>
|
|
<a name="697"><span class="lineNum"> 697 </span> : : </a>
|
|
<a name="698"><span class="lineNum"> 698 </span> : : template <typename T1, typename T2, typename T3, typename T4, typename T5,</a>
|
|
<a name="699"><span class="lineNum"> 699 </span> : : typename T6, typename T7></a>
|
|
<a name="700"><span class="lineNum"> 700 </span> : : void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7>& t,</a>
|
|
<a name="701"><span class="lineNum"> 701 </span> : : ::std::ostream* os) {</a>
|
|
<a name="702"><span class="lineNum"> 702 </span> : : PrintTupleTo(t, os);</a>
|
|
<a name="703"><span class="lineNum"> 703 </span> : : }</a>
|
|
<a name="704"><span class="lineNum"> 704 </span> : : </a>
|
|
<a name="705"><span class="lineNum"> 705 </span> : : template <typename T1, typename T2, typename T3, typename T4, typename T5,</a>
|
|
<a name="706"><span class="lineNum"> 706 </span> : : typename T6, typename T7, typename T8></a>
|
|
<a name="707"><span class="lineNum"> 707 </span> : : void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8>& t,</a>
|
|
<a name="708"><span class="lineNum"> 708 </span> : : ::std::ostream* os) {</a>
|
|
<a name="709"><span class="lineNum"> 709 </span> : : PrintTupleTo(t, os);</a>
|
|
<a name="710"><span class="lineNum"> 710 </span> : : }</a>
|
|
<a name="711"><span class="lineNum"> 711 </span> : : </a>
|
|
<a name="712"><span class="lineNum"> 712 </span> : : template <typename T1, typename T2, typename T3, typename T4, typename T5,</a>
|
|
<a name="713"><span class="lineNum"> 713 </span> : : typename T6, typename T7, typename T8, typename T9></a>
|
|
<a name="714"><span class="lineNum"> 714 </span> : : void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9>& t,</a>
|
|
<a name="715"><span class="lineNum"> 715 </span> : : ::std::ostream* os) {</a>
|
|
<a name="716"><span class="lineNum"> 716 </span> : : PrintTupleTo(t, os);</a>
|
|
<a name="717"><span class="lineNum"> 717 </span> : : }</a>
|
|
<a name="718"><span class="lineNum"> 718 </span> : : </a>
|
|
<a name="719"><span class="lineNum"> 719 </span> : : template <typename T1, typename T2, typename T3, typename T4, typename T5,</a>
|
|
<a name="720"><span class="lineNum"> 720 </span> : : typename T6, typename T7, typename T8, typename T9, typename T10></a>
|
|
<a name="721"><span class="lineNum"> 721 </span> : : void PrintTo(</a>
|
|
<a name="722"><span class="lineNum"> 722 </span> : : const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>& t,</a>
|
|
<a name="723"><span class="lineNum"> 723 </span> : : ::std::ostream* os) {</a>
|
|
<a name="724"><span class="lineNum"> 724 </span> : : PrintTupleTo(t, os);</a>
|
|
<a name="725"><span class="lineNum"> 725 </span> : : }</a>
|
|
<a name="726"><span class="lineNum"> 726 </span> : : #endif // GTEST_HAS_TR1_TUPLE</a>
|
|
<a name="727"><span class="lineNum"> 727 </span> : : </a>
|
|
<a name="728"><span class="lineNum"> 728 </span> : : #if GTEST_HAS_STD_TUPLE_</a>
|
|
<a name="729"><span class="lineNum"> 729 </span> : : template <typename... Types></a>
|
|
<a name="730"><span class="lineNum"> 730 </span> : : void PrintTo(const ::std::tuple<Types...>& t, ::std::ostream* os) {</a>
|
|
<a name="731"><span class="lineNum"> 731 </span> : : PrintTupleTo(t, os);</a>
|
|
<a name="732"><span class="lineNum"> 732 </span> : : }</a>
|
|
<a name="733"><span class="lineNum"> 733 </span> : : #endif // GTEST_HAS_STD_TUPLE_</a>
|
|
<a name="734"><span class="lineNum"> 734 </span> : : </a>
|
|
<a name="735"><span class="lineNum"> 735 </span> : : // Overload for std::pair.</a>
|
|
<a name="736"><span class="lineNum"> 736 </span> : : template <typename T1, typename T2></a>
|
|
<a name="737"><span class="lineNum"> 737 </span> : : void PrintTo(const ::std::pair<T1, T2>& value, ::std::ostream* os) {</a>
|
|
<a name="738"><span class="lineNum"> 738 </span> : : *os << '(';</a>
|
|
<a name="739"><span class="lineNum"> 739 </span> : : // We cannot use UniversalPrint(value.first, os) here, as T1 may be</a>
|
|
<a name="740"><span class="lineNum"> 740 </span> : : // a reference type. The same for printing value.second.</a>
|
|
<a name="741"><span class="lineNum"> 741 </span> : : UniversalPrinter<T1>::Print(value.first, os);</a>
|
|
<a name="742"><span class="lineNum"> 742 </span> : : *os << ", ";</a>
|
|
<a name="743"><span class="lineNum"> 743 </span> : : UniversalPrinter<T2>::Print(value.second, os);</a>
|
|
<a name="744"><span class="lineNum"> 744 </span> : : *os << ')';</a>
|
|
<a name="745"><span class="lineNum"> 745 </span> : : }</a>
|
|
<a name="746"><span class="lineNum"> 746 </span> : : </a>
|
|
<a name="747"><span class="lineNum"> 747 </span> : : // Implements printing a non-reference type T by letting the compiler</a>
|
|
<a name="748"><span class="lineNum"> 748 </span> : : // pick the right overload of PrintTo() for T.</a>
|
|
<a name="749"><span class="lineNum"> 749 </span> : : template <typename T></a>
|
|
<a name="750"><span class="lineNum"> 750 </span> : : class UniversalPrinter {</a>
|
|
<a name="751"><span class="lineNum"> 751 </span> : : public:</a>
|
|
<a name="752"><span class="lineNum"> 752 </span> : : // MSVC warns about adding const to a function type, so we want to</a>
|
|
<a name="753"><span class="lineNum"> 753 </span> : : // disable the warning.</a>
|
|
<a name="754"><span class="lineNum"> 754 </span> : : GTEST_DISABLE_MSC_WARNINGS_PUSH_(4180)</a>
|
|
<a name="755"><span class="lineNum"> 755 </span> : : </a>
|
|
<a name="756"><span class="lineNum"> 756 </span> : : // Note: we deliberately don't call this PrintTo(), as that name</a>
|
|
<a name="757"><span class="lineNum"> 757 </span> : : // conflicts with ::testing::internal::PrintTo in the body of the</a>
|
|
<a name="758"><span class="lineNum"> 758 </span> : : // function.</a>
|
|
<a name="759"><span class="lineNum"> 759 </span> :<span class="lineNoCov"> 0 : static void Print(const T& value, ::std::ostream* os) {</span></a>
|
|
<a name="760"><span class="lineNum"> 760 </span> : : // By default, ::testing::internal::PrintTo() is used for printing</a>
|
|
<a name="761"><span class="lineNum"> 761 </span> : : // the value.</a>
|
|
<a name="762"><span class="lineNum"> 762 </span> : : //</a>
|
|
<a name="763"><span class="lineNum"> 763 </span> : : // Thanks to Koenig look-up, if T is a class and has its own</a>
|
|
<a name="764"><span class="lineNum"> 764 </span> : : // PrintTo() function defined in its namespace, that function will</a>
|
|
<a name="765"><span class="lineNum"> 765 </span> : : // be visible here. Since it is more specific than the generic ones</a>
|
|
<a name="766"><span class="lineNum"> 766 </span> : : // in ::testing::internal, it will be picked by the compiler in the</a>
|
|
<a name="767"><span class="lineNum"> 767 </span> : : // following statement - exactly what we want.</a>
|
|
<a name="768"><span class="lineNum"> 768 </span> :<span class="lineNoCov"> 0 : PrintTo(value, os);</span></a>
|
|
<a name="769"><span class="lineNum"> 769 </span> :<span class="lineNoCov"> 0 : }</span></a>
|
|
<a name="770"><span class="lineNum"> 770 </span> : : </a>
|
|
<a name="771"><span class="lineNum"> 771 </span> : : GTEST_DISABLE_MSC_WARNINGS_POP_()</a>
|
|
<a name="772"><span class="lineNum"> 772 </span> : : };</a>
|
|
<a name="773"><span class="lineNum"> 773 </span> : : </a>
|
|
<a name="774"><span class="lineNum"> 774 </span> : : #if GTEST_HAS_ABSL</a>
|
|
<a name="775"><span class="lineNum"> 775 </span> : : </a>
|
|
<a name="776"><span class="lineNum"> 776 </span> : : // Printer for absl::optional</a>
|
|
<a name="777"><span class="lineNum"> 777 </span> : : </a>
|
|
<a name="778"><span class="lineNum"> 778 </span> : : template <typename T></a>
|
|
<a name="779"><span class="lineNum"> 779 </span> : : class UniversalPrinter<::absl::optional<T>> {</a>
|
|
<a name="780"><span class="lineNum"> 780 </span> : : public:</a>
|
|
<a name="781"><span class="lineNum"> 781 </span> : : static void Print(const ::absl::optional<T>& value, ::std::ostream* os) {</a>
|
|
<a name="782"><span class="lineNum"> 782 </span> : : *os << '(';</a>
|
|
<a name="783"><span class="lineNum"> 783 </span> : : if (!value) {</a>
|
|
<a name="784"><span class="lineNum"> 784 </span> : : *os << "nullopt";</a>
|
|
<a name="785"><span class="lineNum"> 785 </span> : : } else {</a>
|
|
<a name="786"><span class="lineNum"> 786 </span> : : UniversalPrint(*value, os);</a>
|
|
<a name="787"><span class="lineNum"> 787 </span> : : }</a>
|
|
<a name="788"><span class="lineNum"> 788 </span> : : *os << ')';</a>
|
|
<a name="789"><span class="lineNum"> 789 </span> : : }</a>
|
|
<a name="790"><span class="lineNum"> 790 </span> : : };</a>
|
|
<a name="791"><span class="lineNum"> 791 </span> : : </a>
|
|
<a name="792"><span class="lineNum"> 792 </span> : : // Printer for absl::variant</a>
|
|
<a name="793"><span class="lineNum"> 793 </span> : : </a>
|
|
<a name="794"><span class="lineNum"> 794 </span> : : template <typename... T></a>
|
|
<a name="795"><span class="lineNum"> 795 </span> : : class UniversalPrinter<::absl::variant<T...>> {</a>
|
|
<a name="796"><span class="lineNum"> 796 </span> : : public:</a>
|
|
<a name="797"><span class="lineNum"> 797 </span> : : static void Print(const ::absl::variant<T...>& value, ::std::ostream* os) {</a>
|
|
<a name="798"><span class="lineNum"> 798 </span> : : *os << '(';</a>
|
|
<a name="799"><span class="lineNum"> 799 </span> : : absl::visit(Visitor{os}, value);</a>
|
|
<a name="800"><span class="lineNum"> 800 </span> : : *os << ')';</a>
|
|
<a name="801"><span class="lineNum"> 801 </span> : : }</a>
|
|
<a name="802"><span class="lineNum"> 802 </span> : : </a>
|
|
<a name="803"><span class="lineNum"> 803 </span> : : private:</a>
|
|
<a name="804"><span class="lineNum"> 804 </span> : : struct Visitor {</a>
|
|
<a name="805"><span class="lineNum"> 805 </span> : : template <typename U></a>
|
|
<a name="806"><span class="lineNum"> 806 </span> : : void operator()(const U& u) const {</a>
|
|
<a name="807"><span class="lineNum"> 807 </span> : : *os << "'" << GetTypeName<U>() << "' with value ";</a>
|
|
<a name="808"><span class="lineNum"> 808 </span> : : UniversalPrint(u, os);</a>
|
|
<a name="809"><span class="lineNum"> 809 </span> : : }</a>
|
|
<a name="810"><span class="lineNum"> 810 </span> : : ::std::ostream* os;</a>
|
|
<a name="811"><span class="lineNum"> 811 </span> : : };</a>
|
|
<a name="812"><span class="lineNum"> 812 </span> : : };</a>
|
|
<a name="813"><span class="lineNum"> 813 </span> : : </a>
|
|
<a name="814"><span class="lineNum"> 814 </span> : : #endif // GTEST_HAS_ABSL</a>
|
|
<a name="815"><span class="lineNum"> 815 </span> : : </a>
|
|
<a name="816"><span class="lineNum"> 816 </span> : : // UniversalPrintArray(begin, len, os) prints an array of 'len'</a>
|
|
<a name="817"><span class="lineNum"> 817 </span> : : // elements, starting at address 'begin'.</a>
|
|
<a name="818"><span class="lineNum"> 818 </span> : : template <typename T></a>
|
|
<a name="819"><span class="lineNum"> 819 </span> : : void UniversalPrintArray(const T* begin, size_t len, ::std::ostream* os) {</a>
|
|
<a name="820"><span class="lineNum"> 820 </span> : : if (len == 0) {</a>
|
|
<a name="821"><span class="lineNum"> 821 </span> : : *os << "{}";</a>
|
|
<a name="822"><span class="lineNum"> 822 </span> : : } else {</a>
|
|
<a name="823"><span class="lineNum"> 823 </span> : : *os << "{ ";</a>
|
|
<a name="824"><span class="lineNum"> 824 </span> : : const size_t kThreshold = 18;</a>
|
|
<a name="825"><span class="lineNum"> 825 </span> : : const size_t kChunkSize = 8;</a>
|
|
<a name="826"><span class="lineNum"> 826 </span> : : // If the array has more than kThreshold elements, we'll have to</a>
|
|
<a name="827"><span class="lineNum"> 827 </span> : : // omit some details by printing only the first and the last</a>
|
|
<a name="828"><span class="lineNum"> 828 </span> : : // kChunkSize elements.</a>
|
|
<a name="829"><span class="lineNum"> 829 </span> : : // FIXME: let the user control the threshold using a flag.</a>
|
|
<a name="830"><span class="lineNum"> 830 </span> : : if (len <= kThreshold) {</a>
|
|
<a name="831"><span class="lineNum"> 831 </span> : : PrintRawArrayTo(begin, len, os);</a>
|
|
<a name="832"><span class="lineNum"> 832 </span> : : } else {</a>
|
|
<a name="833"><span class="lineNum"> 833 </span> : : PrintRawArrayTo(begin, kChunkSize, os);</a>
|
|
<a name="834"><span class="lineNum"> 834 </span> : : *os << ", ..., ";</a>
|
|
<a name="835"><span class="lineNum"> 835 </span> : : PrintRawArrayTo(begin + len - kChunkSize, kChunkSize, os);</a>
|
|
<a name="836"><span class="lineNum"> 836 </span> : : }</a>
|
|
<a name="837"><span class="lineNum"> 837 </span> : : *os << " }";</a>
|
|
<a name="838"><span class="lineNum"> 838 </span> : : }</a>
|
|
<a name="839"><span class="lineNum"> 839 </span> : : }</a>
|
|
<a name="840"><span class="lineNum"> 840 </span> : : // This overload prints a (const) char array compactly.</a>
|
|
<a name="841"><span class="lineNum"> 841 </span> : : GTEST_API_ void UniversalPrintArray(</a>
|
|
<a name="842"><span class="lineNum"> 842 </span> : : const char* begin, size_t len, ::std::ostream* os);</a>
|
|
<a name="843"><span class="lineNum"> 843 </span> : : </a>
|
|
<a name="844"><span class="lineNum"> 844 </span> : : // This overload prints a (const) wchar_t array compactly.</a>
|
|
<a name="845"><span class="lineNum"> 845 </span> : : GTEST_API_ void UniversalPrintArray(</a>
|
|
<a name="846"><span class="lineNum"> 846 </span> : : const wchar_t* begin, size_t len, ::std::ostream* os);</a>
|
|
<a name="847"><span class="lineNum"> 847 </span> : : </a>
|
|
<a name="848"><span class="lineNum"> 848 </span> : : // Implements printing an array type T[N].</a>
|
|
<a name="849"><span class="lineNum"> 849 </span> : : template <typename T, size_t N></a>
|
|
<a name="850"><span class="lineNum"> 850 </span> : : class UniversalPrinter<T[N]> {</a>
|
|
<a name="851"><span class="lineNum"> 851 </span> : : public:</a>
|
|
<a name="852"><span class="lineNum"> 852 </span> : : // Prints the given array, omitting some elements when there are too</a>
|
|
<a name="853"><span class="lineNum"> 853 </span> : : // many.</a>
|
|
<a name="854"><span class="lineNum"> 854 </span> : : static void Print(const T (&a)[N], ::std::ostream* os) {</a>
|
|
<a name="855"><span class="lineNum"> 855 </span> : : UniversalPrintArray(a, N, os);</a>
|
|
<a name="856"><span class="lineNum"> 856 </span> : : }</a>
|
|
<a name="857"><span class="lineNum"> 857 </span> : : };</a>
|
|
<a name="858"><span class="lineNum"> 858 </span> : : </a>
|
|
<a name="859"><span class="lineNum"> 859 </span> : : // Implements printing a reference type T&.</a>
|
|
<a name="860"><span class="lineNum"> 860 </span> : : template <typename T></a>
|
|
<a name="861"><span class="lineNum"> 861 </span> : : class UniversalPrinter<T&> {</a>
|
|
<a name="862"><span class="lineNum"> 862 </span> : : public:</a>
|
|
<a name="863"><span class="lineNum"> 863 </span> : : // MSVC warns about adding const to a function type, so we want to</a>
|
|
<a name="864"><span class="lineNum"> 864 </span> : : // disable the warning.</a>
|
|
<a name="865"><span class="lineNum"> 865 </span> : : GTEST_DISABLE_MSC_WARNINGS_PUSH_(4180)</a>
|
|
<a name="866"><span class="lineNum"> 866 </span> : : </a>
|
|
<a name="867"><span class="lineNum"> 867 </span> : : static void Print(const T& value, ::std::ostream* os) {</a>
|
|
<a name="868"><span class="lineNum"> 868 </span> : : // Prints the address of the value. We use reinterpret_cast here</a>
|
|
<a name="869"><span class="lineNum"> 869 </span> : : // as static_cast doesn't compile when T is a function type.</a>
|
|
<a name="870"><span class="lineNum"> 870 </span> : : *os << "@" << reinterpret_cast<const void*>(&value) << " ";</a>
|
|
<a name="871"><span class="lineNum"> 871 </span> : : </a>
|
|
<a name="872"><span class="lineNum"> 872 </span> : : // Then prints the value itself.</a>
|
|
<a name="873"><span class="lineNum"> 873 </span> : : UniversalPrint(value, os);</a>
|
|
<a name="874"><span class="lineNum"> 874 </span> : : }</a>
|
|
<a name="875"><span class="lineNum"> 875 </span> : : </a>
|
|
<a name="876"><span class="lineNum"> 876 </span> : : GTEST_DISABLE_MSC_WARNINGS_POP_()</a>
|
|
<a name="877"><span class="lineNum"> 877 </span> : : };</a>
|
|
<a name="878"><span class="lineNum"> 878 </span> : : </a>
|
|
<a name="879"><span class="lineNum"> 879 </span> : : // Prints a value tersely: for a reference type, the referenced value</a>
|
|
<a name="880"><span class="lineNum"> 880 </span> : : // (but not the address) is printed; for a (const) char pointer, the</a>
|
|
<a name="881"><span class="lineNum"> 881 </span> : : // NUL-terminated string (but not the pointer) is printed.</a>
|
|
<a name="882"><span class="lineNum"> 882 </span> : : </a>
|
|
<a name="883"><span class="lineNum"> 883 </span> : : template <typename T></a>
|
|
<a name="884"><span class="lineNum"> 884 </span> : : class UniversalTersePrinter {</a>
|
|
<a name="885"><span class="lineNum"> 885 </span> : : public:</a>
|
|
<a name="886"><span class="lineNum"> 886 </span> :<span class="lineNoCov"> 0 : static void Print(const T& value, ::std::ostream* os) {</span></a>
|
|
<a name="887"><span class="lineNum"> 887 </span> :<span class="lineNoCov"> 0 : UniversalPrint(value, os);</span></a>
|
|
<a name="888"><span class="lineNum"> 888 </span> :<span class="lineNoCov"> 0 : }</span></a>
|
|
<a name="889"><span class="lineNum"> 889 </span> : : };</a>
|
|
<a name="890"><span class="lineNum"> 890 </span> : : template <typename T></a>
|
|
<a name="891"><span class="lineNum"> 891 </span> : : class UniversalTersePrinter<T&> {</a>
|
|
<a name="892"><span class="lineNum"> 892 </span> : : public:</a>
|
|
<a name="893"><span class="lineNum"> 893 </span> : : static void Print(const T& value, ::std::ostream* os) {</a>
|
|
<a name="894"><span class="lineNum"> 894 </span> : : UniversalPrint(value, os);</a>
|
|
<a name="895"><span class="lineNum"> 895 </span> : : }</a>
|
|
<a name="896"><span class="lineNum"> 896 </span> : : };</a>
|
|
<a name="897"><span class="lineNum"> 897 </span> : : template <typename T, size_t N></a>
|
|
<a name="898"><span class="lineNum"> 898 </span> : : class UniversalTersePrinter<T[N]> {</a>
|
|
<a name="899"><span class="lineNum"> 899 </span> : : public:</a>
|
|
<a name="900"><span class="lineNum"> 900 </span> : : static void Print(const T (&value)[N], ::std::ostream* os) {</a>
|
|
<a name="901"><span class="lineNum"> 901 </span> : : UniversalPrinter<T[N]>::Print(value, os);</a>
|
|
<a name="902"><span class="lineNum"> 902 </span> : : }</a>
|
|
<a name="903"><span class="lineNum"> 903 </span> : : };</a>
|
|
<a name="904"><span class="lineNum"> 904 </span> : : template <></a>
|
|
<a name="905"><span class="lineNum"> 905 </span> : : class UniversalTersePrinter<const char*> {</a>
|
|
<a name="906"><span class="lineNum"> 906 </span> : : public:</a>
|
|
<a name="907"><span class="lineNum"> 907 </span> : : static void Print(const char* str, ::std::ostream* os) {</a>
|
|
<a name="908"><span class="lineNum"> 908 </span> : : if (str == NULL) {</a>
|
|
<a name="909"><span class="lineNum"> 909 </span> : : *os << "NULL";</a>
|
|
<a name="910"><span class="lineNum"> 910 </span> : : } else {</a>
|
|
<a name="911"><span class="lineNum"> 911 </span> : : UniversalPrint(std::string(str), os);</a>
|
|
<a name="912"><span class="lineNum"> 912 </span> : : }</a>
|
|
<a name="913"><span class="lineNum"> 913 </span> : : }</a>
|
|
<a name="914"><span class="lineNum"> 914 </span> : : };</a>
|
|
<a name="915"><span class="lineNum"> 915 </span> : : template <></a>
|
|
<a name="916"><span class="lineNum"> 916 </span> : : class UniversalTersePrinter<char*> {</a>
|
|
<a name="917"><span class="lineNum"> 917 </span> : : public:</a>
|
|
<a name="918"><span class="lineNum"> 918 </span> : : static void Print(char* str, ::std::ostream* os) {</a>
|
|
<a name="919"><span class="lineNum"> 919 </span> : : UniversalTersePrinter<const char*>::Print(str, os);</a>
|
|
<a name="920"><span class="lineNum"> 920 </span> : : }</a>
|
|
<a name="921"><span class="lineNum"> 921 </span> : : };</a>
|
|
<a name="922"><span class="lineNum"> 922 </span> : : </a>
|
|
<a name="923"><span class="lineNum"> 923 </span> : : #if GTEST_HAS_STD_WSTRING</a>
|
|
<a name="924"><span class="lineNum"> 924 </span> : : template <></a>
|
|
<a name="925"><span class="lineNum"> 925 </span> : : class UniversalTersePrinter<const wchar_t*> {</a>
|
|
<a name="926"><span class="lineNum"> 926 </span> : : public:</a>
|
|
<a name="927"><span class="lineNum"> 927 </span> : : static void Print(const wchar_t* str, ::std::ostream* os) {</a>
|
|
<a name="928"><span class="lineNum"> 928 </span> : : if (str == NULL) {</a>
|
|
<a name="929"><span class="lineNum"> 929 </span> : : *os << "NULL";</a>
|
|
<a name="930"><span class="lineNum"> 930 </span> : : } else {</a>
|
|
<a name="931"><span class="lineNum"> 931 </span> : : UniversalPrint(::std::wstring(str), os);</a>
|
|
<a name="932"><span class="lineNum"> 932 </span> : : }</a>
|
|
<a name="933"><span class="lineNum"> 933 </span> : : }</a>
|
|
<a name="934"><span class="lineNum"> 934 </span> : : };</a>
|
|
<a name="935"><span class="lineNum"> 935 </span> : : #endif</a>
|
|
<a name="936"><span class="lineNum"> 936 </span> : : </a>
|
|
<a name="937"><span class="lineNum"> 937 </span> : : template <></a>
|
|
<a name="938"><span class="lineNum"> 938 </span> : : class UniversalTersePrinter<wchar_t*> {</a>
|
|
<a name="939"><span class="lineNum"> 939 </span> : : public:</a>
|
|
<a name="940"><span class="lineNum"> 940 </span> : : static void Print(wchar_t* str, ::std::ostream* os) {</a>
|
|
<a name="941"><span class="lineNum"> 941 </span> : : UniversalTersePrinter<const wchar_t*>::Print(str, os);</a>
|
|
<a name="942"><span class="lineNum"> 942 </span> : : }</a>
|
|
<a name="943"><span class="lineNum"> 943 </span> : : };</a>
|
|
<a name="944"><span class="lineNum"> 944 </span> : : </a>
|
|
<a name="945"><span class="lineNum"> 945 </span> : : template <typename T></a>
|
|
<a name="946"><span class="lineNum"> 946 </span> : : void UniversalTersePrint(const T& value, ::std::ostream* os) {</a>
|
|
<a name="947"><span class="lineNum"> 947 </span> : : UniversalTersePrinter<T>::Print(value, os);</a>
|
|
<a name="948"><span class="lineNum"> 948 </span> : : }</a>
|
|
<a name="949"><span class="lineNum"> 949 </span> : : </a>
|
|
<a name="950"><span class="lineNum"> 950 </span> : : // Prints a value using the type inferred by the compiler. The</a>
|
|
<a name="951"><span class="lineNum"> 951 </span> : : // difference between this and UniversalTersePrint() is that for a</a>
|
|
<a name="952"><span class="lineNum"> 952 </span> : : // (const) char pointer, this prints both the pointer and the</a>
|
|
<a name="953"><span class="lineNum"> 953 </span> : : // NUL-terminated string.</a>
|
|
<a name="954"><span class="lineNum"> 954 </span> : : template <typename T></a>
|
|
<a name="955"><span class="lineNum"> 955 </span> :<span class="lineNoCov"> 0 : void UniversalPrint(const T& value, ::std::ostream* os) {</span></a>
|
|
<a name="956"><span class="lineNum"> 956 </span> : : // A workarond for the bug in VC++ 7.1 that prevents us from instantiating</a>
|
|
<a name="957"><span class="lineNum"> 957 </span> : : // UniversalPrinter with T directly.</a>
|
|
<a name="958"><span class="lineNum"> 958 </span> : : typedef T T1;</a>
|
|
<a name="959"><span class="lineNum"> 959 </span> :<span class="lineNoCov"> 0 : UniversalPrinter<T1>::Print(value, os);</span></a>
|
|
<a name="960"><span class="lineNum"> 960 </span> :<span class="lineNoCov"> 0 : }</span></a>
|
|
<a name="961"><span class="lineNum"> 961 </span> : : </a>
|
|
<a name="962"><span class="lineNum"> 962 </span> : : typedef ::std::vector< ::std::string> Strings;</a>
|
|
<a name="963"><span class="lineNum"> 963 </span> : : </a>
|
|
<a name="964"><span class="lineNum"> 964 </span> : : // TuplePolicy<TupleT> must provide:</a>
|
|
<a name="965"><span class="lineNum"> 965 </span> : : // - tuple_size</a>
|
|
<a name="966"><span class="lineNum"> 966 </span> : : // size of tuple TupleT.</a>
|
|
<a name="967"><span class="lineNum"> 967 </span> : : // - get<size_t I>(const TupleT& t)</a>
|
|
<a name="968"><span class="lineNum"> 968 </span> : : // static function extracting element I of tuple TupleT.</a>
|
|
<a name="969"><span class="lineNum"> 969 </span> : : // - tuple_element<size_t I>::type</a>
|
|
<a name="970"><span class="lineNum"> 970 </span> : : // type of element I of tuple TupleT.</a>
|
|
<a name="971"><span class="lineNum"> 971 </span> : : template <typename TupleT></a>
|
|
<a name="972"><span class="lineNum"> 972 </span> : : struct TuplePolicy;</a>
|
|
<a name="973"><span class="lineNum"> 973 </span> : : </a>
|
|
<a name="974"><span class="lineNum"> 974 </span> : : #if GTEST_HAS_TR1_TUPLE</a>
|
|
<a name="975"><span class="lineNum"> 975 </span> : : template <typename TupleT></a>
|
|
<a name="976"><span class="lineNum"> 976 </span> : : struct TuplePolicy {</a>
|
|
<a name="977"><span class="lineNum"> 977 </span> : : typedef TupleT Tuple;</a>
|
|
<a name="978"><span class="lineNum"> 978 </span> : : static const size_t tuple_size = ::std::tr1::tuple_size<Tuple>::value;</a>
|
|
<a name="979"><span class="lineNum"> 979 </span> : : </a>
|
|
<a name="980"><span class="lineNum"> 980 </span> : : template <size_t I></a>
|
|
<a name="981"><span class="lineNum"> 981 </span> : : struct tuple_element : ::std::tr1::tuple_element<static_cast<int>(I), Tuple> {</a>
|
|
<a name="982"><span class="lineNum"> 982 </span> : : };</a>
|
|
<a name="983"><span class="lineNum"> 983 </span> : : </a>
|
|
<a name="984"><span class="lineNum"> 984 </span> : : template <size_t I></a>
|
|
<a name="985"><span class="lineNum"> 985 </span> : : static typename AddReference<const typename ::std::tr1::tuple_element<</a>
|
|
<a name="986"><span class="lineNum"> 986 </span> : : #if defined(_MSC_VER) && _MSC_VER < 1900</a>
|
|
<a name="987"><span class="lineNum"> 987 </span> : : I, Tuple>::type>::type</a>
|
|
<a name="988"><span class="lineNum"> 988 </span> : : #else</a>
|
|
<a name="989"><span class="lineNum"> 989 </span> : : static_cast<int>(I), Tuple>::type>::type</a>
|
|
<a name="990"><span class="lineNum"> 990 </span> : : #endif</a>
|
|
<a name="991"><span class="lineNum"> 991 </span> : : get(const Tuple& tuple) {</a>
|
|
<a name="992"><span class="lineNum"> 992 </span> : : return ::std::tr1::get<I>(tuple);</a>
|
|
<a name="993"><span class="lineNum"> 993 </span> : : }</a>
|
|
<a name="994"><span class="lineNum"> 994 </span> : : };</a>
|
|
<a name="995"><span class="lineNum"> 995 </span> : : template <typename TupleT></a>
|
|
<a name="996"><span class="lineNum"> 996 </span> : : const size_t TuplePolicy<TupleT>::tuple_size;</a>
|
|
<a name="997"><span class="lineNum"> 997 </span> : : #endif // GTEST_HAS_TR1_TUPLE</a>
|
|
<a name="998"><span class="lineNum"> 998 </span> : : </a>
|
|
<a name="999"><span class="lineNum"> 999 </span> : : #if GTEST_HAS_STD_TUPLE_</a>
|
|
<a name="1000"><span class="lineNum"> 1000 </span> : : template <typename... Types></a>
|
|
<a name="1001"><span class="lineNum"> 1001 </span> : : struct TuplePolicy< ::std::tuple<Types...> > {</a>
|
|
<a name="1002"><span class="lineNum"> 1002 </span> : : typedef ::std::tuple<Types...> Tuple;</a>
|
|
<a name="1003"><span class="lineNum"> 1003 </span> : : static const size_t tuple_size = ::std::tuple_size<Tuple>::value;</a>
|
|
<a name="1004"><span class="lineNum"> 1004 </span> : : </a>
|
|
<a name="1005"><span class="lineNum"> 1005 </span> : : template <size_t I></a>
|
|
<a name="1006"><span class="lineNum"> 1006 </span> : : struct tuple_element : ::std::tuple_element<I, Tuple> {};</a>
|
|
<a name="1007"><span class="lineNum"> 1007 </span> : : </a>
|
|
<a name="1008"><span class="lineNum"> 1008 </span> : : template <size_t I></a>
|
|
<a name="1009"><span class="lineNum"> 1009 </span> : : static const typename ::std::tuple_element<I, Tuple>::type& get(</a>
|
|
<a name="1010"><span class="lineNum"> 1010 </span> : : const Tuple& tuple) {</a>
|
|
<a name="1011"><span class="lineNum"> 1011 </span> : : return ::std::get<I>(tuple);</a>
|
|
<a name="1012"><span class="lineNum"> 1012 </span> : : }</a>
|
|
<a name="1013"><span class="lineNum"> 1013 </span> : : };</a>
|
|
<a name="1014"><span class="lineNum"> 1014 </span> : : template <typename... Types></a>
|
|
<a name="1015"><span class="lineNum"> 1015 </span> : : const size_t TuplePolicy< ::std::tuple<Types...> >::tuple_size;</a>
|
|
<a name="1016"><span class="lineNum"> 1016 </span> : : #endif // GTEST_HAS_STD_TUPLE_</a>
|
|
<a name="1017"><span class="lineNum"> 1017 </span> : : </a>
|
|
<a name="1018"><span class="lineNum"> 1018 </span> : : #if GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_</a>
|
|
<a name="1019"><span class="lineNum"> 1019 </span> : : // This helper template allows PrintTo() for tuples and</a>
|
|
<a name="1020"><span class="lineNum"> 1020 </span> : : // UniversalTersePrintTupleFieldsToStrings() to be defined by</a>
|
|
<a name="1021"><span class="lineNum"> 1021 </span> : : // induction on the number of tuple fields. The idea is that</a>
|
|
<a name="1022"><span class="lineNum"> 1022 </span> : : // TuplePrefixPrinter<N>::PrintPrefixTo(t, os) prints the first N</a>
|
|
<a name="1023"><span class="lineNum"> 1023 </span> : : // fields in tuple t, and can be defined in terms of</a>
|
|
<a name="1024"><span class="lineNum"> 1024 </span> : : // TuplePrefixPrinter<N - 1>.</a>
|
|
<a name="1025"><span class="lineNum"> 1025 </span> : : //</a>
|
|
<a name="1026"><span class="lineNum"> 1026 </span> : : // The inductive case.</a>
|
|
<a name="1027"><span class="lineNum"> 1027 </span> : : template <size_t N></a>
|
|
<a name="1028"><span class="lineNum"> 1028 </span> : : struct TuplePrefixPrinter {</a>
|
|
<a name="1029"><span class="lineNum"> 1029 </span> : : // Prints the first N fields of a tuple.</a>
|
|
<a name="1030"><span class="lineNum"> 1030 </span> : : template <typename Tuple></a>
|
|
<a name="1031"><span class="lineNum"> 1031 </span> : : static void PrintPrefixTo(const Tuple& t, ::std::ostream* os) {</a>
|
|
<a name="1032"><span class="lineNum"> 1032 </span> : : TuplePrefixPrinter<N - 1>::PrintPrefixTo(t, os);</a>
|
|
<a name="1033"><span class="lineNum"> 1033 </span> : : GTEST_INTENTIONAL_CONST_COND_PUSH_()</a>
|
|
<a name="1034"><span class="lineNum"> 1034 </span> : : if (N > 1) {</a>
|
|
<a name="1035"><span class="lineNum"> 1035 </span> : : GTEST_INTENTIONAL_CONST_COND_POP_()</a>
|
|
<a name="1036"><span class="lineNum"> 1036 </span> : : *os << ", ";</a>
|
|
<a name="1037"><span class="lineNum"> 1037 </span> : : }</a>
|
|
<a name="1038"><span class="lineNum"> 1038 </span> : : UniversalPrinter<</a>
|
|
<a name="1039"><span class="lineNum"> 1039 </span> : : typename TuplePolicy<Tuple>::template tuple_element<N - 1>::type></a>
|
|
<a name="1040"><span class="lineNum"> 1040 </span> : : ::Print(TuplePolicy<Tuple>::template get<N - 1>(t), os);</a>
|
|
<a name="1041"><span class="lineNum"> 1041 </span> : : }</a>
|
|
<a name="1042"><span class="lineNum"> 1042 </span> : : </a>
|
|
<a name="1043"><span class="lineNum"> 1043 </span> : : // Tersely prints the first N fields of a tuple to a string vector,</a>
|
|
<a name="1044"><span class="lineNum"> 1044 </span> : : // one element for each field.</a>
|
|
<a name="1045"><span class="lineNum"> 1045 </span> : : template <typename Tuple></a>
|
|
<a name="1046"><span class="lineNum"> 1046 </span> : : static void TersePrintPrefixToStrings(const Tuple& t, Strings* strings) {</a>
|
|
<a name="1047"><span class="lineNum"> 1047 </span> : : TuplePrefixPrinter<N - 1>::TersePrintPrefixToStrings(t, strings);</a>
|
|
<a name="1048"><span class="lineNum"> 1048 </span> : : ::std::stringstream ss;</a>
|
|
<a name="1049"><span class="lineNum"> 1049 </span> : : UniversalTersePrint(TuplePolicy<Tuple>::template get<N - 1>(t), &ss);</a>
|
|
<a name="1050"><span class="lineNum"> 1050 </span> : : strings->push_back(ss.str());</a>
|
|
<a name="1051"><span class="lineNum"> 1051 </span> : : }</a>
|
|
<a name="1052"><span class="lineNum"> 1052 </span> : : };</a>
|
|
<a name="1053"><span class="lineNum"> 1053 </span> : : </a>
|
|
<a name="1054"><span class="lineNum"> 1054 </span> : : // Base case.</a>
|
|
<a name="1055"><span class="lineNum"> 1055 </span> : : template <></a>
|
|
<a name="1056"><span class="lineNum"> 1056 </span> : : struct TuplePrefixPrinter<0> {</a>
|
|
<a name="1057"><span class="lineNum"> 1057 </span> : : template <typename Tuple></a>
|
|
<a name="1058"><span class="lineNum"> 1058 </span> : : static void PrintPrefixTo(const Tuple&, ::std::ostream*) {}</a>
|
|
<a name="1059"><span class="lineNum"> 1059 </span> : : </a>
|
|
<a name="1060"><span class="lineNum"> 1060 </span> : : template <typename Tuple></a>
|
|
<a name="1061"><span class="lineNum"> 1061 </span> : : static void TersePrintPrefixToStrings(const Tuple&, Strings*) {}</a>
|
|
<a name="1062"><span class="lineNum"> 1062 </span> : : };</a>
|
|
<a name="1063"><span class="lineNum"> 1063 </span> : : </a>
|
|
<a name="1064"><span class="lineNum"> 1064 </span> : : // Helper function for printing a tuple.</a>
|
|
<a name="1065"><span class="lineNum"> 1065 </span> : : // Tuple must be either std::tr1::tuple or std::tuple type.</a>
|
|
<a name="1066"><span class="lineNum"> 1066 </span> : : template <typename Tuple></a>
|
|
<a name="1067"><span class="lineNum"> 1067 </span> : : void PrintTupleTo(const Tuple& t, ::std::ostream* os) {</a>
|
|
<a name="1068"><span class="lineNum"> 1068 </span> : : *os << "(";</a>
|
|
<a name="1069"><span class="lineNum"> 1069 </span> : : TuplePrefixPrinter<TuplePolicy<Tuple>::tuple_size>::PrintPrefixTo(t, os);</a>
|
|
<a name="1070"><span class="lineNum"> 1070 </span> : : *os << ")";</a>
|
|
<a name="1071"><span class="lineNum"> 1071 </span> : : }</a>
|
|
<a name="1072"><span class="lineNum"> 1072 </span> : : </a>
|
|
<a name="1073"><span class="lineNum"> 1073 </span> : : // Prints the fields of a tuple tersely to a string vector, one</a>
|
|
<a name="1074"><span class="lineNum"> 1074 </span> : : // element for each field. See the comment before</a>
|
|
<a name="1075"><span class="lineNum"> 1075 </span> : : // UniversalTersePrint() for how we define "tersely".</a>
|
|
<a name="1076"><span class="lineNum"> 1076 </span> : : template <typename Tuple></a>
|
|
<a name="1077"><span class="lineNum"> 1077 </span> : : Strings UniversalTersePrintTupleFieldsToStrings(const Tuple& value) {</a>
|
|
<a name="1078"><span class="lineNum"> 1078 </span> : : Strings result;</a>
|
|
<a name="1079"><span class="lineNum"> 1079 </span> : : TuplePrefixPrinter<TuplePolicy<Tuple>::tuple_size>::</a>
|
|
<a name="1080"><span class="lineNum"> 1080 </span> : : TersePrintPrefixToStrings(value, &result);</a>
|
|
<a name="1081"><span class="lineNum"> 1081 </span> : : return result;</a>
|
|
<a name="1082"><span class="lineNum"> 1082 </span> : : }</a>
|
|
<a name="1083"><span class="lineNum"> 1083 </span> : : #endif // GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_</a>
|
|
<a name="1084"><span class="lineNum"> 1084 </span> : : </a>
|
|
<a name="1085"><span class="lineNum"> 1085 </span> : : } // namespace internal</a>
|
|
<a name="1086"><span class="lineNum"> 1086 </span> : : </a>
|
|
<a name="1087"><span class="lineNum"> 1087 </span> : : #if GTEST_HAS_ABSL</a>
|
|
<a name="1088"><span class="lineNum"> 1088 </span> : : namespace internal2 {</a>
|
|
<a name="1089"><span class="lineNum"> 1089 </span> : : template <typename T></a>
|
|
<a name="1090"><span class="lineNum"> 1090 </span> : : void TypeWithoutFormatter<T, kConvertibleToStringView>::PrintValue(</a>
|
|
<a name="1091"><span class="lineNum"> 1091 </span> : : const T& value, ::std::ostream* os) {</a>
|
|
<a name="1092"><span class="lineNum"> 1092 </span> : : internal::PrintTo(absl::string_view(value), os);</a>
|
|
<a name="1093"><span class="lineNum"> 1093 </span> : : }</a>
|
|
<a name="1094"><span class="lineNum"> 1094 </span> : : } // namespace internal2</a>
|
|
<a name="1095"><span class="lineNum"> 1095 </span> : : #endif</a>
|
|
<a name="1096"><span class="lineNum"> 1096 </span> : : </a>
|
|
<a name="1097"><span class="lineNum"> 1097 </span> : : template <typename T></a>
|
|
<a name="1098"><span class="lineNum"> 1098 </span> :<span class="lineNoCov"> 0 : ::std::string PrintToString(const T& value) {</span></a>
|
|
<a name="1099"><span class="lineNum"> 1099 </span> [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov"> 0 : ::std::stringstream ss;</span></a>
|
|
<a name="1100"><span class="lineNum"> 1100 </span> [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov"> 0 : internal::UniversalTersePrinter<T>::Print(value, &ss);</span></a>
|
|
<a name="1101"><span class="lineNum"> 1101 </span> [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov"> 0 : return ss.str();</span></a>
|
|
<a name="1102"><span class="lineNum"> 1102 </span> : : }</a>
|
|
<a name="1103"><span class="lineNum"> 1103 </span> : : </a>
|
|
<a name="1104"><span class="lineNum"> 1104 </span> : : } // namespace testing</a>
|
|
<a name="1105"><span class="lineNum"> 1105 </span> : : </a>
|
|
<a name="1106"><span class="lineNum"> 1106 </span> : : // Include any custom printer added by the local installation.</a>
|
|
<a name="1107"><span class="lineNum"> 1107 </span> : : // We must include this header at the end to make sure it can use the</a>
|
|
<a name="1108"><span class="lineNum"> 1108 </span> : : // declarations from this file.</a>
|
|
<a name="1109"><span class="lineNum"> 1109 </span> : : #include "gtest/internal/custom/gtest-printers.h"</a>
|
|
<a name="1110"><span class="lineNum"> 1110 </span> : : </a>
|
|
<a name="1111"><span class="lineNum"> 1111 </span> : : #endif // GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_</a>
|
|
</pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<br>
|
|
|
|
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
<tr><td class="ruler"><img src="../../../glass.png" width=3 height=3 alt=""></td></tr>
|
|
<tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.14</a></td></tr>
|
|
</table>
|
|
<br>
|
|
|
|
</body>
|
|
</html>
|