X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=gtest_sdl_main.cpp;h=e3051ad3518a86c8c48055d00ed5b694644e32de;hp=90a929edd7d330853c44a7d291ce7aeca3b24e7b;hb=240454ecb79e895dfebfab146174bd7458af4e42;hpb=34036d849937f22c0addfcba44f65207c96deddc diff --git a/gtest_sdl_main.cpp b/gtest_sdl_main.cpp index 90a929e..e3051ad 100644 --- a/gtest_sdl_main.cpp +++ b/gtest_sdl_main.cpp @@ -9,6 +9,9 @@ #include #include #endif +#ifdef HAVE_BENCHMARK +#include +#endif #include #include @@ -44,14 +47,28 @@ int main(int argc, char **argv) { 32, 32, SDL_WINDOW_OPENGL); SDL_GLContext context = SDL_GL_CreateContext(window); - assert(context != NULL); + assert(context != nullptr); #else SDL_SetVideoMode(32, 32, 0, SDL_OPENGL); - SDL_WM_SetCaption("OpenGL window for unit test", NULL); + SDL_WM_SetCaption("OpenGL window for unit test", nullptr); #endif - testing::InitGoogleTest(&argc, argv); - int err = RUN_ALL_TESTS(); + int err; + if (argc >= 2 && strcmp(argv[1], "--benchmark") == 0) { +#ifdef HAVE_BENCHMARK + --argc; + ::benchmark::Initialize(&argc, argv + 1); + if (::benchmark::ReportUnrecognizedArguments(argc, argv)) return 1; + ::benchmark::RunSpecifiedBenchmarks(); + err = 0; +#else + fprintf(stderr, "No support for microbenchmarks compiled in.\n"); + err = 1; +#endif + } else { + testing::InitGoogleTest(&argc, argv); + err = RUN_ALL_TESTS(); + } SDL_Quit(); - exit(err); + return err; }