From 682c89f7557eb53c7359b6cbf3670c05165f2419 Mon Sep 17 00:00:00 2001 From: "zhanyong.wan" Date: Wed, 16 Jun 2010 22:47:13 +0000 Subject: Makes gtest report failures in ad hoc test assertions executed before RUN_ALL_TESTS(). --- src/gtest-internal-inl.h | 8 ++++++-- src/gtest.cc | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gtest-internal-inl.h b/src/gtest-internal-inl.h index 9e63aed7..c5608c99 100644 --- a/src/gtest-internal-inl.h +++ b/src/gtest-internal-inl.h @@ -754,9 +754,13 @@ class GTEST_API_ UnitTestImpl { // doesn't apply there.) int RunAllTests(); - // Clears the results of all tests, including the ad hoc test. - void ClearResult() { + // Clears the results of all tests, except the ad hoc tests. + void ClearNonAdHocTestResult() { ForEach(test_cases_, TestCase::ClearTestCaseResult); + } + + // Clears the results of ad-hoc test assertions. + void ClearAdHocTestResult() { ad_hoc_test_result_.Clear(); } diff --git a/src/gtest.cc b/src/gtest.cc index e136a18b..cb2c34c7 100644 --- a/src/gtest.cc +++ b/src/gtest.cc @@ -3999,7 +3999,9 @@ int UnitTestImpl::RunAllTests() { // Repeats forever if the repeat count is negative. const bool forever = repeat < 0; for (int i = 0; forever || i != repeat; i++) { - ClearResult(); + // We want to preserve failures generated by ad-hoc test + // assertions executed before RUN_ALL_TESTS(). + ClearNonAdHocTestResult(); const TimeInMillis start = GetTimeInMillis(); -- cgit v1.2.3