test-main.cc 1.2 KB

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