| 3568 | // Result in case of an SEH exception. |
| 3569 | template <class T, typename Result> |
| 3570 | Result HandleExceptionsInMethodIfSupported( |
| 3571 | T* object, Result (T::*method)(), const char* location) { |
| 3572 | // NOTE: The user code can affect the way in which Google Test handles |
| 3573 | // exceptions by setting GTEST_FLAG(catch_exceptions), but only before |
| 3574 | // RUN_ALL_TESTS() starts. It is technically possible to check the flag |
| 3575 | // after the exception is caught and either report or re-throw the |
| 3576 | // exception based on the flag's value: |
| 3577 | // |
| 3578 | // try { |
| 3579 | // // Perform the test method. |
| 3580 | // } catch (...) { |
| 3581 | // if (GTEST_FLAG(catch_exceptions)) |
| 3582 | // // Report the exception as failure. |
| 3583 | // else |
| 3584 | // throw; // Re-throws the original exception. |
| 3585 | // } |
| 3586 | // |
| 3587 | // However, the purpose of this flag is to allow the program to drop into |
| 3588 | // the debugger when the exception is thrown. On most platforms, once the |
| 3589 | // control enters the catch block, the exception origin information is |
| 3590 | // lost and the debugger will stop the program at the point of the |
| 3591 | // re-throw in this function -- instead of at the point of the original |
| 3592 | // throw statement in the code under test. For this reason, we perform |
| 3593 | // the check early, sacrificing the ability to affect Google Test's |
| 3594 | // exception handling in the method where the exception is thrown. |
| 3595 | if (internal::GetUnitTestImpl()->catch_exceptions()) { |
| 3596 | #if GTEST_HAS_EXCEPTIONS |
| 3597 | try { |
| 3598 | return HandleSehExceptionsInMethodIfSupported(object, method, location); |
| 3599 | } catch (const internal::GoogleTestFailureException&) { // NOLINT |
| 3600 | // This exception type can only be thrown by a failed Google |
| 3601 | // Test assertion with the intention of letting another testing |
| 3602 | // framework catch it. Therefore we just re-throw it. |
| 3603 | throw; |
| 3604 | } catch (const std::exception& e) { // NOLINT |
| 3605 | internal::ReportFailureInUnknownLocation( |
| 3606 | TestPartResult::kFatalFailure, |
| 3607 | FormatCxxExceptionMessage(e.what(), location)); |
| 3608 | } catch (...) { // NOLINT |
| 3609 | internal::ReportFailureInUnknownLocation( |
| 3610 | TestPartResult::kFatalFailure, |
| 3611 | FormatCxxExceptionMessage(NULL, location)); |
| 3612 | } |
| 3613 | return static_cast<Result>(0); |
| 3614 | #else |
| 3615 | return HandleSehExceptionsInMethodIfSupported(object, method, location); |
| 3616 | #endif // GTEST_HAS_EXCEPTIONS |
| 3617 | } else { |
| 3618 | return (object->*method)(); |
| 3619 | } |
| 3620 | } |
| 3621 | |
| 3622 | } // namespace internal |
| 3623 |
no test coverage detected