Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion googletest/include/gtest/gtest.h
Original file line number Diff line number Diff line change
Expand Up @@ -1597,7 +1597,7 @@ AssertionResult CmpHelperFloatingPointEQ(const char* lhs_expression,
rhs_ss << rhs_value;

return EqFailure(lhs_expression, rhs_expression,
StringStreamToString(&lhs_ss), StringStreamToString(&rhs_ss),
StringStreamToString(lhs_ss), StringStreamToString(rhs_ss),
false);
}

Expand Down
2 changes: 1 addition & 1 deletion googletest/include/gtest/internal/gtest-string.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class GTEST_API_ String {

// Gets the content of the stringstream's buffer as an std::string. Each '\0'
// character in the buffer is replaced with "\\0".
GTEST_API_ std::string StringStreamToString(::std::stringstream* stream);
GTEST_API_ std::string StringStreamToString(const ::std::stringstream& stream);

} // namespace internal
} // namespace testing
Expand Down
20 changes: 10 additions & 10 deletions googletest/src/gtest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1343,7 +1343,7 @@ Message& Message::operator<<(const ::std::wstring& wstr) {
// Gets the text streamed to this object so far as an std::string.
// Each '\0' character in the buffer is replaced with "\\0".
std::string Message::GetString() const {
return internal::StringStreamToString(ss_.get());
return internal::StringStreamToString(*ss_);
}

namespace internal {
Expand Down Expand Up @@ -1762,8 +1762,8 @@ AssertionResult FloatingPointLE(const char* expr1, const char* expr2,

return AssertionFailure()
<< "Expected: (" << expr1 << ") <= (" << expr2 << ")\n"
<< " Actual: " << StringStreamToString(&val1_ss) << " vs "
<< StringStreamToString(&val2_ss);
<< " Actual: " << StringStreamToString(val1_ss) << " vs "
<< StringStreamToString(val2_ss);
}

} // namespace internal
Expand Down Expand Up @@ -2131,7 +2131,7 @@ std::string WideStringToUtf8(const wchar_t* str, int num_chars) {

stream << CodePointToUtf8(unicode_code_point);
}
return StringStreamToString(&stream);
return StringStreamToString(stream);
}

// Converts a wide C string to an std::string using the UTF-8 encoding.
Expand Down Expand Up @@ -2272,8 +2272,8 @@ std::string String::FormatByte(unsigned char value) {

// Converts the buffer in a stringstream to an std::string, converting NUL
// bytes to "\\0" along the way.
std::string StringStreamToString(::std::stringstream* ss) {
const ::std::string& str = ss->str();
std::string StringStreamToString(const ::std::stringstream& ss) {
const ::std::string& str = ss.str();
const char* const start = str.c_str();
const char* const end = start + str.length();

Expand Down Expand Up @@ -4058,7 +4058,7 @@ void XmlUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
FILE* xmlout = OpenFileForWriting(output_file_);
std::stringstream stream;
PrintXmlUnitTest(&stream, unit_test);
fprintf(xmlout, "%s", StringStreamToString(&stream).c_str());
fprintf(xmlout, "%s", StringStreamToString(stream).c_str());
fclose(xmlout);
}

Expand All @@ -4067,7 +4067,7 @@ void XmlUnitTestResultPrinter::ListTestsMatchingFilter(
FILE* xmlout = OpenFileForWriting(output_file_);
std::stringstream stream;
PrintXmlTestsList(&stream, test_suites);
fprintf(xmlout, "%s", StringStreamToString(&stream).c_str());
fprintf(xmlout, "%s", StringStreamToString(stream).c_str());
fclose(xmlout);
}

Expand Down Expand Up @@ -4586,7 +4586,7 @@ void JsonUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
FILE* jsonout = OpenFileForWriting(output_file_);
std::stringstream stream;
PrintJsonUnitTest(&stream, unit_test);
fprintf(jsonout, "%s", StringStreamToString(&stream).c_str());
fprintf(jsonout, "%s", StringStreamToString(stream).c_str());
fclose(jsonout);
}

Expand Down Expand Up @@ -6407,7 +6407,7 @@ void UnitTestImpl::ListTestsMatchingFilter() {
UnitTestOptions::GetAbsolutePathToOutputFile().c_str())
.PrintJsonTestList(&stream, test_suites_);
}
fprintf(fileout, "%s", StringStreamToString(&stream).c_str());
fprintf(fileout, "%s", StringStreamToString(stream).c_str());
fclose(fileout);
}
#endif // GTEST_HAS_FILE_SYSTEM
Expand Down
2 changes: 1 addition & 1 deletion googletest/test/googletest-message-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ TEST(MessageTest, StreamsToOStream) {
Message msg("Hello");
::std::stringstream ss;
ss << msg;
EXPECT_EQ("Hello", testing::internal::StringStreamToString(&ss));
EXPECT_EQ("Hello", testing::internal::StringStreamToString(ss));
}

// Tests that a Message object doesn't take up too much stack space.
Expand Down