gtest_break_on_failure_unittest_.cc
Go to the documentation of this file.
00001 // Copyright 2006, Google Inc.
00002 // All rights reserved.
00003 //
00004 // Redistribution and use in source and binary forms, with or without
00005 // modification, are permitted provided that the following conditions are
00006 // met:
00007 //
00008 //     * Redistributions of source code must retain the above copyright
00009 // notice, this list of conditions and the following disclaimer.
00010 //     * Redistributions in binary form must reproduce the above
00011 // copyright notice, this list of conditions and the following disclaimer
00012 // in the documentation and/or other materials provided with the
00013 // distribution.
00014 //     * Neither the name of Google Inc. nor the names of its
00015 // contributors may be used to endorse or promote products derived from
00016 // this software without specific prior written permission.
00017 //
00018 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00019 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00020 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00021 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00022 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00023 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00024 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00025 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00026 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00027 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00028 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029 //
00030 // Author: wan@google.com (Zhanyong Wan)
00031 
00032 // Unit test for Google Test's break-on-failure mode.
00033 //
00034 // A user can ask Google Test to seg-fault when an assertion fails, using
00035 // either the GTEST_BREAK_ON_FAILURE environment variable or the
00036 // --gtest_break_on_failure flag.  This file is used for testing such
00037 // functionality.
00038 //
00039 // This program will be invoked from a Python unit test.  It is
00040 // expected to fail.  Don't run it directly.
00041 
00042 #include "gtest/gtest.h"
00043 
00044 #if GTEST_OS_WINDOWS
00045 # include <windows.h>
00046 # include <stdlib.h>
00047 #endif
00048 
00049 namespace {
00050 
00051 // A test that's expected to fail.
00052 TEST(Foo, Bar) {
00053   EXPECT_EQ(2, 3);
00054 }
00055 
00056 #if GTEST_HAS_SEH && !GTEST_OS_WINDOWS_MOBILE
00057 // On Windows Mobile global exception handlers are not supported.
00058 LONG WINAPI ExitWithExceptionCode(
00059     struct _EXCEPTION_POINTERS* exception_pointers) {
00060   exit(exception_pointers->ExceptionRecord->ExceptionCode);
00061 }
00062 #endif
00063 
00064 }  // namespace
00065 
00066 int main(int argc, char **argv) {
00067 #if GTEST_OS_WINDOWS
00068   // Suppresses display of the Windows error dialog upon encountering
00069   // a general protection fault (segment violation).
00070   SetErrorMode(SEM_NOGPFAULTERRORBOX | SEM_FAILCRITICALERRORS);
00071 
00072 # if GTEST_HAS_SEH && !GTEST_OS_WINDOWS_MOBILE
00073 
00074   // The default unhandled exception filter does not always exit
00075   // with the exception code as exit code - for example it exits with
00076   // 0 for EXCEPTION_ACCESS_VIOLATION and 1 for EXCEPTION_BREAKPOINT
00077   // if the application is compiled in debug mode. Thus we use our own
00078   // filter which always exits with the exception code for unhandled
00079   // exceptions.
00080   SetUnhandledExceptionFilter(ExitWithExceptionCode);
00081 
00082 # endif
00083 #endif
00084 
00085   testing::InitGoogleTest(&argc, argv);
00086 
00087   return RUN_ALL_TESTS();
00088 }


ros_opcua_impl_freeopcua
Author(s): Denis Štogl
autogenerated on Sat Jun 8 2019 18:24:55