aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2009-07-15 19:01:51 +0000
committerzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2009-07-15 19:01:51 +0000
commit3a47ddf8ea888b4e5fe06bf79ef03a1456274f00 (patch)
treef3d8ae11bef8344c1ba48d3068efddc724a3d1ff /src
parent8bdb31e0540c46de485b362178f60e8bb947ff43 (diff)
downloadgoogletest-3a47ddf8ea888b4e5fe06bf79ef03a1456274f00.tar.gz
googletest-3a47ddf8ea888b4e5fe06bf79ef03a1456274f00.tar.bz2
googletest-3a47ddf8ea888b4e5fe06bf79ef03a1456274f00.zip
Makes gtest report failures to Visual Studio's Output window. Based on code by Alexander Demin.
Diffstat (limited to 'src')
-rw-r--r--src/gtest.cc18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/gtest.cc b/src/gtest.cc
index 7bdf18ad..bc970173 100644
--- a/src/gtest.cc
+++ b/src/gtest.cc
@@ -2556,10 +2556,19 @@ static internal::String PrintTestPartResultToString(
}
// Prints a TestPartResult.
-static void PrintTestPartResult(
- const TestPartResult& test_part_result) {
- printf("%s\n", PrintTestPartResultToString(test_part_result).c_str());
+static void PrintTestPartResult(const TestPartResult& test_part_result) {
+ const internal::String& result =
+ PrintTestPartResultToString(test_part_result);
+ printf("%s\n", result.c_str());
fflush(stdout);
+#if GTEST_OS_WINDOWS
+ // If the test program runs in Visual Studio or a debugger, the
+ // following states add the test part result message to the Output
+ // window such that the user can double-click on it to jump to the
+ // corresponding source code location; otherwise they do nothing.
+ ::OutputDebugStringA(result.c_str());
+ ::OutputDebugStringA("\n");
+#endif
}
// class PrettyUnitTestResultPrinter
@@ -3426,7 +3435,8 @@ void UnitTest::AddTestPartResult(TestPartResultType result_type,
for (int i = 0; i < impl_->gtest_trace_stack()->size(); i++) {
const internal::TraceInfo& trace =
impl_->gtest_trace_stack()->GetElement(i);
- msg << "\n" << trace.file << ":" << trace.line << ": " << trace.message;
+ msg << "\n" << internal::FormatFileLocation(trace.file, trace.line)
+ << " " << trace.message;
}
}