aboutsummaryrefslogtreecommitdiffstats
path: root/test/gtest_break_on_failure_unittest_.cc
diff options
context:
space:
mode:
authorzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2010-02-02 22:33:34 +0000
committerzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2010-02-02 22:33:34 +0000
commit8d373310561a8d68d2a22ca7c6613deff5fa6e05 (patch)
tree1e9f5841133e353b24695fd8ca48a3353b35bfbe /test/gtest_break_on_failure_unittest_.cc
parent81e1cc73c83265e54b2ec7edc17e77f4d1b89e86 (diff)
downloadgoogletest-8d373310561a8d68d2a22ca7c6613deff5fa6e05.tar.gz
googletest-8d373310561a8d68d2a22ca7c6613deff5fa6e05.tar.bz2
googletest-8d373310561a8d68d2a22ca7c6613deff5fa6e05.zip
Adds support for alternate path separator on Windows, and make all tests pass with CMake and VC++ 9 (by Manuel Klimek).
Diffstat (limited to 'test/gtest_break_on_failure_unittest_.cc')
-rw-r--r--test/gtest_break_on_failure_unittest_.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/gtest_break_on_failure_unittest_.cc b/test/gtest_break_on_failure_unittest_.cc
index 10a1203b..d28d1d3d 100644
--- a/test/gtest_break_on_failure_unittest_.cc
+++ b/test/gtest_break_on_failure_unittest_.cc
@@ -43,6 +43,7 @@
#if GTEST_OS_WINDOWS
#include <windows.h>
+#include <stdlib.h>
#endif
namespace {
@@ -52,6 +53,14 @@ TEST(Foo, Bar) {
EXPECT_EQ(2, 3);
}
+#if GTEST_HAS_SEH && !GTEST_OS_WINDOWS_MOBILE
+// On Windows Mobile global exception handlers are not supported.
+LONG WINAPI ExitWithExceptionCode(
+ struct _EXCEPTION_POINTERS* exception_pointers) {
+ exit(exception_pointers->ExceptionRecord->ExceptionCode);
+}
+#endif
+
} // namespace
int main(int argc, char **argv) {
@@ -59,7 +68,18 @@ int main(int argc, char **argv) {
// Suppresses display of the Windows error dialog upon encountering
// a general protection fault (segment violation).
SetErrorMode(SEM_NOGPFAULTERRORBOX | SEM_FAILCRITICALERRORS);
+
+#if !GTEST_OS_WINDOWS_MOBILE
+ // The default unhandled exception filter does not always exit
+ // with the exception code as exit code - for example it exits with
+ // 0 for EXCEPTION_ACCESS_VIOLATION and 1 for EXCEPTION_BREAKPOINT
+ // if the application is compiled in debug mode. Thus we use our own
+ // filter which always exits with the exception code for unhandled
+ // exceptions.
+ SetUnhandledExceptionFilter(ExitWithExceptionCode);
+#endif
#endif
+
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();