| 9794 | // elements, starting at address 'begin'. |
| 9795 | template <typename T> |
| 9796 | void UniversalPrintArray(const T* begin, size_t len, ::std::ostream* os) { |
| 9797 | if (len == 0) { |
| 9798 | *os << "{}"; |
| 9799 | } else { |
| 9800 | *os << "{ "; |
| 9801 | const size_t kThreshold = 18; |
| 9802 | const size_t kChunkSize = 8; |
| 9803 | // If the array has more than kThreshold elements, we'll have to |
| 9804 | // omit some details by printing only the first and the last |
| 9805 | // kChunkSize elements. |
| 9806 | // TODO(wan@google.com): let the user control the threshold using a flag. |
| 9807 | if (len <= kThreshold) { |
| 9808 | PrintRawArrayTo(begin, len, os); |
| 9809 | } else { |
| 9810 | PrintRawArrayTo(begin, kChunkSize, os); |
| 9811 | *os << ", ..., "; |
| 9812 | PrintRawArrayTo(begin + len - kChunkSize, kChunkSize, os); |
| 9813 | } |
| 9814 | *os << " }"; |
| 9815 | } |
| 9816 | } |
| 9817 | // This overload prints a (const) char array compactly. |
| 9818 | GTEST_API_ void UniversalPrintArray(const char* begin, |
| 9819 | size_t len, |
no test coverage detected