summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvladlosev <vladlosev@861a406c-534a-0410-8894-cb66d6ee9925>2010-05-18 21:13:48 +0000
committervladlosev <vladlosev@861a406c-534a-0410-8894-cb66d6ee9925>2010-05-18 21:13:48 +0000
commit3a6fc976eaf7f79a3e8212595ccf49d72d37335b (patch)
treef05da91adcf46a58df848555809eb74929096bab /src
parent3232e6797752028fabe8daddd212e52f0ea76ee6 (diff)
downloadgtest-3a6fc976eaf7f79a3e8212595ccf49d72d37335b.tar.gz
gtest-3a6fc976eaf7f79a3e8212595ccf49d72d37335b.tar.bz2
gtest-3a6fc976eaf7f79a3e8212595ccf49d72d37335b.tar.xz
Implements printing parameters of failed parameterized tests (issue 71).
git-svn-id: http://googletest.googlecode.com/svn/trunk@435 861a406c-534a-0410-8894-cb66d6ee9925
Diffstat (limited to 'src')
-rw-r--r--src/gtest.cc33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/gtest.cc b/src/gtest.cc
index 302c327..e136a18 100644
--- a/src/gtest.cc
+++ b/src/gtest.cc
@@ -2658,6 +2658,19 @@ void ColoredPrintf(GTestColor color, const char* fmt, ...) {
va_end(args);
}
+void PrintFullTestCommentIfPresent(const TestInfo& test_info) {
+ const char* const comment = test_info.comment();
+ const char* const test_case_comment = test_info.test_case_comment();
+
+ if (test_case_comment[0] != '\0' || comment[0] != '\0') {
+ printf(", where %s", test_case_comment);
+ if (test_case_comment[0] != '\0' && comment[0] != '\0') {
+ printf(" and ");
+ }
+ printf("%s", comment);
+ }
+}
+
// This class implements the TestEventListener interface.
//
// Class PrettyUnitTestResultPrinter is copyable.
@@ -2748,11 +2761,7 @@ void PrettyUnitTestResultPrinter::OnTestCaseStart(const TestCase& test_case) {
void PrettyUnitTestResultPrinter::OnTestStart(const TestInfo& test_info) {
ColoredPrintf(COLOR_GREEN, "[ RUN ] ");
PrintTestName(test_case_name_.c_str(), test_info.name());
- if (test_info.comment()[0] == '\0') {
- printf("\n");
- } else {
- printf(", where %s\n", test_info.comment());
- }
+ printf("\n");
fflush(stdout);
}
@@ -2775,6 +2784,9 @@ void PrettyUnitTestResultPrinter::OnTestEnd(const TestInfo& test_info) {
ColoredPrintf(COLOR_RED, "[ FAILED ] ");
}
PrintTestName(test_case_name_.c_str(), test_info.name());
+ if (test_info.result()->Failed())
+ PrintFullTestCommentIfPresent(test_info);
+
if (GTEST_FLAG(print_time)) {
printf(" (%s ms)\n", internal::StreamableToString(
test_info.result()->elapsed_time()).c_str());
@@ -2823,15 +2835,8 @@ void PrettyUnitTestResultPrinter::PrintFailedTests(const UnitTest& unit_test) {
}
ColoredPrintf(COLOR_RED, "[ FAILED ] ");
printf("%s.%s", test_case.name(), test_info.name());
- if (test_case.comment()[0] != '\0' ||
- test_info.comment()[0] != '\0') {
- printf(", where %s", test_case.comment());
- if (test_case.comment()[0] != '\0' &&
- test_info.comment()[0] != '\0') {
- printf(" and ");
- }
- }
- printf("%s\n", test_info.comment());
+ PrintFullTestCommentIfPresent(test_info);
+ printf("\n");
}
}
}