1 // Formatting library for C++ - test main function.
2 //
3 // Copyright (c) 2012 - present, Victor Zverovich
4 // All rights reserved.
5 //
6 // For the license information refer to format.h.
7
8 #include <cstdlib>
9
10 #include "gtest.h"
11
12 #ifdef _WIN32
13 # include <windows.h>
14 #endif
15
16 #ifdef _MSC_VER
17 # include <crtdbg.h>
18 #else
19 # define _CrtSetReportFile(a, b)
20 # define _CrtSetReportMode(a, b)
21 #endif
22
main(int argc,char ** argv)23 int main(int argc, char** argv) {
24 #ifdef _WIN32
25 // Don't display any error dialogs. This also suppresses message boxes
26 // on assertion failures in MinGW where _set_error_mode/CrtSetReportMode
27 // doesn't help.
28 SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX |
29 SEM_NOOPENFILEERRORBOX);
30 #endif
31 // Disable message boxes on assertion failures.
32 _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
33 _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
34 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
35 _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
36 try {
37 testing::InitGoogleTest(&argc, argv);
38 return RUN_ALL_TESTS();
39 } catch (...) {
40 // Catch all exceptions to make Coverity happy.
41 }
42 return EXIT_FAILURE;
43 }
44