Converts the buffer in a stringstream to an std::string, converting NUL bytes to "\\0" along the way.
| 3477 | // Converts the buffer in a stringstream to an std::string, converting NUL |
| 3478 | // bytes to "\\0" along the way. |
| 3479 | std::string StringStreamToString(::std::stringstream* ss) { |
| 3480 | const ::std::string& str = ss->str(); |
| 3481 | const char* const start = str.c_str(); |
| 3482 | const char* const end = start + str.length(); |
| 3483 | |
| 3484 | std::string result; |
| 3485 | result.reserve(static_cast<size_t>(2 * (end - start))); |
| 3486 | for (const char* ch = start; ch != end; ++ch) { |
| 3487 | if (*ch == '\0') { |
| 3488 | result += "\\0"; // Replaces NUL with "\\0"; |
| 3489 | } else { |
| 3490 | result += *ch; |
| 3491 | } |
| 3492 | } |
| 3493 | |
| 3494 | return result; |
| 3495 | } |
| 3496 | |
| 3497 | // Appends the user-supplied message to the Google-Test-generated message. |
| 3498 | std::string AppendUserMessage(const std::string& gtest_msg, |
no outgoing calls
no test coverage detected