comparison gtest/src/gtest-printers.cc @ 50:afef802824c1

gtest: upgrade to 1.8.0, closes #629
author David Demelier <markand@malikania.fr>
date Sat, 04 Feb 2017 19:05:46 +0100
parents 5d17168ea0af
children
comparison
equal deleted inserted replaced
49:424714e0ea58 50:afef802824c1
43 // defines Foo. 43 // defines Foo.
44 44
45 #include "gtest/gtest-printers.h" 45 #include "gtest/gtest-printers.h"
46 #include <ctype.h> 46 #include <ctype.h>
47 #include <stdio.h> 47 #include <stdio.h>
48 #include <cwchar>
48 #include <ostream> // NOLINT 49 #include <ostream> // NOLINT
49 #include <string> 50 #include <string>
50 #include "gtest/internal/gtest-port.h" 51 #include "gtest/internal/gtest-port.h"
51 52
52 namespace testing { 53 namespace testing {
54 namespace { 55 namespace {
55 56
56 using ::std::ostream; 57 using ::std::ostream;
57 58
58 // Prints a segment of bytes in the given object. 59 // Prints a segment of bytes in the given object.
60 GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_
61 GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_
62 GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_
59 void PrintByteSegmentInObjectTo(const unsigned char* obj_bytes, size_t start, 63 void PrintByteSegmentInObjectTo(const unsigned char* obj_bytes, size_t start,
60 size_t count, ostream* os) { 64 size_t count, ostream* os) {
61 char text[5] = ""; 65 char text[5] = "";
62 for (size_t i = 0; i != count; i++) { 66 for (size_t i = 0; i != count; i++) {
63 const size_t j = start + i; 67 const size_t j = start + i;
250 // Prints the given array of characters to the ostream. CharType must be either 254 // Prints the given array of characters to the ostream. CharType must be either
251 // char or wchar_t. 255 // char or wchar_t.
252 // The array starts at begin, the length is len, it may include '\0' characters 256 // The array starts at begin, the length is len, it may include '\0' characters
253 // and may not be NUL-terminated. 257 // and may not be NUL-terminated.
254 template <typename CharType> 258 template <typename CharType>
259 GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_
260 GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_
261 GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_
255 static void PrintCharsAsStringTo( 262 static void PrintCharsAsStringTo(
256 const CharType* begin, size_t len, ostream* os) { 263 const CharType* begin, size_t len, ostream* os) {
257 const char* const kQuoteBegin = sizeof(CharType) == 1 ? "\"" : "L\""; 264 const char* const kQuoteBegin = sizeof(CharType) == 1 ? "\"" : "L\"";
258 *os << kQuoteBegin; 265 *os << kQuoteBegin;
259 bool is_previous_hex = false; 266 bool is_previous_hex = false;
271 } 278 }
272 279
273 // Prints a (const) char/wchar_t array of 'len' elements, starting at address 280 // Prints a (const) char/wchar_t array of 'len' elements, starting at address
274 // 'begin'. CharType must be either char or wchar_t. 281 // 'begin'. CharType must be either char or wchar_t.
275 template <typename CharType> 282 template <typename CharType>
283 GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_
284 GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_
285 GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_
276 static void UniversalPrintCharArray( 286 static void UniversalPrintCharArray(
277 const CharType* begin, size_t len, ostream* os) { 287 const CharType* begin, size_t len, ostream* os) {
278 // The code 288 // The code
279 // const char kFoo[] = "foo"; 289 // const char kFoo[] = "foo";
280 // generates an array of 4, not 3, elements, with the last one being '\0'. 290 // generates an array of 4, not 3, elements, with the last one being '\0'.
327 void PrintTo(const wchar_t* s, ostream* os) { 337 void PrintTo(const wchar_t* s, ostream* os) {
328 if (s == NULL) { 338 if (s == NULL) {
329 *os << "NULL"; 339 *os << "NULL";
330 } else { 340 } else {
331 *os << ImplicitCast_<const void*>(s) << " pointing to "; 341 *os << ImplicitCast_<const void*>(s) << " pointing to ";
332 PrintCharsAsStringTo(s, wcslen(s), os); 342 PrintCharsAsStringTo(s, std::wcslen(s), os);
333 } 343 }
334 } 344 }
335 #endif // wchar_t is native 345 #endif // wchar_t is native
336 346
337 // Prints a ::string object. 347 // Prints a ::string object.