Converts the buffer in a stringstream to an std::string, converting NUL bytes to "\\0" along the way.
| 1657 | // Converts the buffer in a stringstream to an std::string, converting NUL |
| 1658 | // bytes to "\\0" along the way. |
| 1659 | std::string StringStreamToString(::std::stringstream* ss) { |
| 1660 | const ::std::string& str = ss->str(); |
| 1661 | const char* const start = str.c_str(); |
| 1662 | const char* const end = start + str.length(); |
| 1663 | |
| 1664 | std::string result; |
| 1665 | result.reserve(2 * (end - start)); |
| 1666 | for (const char* ch = start; ch != end; ++ch) { |
| 1667 | if (*ch == '\0') { |
| 1668 | result += "\\0"; // Replaces NUL with "\\0"; |
| 1669 | } else { |
| 1670 | result += *ch; |
| 1671 | } |
| 1672 | } |
| 1673 | |
| 1674 | return result; |
| 1675 | } |
| 1676 | |
| 1677 | // Appends the user-supplied message to the Google-Test-generated message. |
| 1678 | std::string AppendUserMessage(const std::string& gtest_msg, |
no outgoing calls
no test coverage detected