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 #include "gtest.h"
10
11 #ifdef _WIN32
12 # include <windows.h>
13 #endif
14
15 #ifdef _MSC_VER
16 # include <crtdbg.h>
17 #else
18 # define _CrtSetReportFile(a, b)
19 # define _CrtSetReportMode(a, b)
20 #endif
21
main(int argc,char ** argv)22 int main(int argc, char** argv) {
23 #ifdef _WIN32
24 // Don't display any error dialogs. This also suppresses message boxes
25 // on assertion failures in MinGW where _set_error_mode/CrtSetReportMode
26 // doesn't help.
27 SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX |
28 SEM_NOOPENFILEERRORBOX);
29 #endif
30 // Disable message boxes on assertion failures.
31 _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
32 _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
33 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
34 _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
35 try {
36 testing::InitGoogleTest(&argc, argv);
37 return RUN_ALL_TESTS();
38 } catch (...) {
39 // Catch all exceptions to make Coverity happy.
40 }
41 return EXIT_FAILURE;
42 }
43