00001 #ifndef COMMON__TEST_ASSERT_IMPL__H
00002 #define COMMON__TEST_ASSERT_IMPL__H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef TEST_ASSERT__H
00038 # error "Must not use this header alone, but from a proper wrapper."
00039 #endif
00040
00041 #if defined(NCBI_OS_MSWIN)
00042 # ifndef NCBI_MSWIN_NO_POPUP
00043 # ifdef _ASSERT
00044 # undef _ASSERT
00045 # endif
00046 # define Type aType
00047 # endif
00048 # include <crtdbg.h>
00049 # include <stdio.h>
00050 # include <windows.h>
00051 # ifndef NCBI_MSWIN_NO_POPUP
00052 # undef Type
00053 # endif
00054
00055
00056
00057
00058
00059
00060
00061
00062 static LONG CALLBACK _SEH_Handler(EXCEPTION_POINTERS* ep)
00063 {
00064
00065 return EXCEPTION_EXECUTE_HANDLER;
00066 }
00067
00068 static int _SuppressDiagPopupMessages(void)
00069 {
00070 #ifndef NCBI_MSWIN_NO_POPUP_EVER
00071
00072 const char* value = getenv("DIAG_SILENT_ABORT");
00073 if (value && (*value == 'Y' || *value == 'y')) {
00074 #endif
00075
00076 SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX |
00077 SEM_NOOPENFILEERRORBOX);
00078
00079
00080 _set_error_mode(_OUT_TO_STDERR);
00081
00082
00083 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
00084 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
00085 _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
00086 _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
00087 _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
00088 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
00089
00090
00091 SetUnhandledExceptionFilter(_SEH_Handler);
00092 #ifndef NCBI_MSWIN_NO_POPUP_EVER
00093 }
00094 #endif
00095 return 0;
00096 }
00097
00098
00099
00100
00101 # if _MSC_VER >= 1400
00102 # pragma section(".CRT$XIV", read)
00103 # endif
00104 # pragma data_seg(".CRT$XIV")
00105 static int (*_SDPM)(void) = _SuppressDiagPopupMessages;
00106 # pragma data_seg()
00107
00108 #endif
00109
00110
00111
00112
00113 #ifndef NCBI_MSWIN_NO_POPUP
00114
00115 #ifdef NDEBUG
00116 # undef NDEBUG
00117 #endif
00118 #ifdef assert
00119 # undef assert
00120 #endif
00121
00122
00123 #ifdef NCBI_OS_IRIX
00124 # ifdef __ASSERT_H__
00125 # undef __ASSERT_H__
00126 # endif
00127 #endif
00128
00129
00130 #ifdef NCBI_OS_OSF1
00131 # ifdef _ASSERT_H_
00132 # undef _ASSERT_H_
00133 # endif
00134 #endif
00135
00136
00137 #ifdef NCBI_OS_DARWIN
00138 # ifdef FIXINC_BROKEN_ASSERT_STDLIB_CHECK
00139 # undef FIXINC_BROKEN_ASSERT_STDLIB_CHECK
00140 # endif
00141 #endif
00142
00143 #include <assert.h>
00144
00145 #ifdef _ASSERT
00146 # undef _ASSERT
00147 #endif
00148 #define _ASSERT assert
00149
00150 #ifdef _TROUBLE
00151 # undef _TROUBLE
00152 #endif
00153 #define _TROUBLE assert(0)
00154
00155 #endif
00156
00157 #endif
00158
00159