mirror of
https://github.com/google/googletest.git
synced 2025-12-06 16:57:00 +08:00
Merge cd6637cf30d68a9df84488122d14c1a699a73615 into 1b96fa13f549387b7549cc89e1a785cf143a1a50
This commit is contained in:
commit
7a34b0581e
@ -1597,7 +1597,7 @@ AssertionResult CmpHelperFloatingPointEQ(const char* lhs_expression,
|
|||||||
rhs_ss << rhs_value;
|
rhs_ss << rhs_value;
|
||||||
|
|
||||||
return EqFailure(lhs_expression, rhs_expression,
|
return EqFailure(lhs_expression, rhs_expression,
|
||||||
StringStreamToString(&lhs_ss), StringStreamToString(&rhs_ss),
|
StringStreamToString(lhs_ss), StringStreamToString(rhs_ss),
|
||||||
false);
|
false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -170,7 +170,7 @@ class GTEST_API_ String {
|
|||||||
|
|
||||||
// Gets the content of the stringstream's buffer as an std::string. Each '\0'
|
// Gets the content of the stringstream's buffer as an std::string. Each '\0'
|
||||||
// character in the buffer is replaced with "\\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 internal
|
||||||
} // namespace testing
|
} // namespace testing
|
||||||
|
|||||||
@ -1343,7 +1343,7 @@ Message& Message::operator<<(const ::std::wstring& wstr) {
|
|||||||
// Gets the text streamed to this object so far as an std::string.
|
// Gets the text streamed to this object so far as an std::string.
|
||||||
// Each '\0' character in the buffer is replaced with "\\0".
|
// Each '\0' character in the buffer is replaced with "\\0".
|
||||||
std::string Message::GetString() const {
|
std::string Message::GetString() const {
|
||||||
return internal::StringStreamToString(ss_.get());
|
return internal::StringStreamToString(*ss_);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
@ -1762,8 +1762,8 @@ AssertionResult FloatingPointLE(const char* expr1, const char* expr2,
|
|||||||
|
|
||||||
return AssertionFailure()
|
return AssertionFailure()
|
||||||
<< "Expected: (" << expr1 << ") <= (" << expr2 << ")\n"
|
<< "Expected: (" << expr1 << ") <= (" << expr2 << ")\n"
|
||||||
<< " Actual: " << StringStreamToString(&val1_ss) << " vs "
|
<< " Actual: " << StringStreamToString(val1_ss) << " vs "
|
||||||
<< StringStreamToString(&val2_ss);
|
<< StringStreamToString(val2_ss);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
@ -2131,7 +2131,7 @@ std::string WideStringToUtf8(const wchar_t* str, int num_chars) {
|
|||||||
|
|
||||||
stream << CodePointToUtf8(unicode_code_point);
|
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.
|
// Converts a wide C string to an std::string using the UTF-8 encoding.
|
||||||
@ -2272,8 +2272,8 @@ std::string String::FormatByte(unsigned char value) {
|
|||||||
|
|
||||||
// Converts the buffer in a stringstream to an std::string, converting NUL
|
// Converts the buffer in a stringstream to an std::string, converting NUL
|
||||||
// bytes to "\\0" along the way.
|
// bytes to "\\0" along the way.
|
||||||
std::string StringStreamToString(::std::stringstream* ss) {
|
std::string StringStreamToString(const ::std::stringstream& ss) {
|
||||||
const ::std::string& str = ss->str();
|
const ::std::string& str = ss.str();
|
||||||
const char* const start = str.c_str();
|
const char* const start = str.c_str();
|
||||||
const char* const end = start + str.length();
|
const char* const end = start + str.length();
|
||||||
|
|
||||||
@ -4058,7 +4058,7 @@ void XmlUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
|
|||||||
FILE* xmlout = OpenFileForWriting(output_file_);
|
FILE* xmlout = OpenFileForWriting(output_file_);
|
||||||
std::stringstream stream;
|
std::stringstream stream;
|
||||||
PrintXmlUnitTest(&stream, unit_test);
|
PrintXmlUnitTest(&stream, unit_test);
|
||||||
fprintf(xmlout, "%s", StringStreamToString(&stream).c_str());
|
fprintf(xmlout, "%s", StringStreamToString(stream).c_str());
|
||||||
fclose(xmlout);
|
fclose(xmlout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4067,7 +4067,7 @@ void XmlUnitTestResultPrinter::ListTestsMatchingFilter(
|
|||||||
FILE* xmlout = OpenFileForWriting(output_file_);
|
FILE* xmlout = OpenFileForWriting(output_file_);
|
||||||
std::stringstream stream;
|
std::stringstream stream;
|
||||||
PrintXmlTestsList(&stream, test_suites);
|
PrintXmlTestsList(&stream, test_suites);
|
||||||
fprintf(xmlout, "%s", StringStreamToString(&stream).c_str());
|
fprintf(xmlout, "%s", StringStreamToString(stream).c_str());
|
||||||
fclose(xmlout);
|
fclose(xmlout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4586,7 +4586,7 @@ void JsonUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
|
|||||||
FILE* jsonout = OpenFileForWriting(output_file_);
|
FILE* jsonout = OpenFileForWriting(output_file_);
|
||||||
std::stringstream stream;
|
std::stringstream stream;
|
||||||
PrintJsonUnitTest(&stream, unit_test);
|
PrintJsonUnitTest(&stream, unit_test);
|
||||||
fprintf(jsonout, "%s", StringStreamToString(&stream).c_str());
|
fprintf(jsonout, "%s", StringStreamToString(stream).c_str());
|
||||||
fclose(jsonout);
|
fclose(jsonout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6409,7 +6409,7 @@ void UnitTestImpl::ListTestsMatchingFilter() {
|
|||||||
UnitTestOptions::GetAbsolutePathToOutputFile().c_str())
|
UnitTestOptions::GetAbsolutePathToOutputFile().c_str())
|
||||||
.PrintJsonTestList(&stream, test_suites_);
|
.PrintJsonTestList(&stream, test_suites_);
|
||||||
}
|
}
|
||||||
fprintf(fileout, "%s", StringStreamToString(&stream).c_str());
|
fprintf(fileout, "%s", StringStreamToString(stream).c_str());
|
||||||
fclose(fileout);
|
fclose(fileout);
|
||||||
}
|
}
|
||||||
#endif // GTEST_HAS_FILE_SYSTEM
|
#endif // GTEST_HAS_FILE_SYSTEM
|
||||||
|
|||||||
@ -173,7 +173,7 @@ TEST(MessageTest, StreamsToOStream) {
|
|||||||
Message msg("Hello");
|
Message msg("Hello");
|
||||||
::std::stringstream ss;
|
::std::stringstream ss;
|
||||||
ss << msg;
|
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.
|
// Tests that a Message object doesn't take up too much stack space.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user