Use FormatFileLocation for streaming file and line

This commit is contained in:
Joshua Cannon 2019-10-07 13:56:47 -05:00
parent 76a560c81c
commit 2ed2211db9
2 changed files with 4 additions and 2 deletions

View File

@ -34,6 +34,7 @@
// EXPECT_CALL). // EXPECT_CALL).
#include "gmock/gmock-spec-builders.h" #include "gmock/gmock-spec-builders.h"
#include "gtest/internal/gtest-port.h"
#include <stdlib.h> #include <stdlib.h>
#include <iostream> // NOLINT #include <iostream> // NOLINT
@ -70,7 +71,7 @@ GTEST_API_ void LogWithLocation(testing::internal::LogSeverity severity,
const char* file, int line, const char* file, int line,
const std::string& message) { const std::string& message) {
::std::ostringstream s; ::std::ostringstream s;
s << file << ":" << line << ": " << message << ::std::endl; s << internal::FormatFileLocation(file, line) << " " << message << ::std::endl;
Log(severity, s.str(), 0); Log(severity, s.str(), 0);
} }

View File

@ -31,6 +31,7 @@
// The Google C++ Testing and Mocking Framework (Google Test) // The Google C++ Testing and Mocking Framework (Google Test)
#include "gtest/gtest-test-part.h" #include "gtest/gtest-test-part.h"
#include "gtest/internal/gtest-port.h"
#include "src/gtest-internal-inl.h" #include "src/gtest-internal-inl.h"
namespace testing { namespace testing {
@ -46,7 +47,7 @@ std::string TestPartResult::ExtractSummary(const char* message) {
// Prints a TestPartResult object. // Prints a TestPartResult object.
std::ostream& operator<<(std::ostream& os, const TestPartResult& result) { std::ostream& operator<<(std::ostream& os, const TestPartResult& result) {
return os << result.file_name() << ":" << result.line_number() << ": " return os << internal::FormatFileLocation(result.file_name(), result.line_number()) << " "
<< (result.type() == TestPartResult::kSuccess << (result.type() == TestPartResult::kSuccess
? "Success" ? "Success"
: result.type() == TestPartResult::kSkip : result.type() == TestPartResult::kSkip