googletest-break-on-failure-unittest_.cc (googletest-release-1.11.0) | : | googletest-break-on-failure-unittest_.cc (googletest-release-1.12.0) | ||
---|---|---|---|---|
skipping to change at line 43 | skipping to change at line 43 | |||
// either the GTEST_BREAK_ON_FAILURE environment variable or the | // either the GTEST_BREAK_ON_FAILURE environment variable or the | |||
// --gtest_break_on_failure flag. This file is used for testing such | // --gtest_break_on_failure flag. This file is used for testing such | |||
// functionality. | // functionality. | |||
// | // | |||
// This program will be invoked from a Python unit test. It is | // This program will be invoked from a Python unit test. It is | |||
// expected to fail. Don't run it directly. | // expected to fail. Don't run it directly. | |||
#include "gtest/gtest.h" | #include "gtest/gtest.h" | |||
#if GTEST_OS_WINDOWS | #if GTEST_OS_WINDOWS | |||
# include <windows.h> | #include <stdlib.h> | |||
# include <stdlib.h> | #include <windows.h> | |||
#endif | #endif | |||
namespace { | namespace { | |||
// A test that's expected to fail. | // A test that's expected to fail. | |||
TEST(Foo, Bar) { | TEST(Foo, Bar) { EXPECT_EQ(2, 3); } | |||
EXPECT_EQ(2, 3); | ||||
} | ||||
#if GTEST_HAS_SEH && !GTEST_OS_WINDOWS_MOBILE | #if GTEST_HAS_SEH && !GTEST_OS_WINDOWS_MOBILE | |||
// On Windows Mobile global exception handlers are not supported. | // On Windows Mobile global exception handlers are not supported. | |||
LONG WINAPI ExitWithExceptionCode( | LONG WINAPI | |||
struct _EXCEPTION_POINTERS* exception_pointers) { | ExitWithExceptionCode(struct _EXCEPTION_POINTERS* exception_pointers) { | |||
exit(exception_pointers->ExceptionRecord->ExceptionCode); | exit(exception_pointers->ExceptionRecord->ExceptionCode); | |||
} | } | |||
#endif | #endif | |||
} // namespace | } // namespace | |||
int main(int argc, char **argv) { | int main(int argc, char** argv) { | |||
#if GTEST_OS_WINDOWS | #if GTEST_OS_WINDOWS | |||
// Suppresses display of the Windows error dialog upon encountering | // Suppresses display of the Windows error dialog upon encountering | |||
// a general protection fault (segment violation). | // a general protection fault (segment violation). | |||
SetErrorMode(SEM_NOGPFAULTERRORBOX | SEM_FAILCRITICALERRORS); | SetErrorMode(SEM_NOGPFAULTERRORBOX | SEM_FAILCRITICALERRORS); | |||
# if GTEST_HAS_SEH && !GTEST_OS_WINDOWS_MOBILE | #if GTEST_HAS_SEH && !GTEST_OS_WINDOWS_MOBILE | |||
// The default unhandled exception filter does not always exit | // The default unhandled exception filter does not always exit | |||
// with the exception code as exit code - for example it exits with | // with the exception code as exit code - for example it exits with | |||
// 0 for EXCEPTION_ACCESS_VIOLATION and 1 for EXCEPTION_BREAKPOINT | // 0 for EXCEPTION_ACCESS_VIOLATION and 1 for EXCEPTION_BREAKPOINT | |||
// if the application is compiled in debug mode. Thus we use our own | // if the application is compiled in debug mode. Thus we use our own | |||
// filter which always exits with the exception code for unhandled | // filter which always exits with the exception code for unhandled | |||
// exceptions. | // exceptions. | |||
SetUnhandledExceptionFilter(ExitWithExceptionCode); | SetUnhandledExceptionFilter(ExitWithExceptionCode); | |||
# endif | #endif | |||
#endif // GTEST_OS_WINDOWS | #endif // GTEST_OS_WINDOWS | |||
testing::InitGoogleTest(&argc, argv); | testing::InitGoogleTest(&argc, argv); | |||
return RUN_ALL_TESTS(); | return RUN_ALL_TESTS(); | |||
} | } | |||
End of changes. 6 change blocks. | ||||
10 lines changed or deleted | 8 lines changed or added |