diff options
author | vladlosev <vladlosev@861a406c-534a-0410-8894-cb66d6ee9925> | 2011-06-13 19:00:37 +0000 |
---|---|---|
committer | vladlosev <vladlosev@861a406c-534a-0410-8894-cb66d6ee9925> | 2011-06-13 19:00:37 +0000 |
commit | cc265df8b44e613ca118ce5da145f91d66f6c440 (patch) | |
tree | 800a32dcfa5f87dcd0d6735b57d1c72e14305d5f /test/gtest_throw_on_failure_test_.cc | |
parent | 7e29bb7f7ebc2a1734415cb64395d87fc87d12be (diff) | |
download | googletest-cc265df8b44e613ca118ce5da145f91d66f6c440.tar.gz googletest-cc265df8b44e613ca118ce5da145f91d66f6c440.tar.bz2 googletest-cc265df8b44e613ca118ce5da145f91d66f6c440.zip |
Fixes broken build on VC++ 7.1.
Diffstat (limited to 'test/gtest_throw_on_failure_test_.cc')
-rw-r--r-- | test/gtest_throw_on_failure_test_.cc | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/test/gtest_throw_on_failure_test_.cc b/test/gtest_throw_on_failure_test_.cc index 03776ecb..2b88fe3d 100644 --- a/test/gtest_throw_on_failure_test_.cc +++ b/test/gtest_throw_on_failure_test_.cc @@ -37,12 +37,28 @@ #include "gtest/gtest.h" +#include <stdio.h> // for fflush, fprintf, NULL, etc. +#include <stdlib.h> // for exit +#include <exception> // for set_terminate + +// This terminate handler aborts the program using exit() rather than abort(). +// This avoids showing pop-ups on Windows systems and core dumps on Unix-like +// ones. +void TerminateHandler() { + fprintf(stderr, "%s\n", "Unhandled C++ exception terminating the program."); + fflush(NULL); + exit(1); +} + int main(int argc, char** argv) { +#if GTEST_HAS_EXCEPTIONS + std::set_terminate(&TerminateHandler); +#endif testing::InitGoogleTest(&argc, argv); // We want to ensure that people can use Google Test assertions in // other testing frameworks, as long as they initialize Google Test - // properly and set the thrown-on-failure mode. Therefore, we don't + // properly and set the throw-on-failure mode. Therefore, we don't // use Google Test's constructs for defining and running tests // (e.g. TEST and RUN_ALL_TESTS) here. |