tesseract v5.3.3.20231005
testing::Message Class Reference

#include <gtest-message.h>

Public Member Functions

 Message ()
 
 Message (const Message &msg)
 
 Message (const char *str)
 
template<typename T >
Messageoperator<< (const T &val)
 
template<typename T >
Messageoperator<< (T *const &pointer)
 
Messageoperator<< (BasicNarrowIoManip val)
 
Messageoperator<< (bool b)
 
Messageoperator<< (const wchar_t *wide_c_str)
 
Messageoperator<< (wchar_t *wide_c_str)
 
std::string GetString () const
 

Detailed Description

Definition at line 91 of file gtest-message.h.

Constructor & Destructor Documentation

◆ Message() [1/3]

testing::Message::Message ( )

Definition at line 1156 of file gtest.cc.

1156 : ss_(new ::std::stringstream) {
1157 // By default, we want there to be enough precision when printing
1158 // a double to a Message.
1159 *ss_ << std::setprecision(std::numeric_limits<double>::digits10 + 2);
1160}

◆ Message() [2/3]

testing::Message::Message ( const Message msg)
inline

Definition at line 102 of file gtest-message.h.

102 : ss_(new ::std::stringstream) { // NOLINT
103 *ss_ << msg.GetString();
104 }

◆ Message() [3/3]

testing::Message::Message ( const char *  str)
inlineexplicit

Definition at line 107 of file gtest-message.h.

107 : ss_(new ::std::stringstream) {
108 *ss_ << str;
109 }

Member Function Documentation

◆ GetString()

std::string testing::Message::GetString ( ) const

Definition at line 1182 of file gtest.cc.

1182 {
1183 return internal::StringStreamToString(ss_.get());
1184}
GTEST_API_ std::string StringStreamToString(::std::stringstream *stream)
Definition: gtest.cc:2164

◆ operator<<() [1/6]

Message & testing::Message::operator<< ( BasicNarrowIoManip  val)
inline

Definition at line 162 of file gtest-message.h.

162 {
163 *ss_ << val;
164 return *this;
165 }

◆ operator<<() [2/6]

Message & testing::Message::operator<< ( bool  b)
inline

Definition at line 168 of file gtest-message.h.

168 {
169 return *this << (b ? "true" : "false");
170 }

◆ operator<<() [3/6]

template<typename T >
Message & testing::Message::operator<< ( const T &  val)
inline

Definition at line 113 of file gtest-message.h.

113 {
114 // Some libraries overload << for STL containers. These
115 // overloads are defined in the global namespace instead of ::std.
116 //
117 // C++'s symbol lookup rule (i.e. Koenig lookup) says that these
118 // overloads are visible in either the std namespace or the global
119 // namespace, but not other namespaces, including the testing
120 // namespace which Google Test's Message class is in.
121 //
122 // To allow STL containers (and other types that has a << operator
123 // defined in the global namespace) to be used in Google Test
124 // assertions, testing::Message must access the custom << operator
125 // from the global namespace. With this using declaration,
126 // overloads of << defined in the global namespace and those
127 // visible via Koenig lookup are both exposed in this function.
128 using ::operator <<;
129 *ss_ << val;
130 return *this;
131 }

◆ operator<<() [4/6]

Message & testing::Message::operator<< ( const wchar_t *  wide_c_str)

Definition at line 1164 of file gtest.cc.

1164 {
1165 return *this << internal::String::ShowWideCString(wide_c_str);
1166}
static std::string ShowWideCString(const wchar_t *wide_c_str)
Definition: gtest.cc:2022

◆ operator<<() [5/6]

template<typename T >
Message & testing::Message::operator<< ( T *const &  pointer)
inline

Definition at line 147 of file gtest-message.h.

147 { // NOLINT
148 if (pointer == nullptr) {
149 *ss_ << "(null)";
150 } else {
151 *ss_ << pointer;
152 }
153 return *this;
154 }

◆ operator<<() [6/6]

Message & testing::Message::operator<< ( wchar_t *  wide_c_str)

Definition at line 1167 of file gtest.cc.

1167 {
1168 return *this << internal::String::ShowWideCString(wide_c_str);
1169}

The documentation for this class was generated from the following files: