sdl2-compat: sync tests and the testlib with current SDL2 branch

From 718fea66f4af6770fb40613ae6899dd099eda884 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Fri, 19 May 2023 17:03:56 +0300
Subject: [PATCH] sync tests and the testlib with current SDL2 branch

---
 src/test/SDL_test_assert.c               |   24 +-
 src/test/SDL_test_common.c               |  505 +-
 src/test/SDL_test_compare.c              |  149 +-
 src/test/SDL_test_crc32.c                |  183 +-
 src/test/SDL_test_font.c                 | 4178 ++++++++--------
 src/test/SDL_test_fuzzer.c               |  238 +-
 src/test/SDL_test_harness.c              |  233 +-
 src/test/SDL_test_imageBlit.c            | 3104 ++++++------
 src/test/SDL_test_imageBlitBlend.c       | 5625 +++++++++++-----------
 src/test/SDL_test_imageFace.c            |  410 +-
 src/test/SDL_test_imagePrimitives.c      |  958 ++--
 src/test/SDL_test_imagePrimitivesBlend.c | 1313 ++---
 src/test/SDL_test_log.c                  |   17 +-
 src/test/SDL_test_md5.c                  |  427 +-
 src/test/SDL_test_memory.c               |   40 +-
 src/test/SDL_test_random.c               |   91 +-
 test/checkkeys.c                         |   85 +-
 test/checkkeysthreads.c                  |  104 +-
 test/controllermap.c                     |  142 +-
 test/gles2funcs.h                        |    6 +-
 test/glfuncs.h                           |  286 +-
 test/loopwave.c                          |   26 +-
 test/loopwavequeue.c                     |   46 +-
 test/testatomic.c                        |  204 +-
 test/testaudiocapture.c                  |   20 +-
 test/testaudiohotplug.c                  |   54 +-
 test/testaudioinfo.c                     |   19 +-
 test/testautomation.c                    |   37 +-
 test/testautomation_audio.c              | 1471 +++---
 test/testautomation_clipboard.c          |   79 +-
 test/testautomation_events.c             |  242 +-
 test/testautomation_guid.c               |   45 +-
 test/testautomation_hints.c              |  339 +-
 test/testautomation_joystick.c           |    7 +-
 test/testautomation_keyboard.c           | 1035 ++--
 test/testautomation_main.c               |   70 +-
 test/testautomation_math.c               |  312 +-
 test/testautomation_mouse.c              |  537 ++-
 test/testautomation_pixels.c             |  457 +-
 test/testautomation_platform.c           |  725 +--
 test/testautomation_rect.c               |  799 +--
 test/testautomation_render.c             | 1750 +++----
 test/testautomation_rwops.c              |  831 ++--
 test/testautomation_sdltest.c            | 2312 +++++----
 test/testautomation_stdlib.c             |  929 ++--
 test/testautomation_suites.h             |    2 +-
 test/testautomation_surface.c            |  448 +-
 test/testautomation_syswm.c              |   28 +-
 test/testautomation_timer.c              |  241 +-
 test/testautomation_video.c              | 2922 +++++------
 test/testbounds.c                        |    4 +-
 test/testcustomcursor.c                  |  224 +-
 test/testdisplayinfo.c                   |   10 +-
 test/testdraw2.c                         |   57 +-
 test/testdrawchessboard.c                |   62 +-
 test/testdropfile.c                      |   15 +-
 test/testerror.c                         |   15 +-
 test/testevdev.c                         |   52 +-
 test/testfile.c                          |  291 +-
 test/testfilesystem.c                    |   23 +-
 test/testgamecontroller.c                |  168 +-
 test/testgeometry.c                      |   34 +-
 test/testgesture.c                       |  154 +-
 test/testgl2.c                           |   94 +-
 test/testgles.c                          |  125 +-
 test/testgles2.c                         |  326 +-
 test/testgles2_sdf.c                     |  244 +-
 test/testhaptic.c                        |   98 +-
 test/testhittesting.c                    |   66 +-
 test/testhotplug.c                       |  152 +-
 test/testiconv.c                         |   21 +-
 test/testime.c                           |  419 +-
 test/testintersections.c                 |   87 +-
 test/testjoystick.c                      |   47 +-
 test/testkeys.c                          |    9 +-
 test/testloadso.c                        |   17 +-
 test/testlocale.c                        |    4 +-
 test/testlock.c                          |   47 +-
 test/testmessage.c                       |   87 +-
 test/testmouse.c                         |  116 +-
 test/testmultiaudio.c                    |   49 +-
 test/testnative.c                        |   32 +-
 test/testnative.h                        |    6 +-
 test/testnativeos2.c                     |    2 +-
 test/testnativew32.c                     |    6 +-
 test/testnativex11.c                     |    6 +-
 test/testoffscreen.c                     |   37 +-
 test/testoverlay2.c                      |   49 +-
 test/testplatform.c                      |  381 +-
 test/testpower.c                         |    9 +-
 test/testqsort.c                         |   31 +-
 test/testrelative.c                      |   46 +-
 test/testrendercopyex.c                  |   24 +-
 test/testrendertarget.c                  |   28 +-
 test/testresample.c                      |   35 +-
 test/testrumble.c                        |   30 +-
 test/testscale.c                         |   25 +-
 test/testsem.c                           |   69 +-
 test/testsensor.c                        |   16 +-
 test/testshader.c                        |  267 +-
 test/testshape.c                         |  121 +-
 test/testsprite2.c                       |   90 +-
 test/testspriteminimal.c                 |   17 +-
 test/teststreaming.c                     |   27 +-
 test/testsurround.c                      |   33 +-
 test/testthread.c                        |   41 +-
 test/testtimer.c                         |   44 +-
 test/testurl.c                           |    2 +-
 test/testutils.c                         |   14 +-
 test/testutils.h                         |    2 +-
 test/testver.c                           |   15 +-
 test/testviewport.c                      |   54 +-
 test/testvulkan.c                        |  153 +-
 test/testwm2.c                           |  206 +-
 test/testyuv.c                           |   67 +-
 test/testyuv_cvt.c                       |   66 +-
 test/testyuv_cvt.h                       |    2 +-
 test/torturethread.c                     |   25 +-
 118 files changed, 20049 insertions(+), 19251 deletions(-)

diff --git a/src/test/SDL_test_assert.c b/src/test/SDL_test_assert.c
index 148564e..dc1eb64 100644
--- a/src/test/SDL_test_assert.c
+++ b/src/test/SDL_test_assert.c
@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
+  Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
@@ -52,7 +52,7 @@ void SDLTest_Assert(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *as
     /* Print assert description into a buffer */
     SDL_memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH);
     va_start(list, assertDescription);
-    SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, assertDescription, list);
+    (void)SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, assertDescription, list);
     va_end(list);
 
     /* Log, then assert and break on failure */
@@ -70,17 +70,14 @@ int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char
     /* Print assert description into a buffer */
     SDL_memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH);
     va_start(list, assertDescription);
-    SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, assertDescription, list);
+    (void)SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, assertDescription, list);
     va_end(list);
 
     /* Log pass or fail message */
-    if (assertCondition == ASSERT_FAIL)
-    {
+    if (assertCondition == ASSERT_FAIL) {
         SDLTest_AssertsFailed++;
         SDLTest_LogError(SDLTEST_ASSERT_CHECK_FORMAT, logMessage, "Failed");
-    }
-    else
-    {
+    } else {
         SDLTest_AssertsPassed++;
         SDLTest_Log(SDLTEST_ASSERT_CHECK_FORMAT, logMessage, "Passed");
     }
@@ -99,10 +96,10 @@ void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription,
     /* Print assert description into a buffer */
     SDL_memset(logMessage, 0, SDLTEST_MAX_LOGMESSAGE_LENGTH);
     va_start(list, assertDescription);
-    SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, assertDescription, list);
+    (void)SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, assertDescription, list);
     va_end(list);
 
-        /* Log pass message */
+    /* Log pass message */
     SDLTest_AssertsPassed++;
     SDLTest_Log(SDLTEST_ASSERT_CHECK_FORMAT, logMessage, "Passed");
 }
@@ -123,12 +120,9 @@ void SDLTest_ResetAssertSummary()
 void SDLTest_LogAssertSummary()
 {
     int totalAsserts = SDLTest_AssertsPassed + SDLTest_AssertsFailed;
-    if (SDLTest_AssertsFailed == 0)
-    {
+    if (SDLTest_AssertsFailed == 0) {
         SDLTest_Log(SDLTEST_ASSERT_SUMMARY_FORMAT, totalAsserts, SDLTest_AssertsPassed, SDLTest_AssertsFailed);
-    }
-    else
-    {
+    } else {
         SDLTest_LogError(SDLTEST_ASSERT_SUMMARY_FORMAT, totalAsserts, SDLTest_AssertsPassed, SDLTest_AssertsFailed);
     }
 }
diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c
index 1dc9793..b06ca72 100644
--- a/src/test/SDL_test_common.c
+++ b/src/test/SDL_test_common.c
@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
+  Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
@@ -46,7 +46,7 @@ static const char *audio_usage[] = {
     "[--channels N]", "[--samples N]"
 };
 
-static void SDL_snprintfcat(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, ... )
+static void SDL_snprintfcat(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
 {
     size_t length = SDL_strlen(text);
     va_list ap;
@@ -54,7 +54,7 @@ static void SDL_snprintfcat(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL
     va_start(ap, fmt);
     text += length;
     maxlen -= length;
-    SDL_vsnprintf(text, maxlen, fmt, ap);
+    (void)SDL_vsnprintf(text, maxlen, fmt, ap);
     va_end(ap);
 }
 
@@ -73,7 +73,7 @@ SDLTest_CommonCreateState(char **argv, Uint32 flags)
     }
 
     state = (SDLTest_CommonState *)SDL_calloc(1, sizeof(*state));
-    if (!state) {
+    if (state == NULL) {
         SDL_OutOfMemory();
         return NULL;
     }
@@ -116,8 +116,16 @@ SDLTest_CommonCreateState(char **argv, Uint32 flags)
     return state;
 }
 
-int
-SDLTest_CommonArg(SDLTest_CommonState * state, int index)
+#define SEARCHARG(dim)            \
+    while (*dim && *dim != ',') { \
+        ++dim;                    \
+    }                             \
+    if (!*dim) {                  \
+        return -1;                \
+    }                             \
+    *dim++ = '\0';
+
+int SDLTest_CommonArg(SDLTest_CommonState *state, int index)
 {
     char **argv = state->argv;
 
@@ -253,7 +261,7 @@ SDLTest_CommonArg(SDLTest_CommonState * state, int index)
     }
     if (SDL_strcasecmp(argv[index], "--windows") == 0) {
         ++index;
-        if (!argv[index] || !SDL_isdigit((unsigned char) *argv[index])) {
+        if (!argv[index] || !SDL_isdigit((unsigned char)*argv[index])) {
             return -1;
         }
         if (!(state->window_flags & SDL_WINDOW_FULLSCREEN)) {
@@ -309,20 +317,11 @@ SDLTest_CommonArg(SDLTest_CommonState * state, int index)
         }
         x = argv[index];
         y = argv[index];
-        #define SEARCHARG(dim) \
-            while (*dim && *dim != ',') { \
-                ++dim; \
-            } \
-            if (!*dim) { \
-                return -1; \
-            } \
-            *dim++ = '\0';
         SEARCHARG(y)
         w = y;
         SEARCHARG(w)
         h = w;
         SEARCHARG(h)
-        #undef SEARCHARG
         state->confine.x = SDL_atoi(x);
         state->confine.y = SDL_atoi(y);
         state->confine.w = SDL_atoi(w);
@@ -538,7 +537,7 @@ SDLTest_CommonArg(SDLTest_CommonState * state, int index)
         if (!argv[index]) {
             return -1;
         }
-        state->audiospec.channels = (Uint8) SDL_atoi(argv[index]);
+        state->audiospec.channels = (Uint8)SDL_atoi(argv[index]);
         return 2;
     }
     if (SDL_strcasecmp(argv[index], "--samples") == 0) {
@@ -546,27 +545,25 @@ SDLTest_CommonArg(SDLTest_CommonState * state, int index)
         if (!argv[index]) {
             return -1;
         }
-        state->audiospec.samples = (Uint16) SDL_atoi(argv[index]);
+        state->audiospec.samples = (Uint16)SDL_atoi(argv[index]);
         return 2;
     }
     if (SDL_strcasecmp(argv[index], "--trackmem") == 0) {
         /* Already handled in SDLTest_CommonCreateState() */
         return 1;
     }
-    if ((SDL_strcasecmp(argv[index], "-h") == 0)
-        || (SDL_strcasecmp(argv[index], "--help") == 0)) {
+    if ((SDL_strcasecmp(argv[index], "-h") == 0) || (SDL_strcasecmp(argv[index], "--help") == 0)) {
         /* Print the usage message */
         return -1;
     }
     if (SDL_strcmp(argv[index], "-NSDocumentRevisionsDebugMode") == 0) {
-    /* Debug flag sent by Xcode */
+        /* Debug flag sent by Xcode */
         return 2;
     }
     return 0;
 }
 
-void
-SDLTest_CommonLogUsage(SDLTest_CommonState * state, const char *argv0, const char **options)
+void SDLTest_CommonLogUsage(SDLTest_CommonState *state, const char *argv0, const char **options)
 {
     int i;
 
@@ -592,11 +589,10 @@ SDLTest_CommonLogUsage(SDLTest_CommonState * state, const char *argv0, const cha
     }
 }
 
-static const char *
-BuildCommonUsageString(char **pstr, const char **strlist, const int numitems, const char **strlist2, const int numitems2)
+static const char *BuildCommonUsageString(char **pstr, const char **strlist, const int numitems, const char **strlist2, const int numitems2)
 {
     char *str = *pstr;
-    if (!str) {
+    if (str == NULL) {
         size_t len = SDL_strlen("[--trackmem]") + 2;
         int i;
         for (i = 0; i < numitems; i++) {
@@ -607,19 +603,19 @@ BuildCommonUsageString(char **pstr, const char **strlist, const int numitems, co
                 len += SDL_strlen(strlist2[i]) + 1;
             }
         }
-        str = (char *) SDL_calloc(1, len);
-        if (!str) {
-            return "";  /* oh well. */
+        str = (char *)SDL_calloc(1, len);
+        if (str == NULL) {
+            return ""; /* oh well. */
         }
         SDL_strlcat(str, "[--trackmem] ", len);
-        for (i = 0; i < numitems-1; i++) {
+        for (i = 0; i < numitems - 1; i++) {
             SDL_strlcat(str, strlist[i], len);
             SDL_strlcat(str, " ", len);
         }
         SDL_strlcat(str, strlist[i], len);
         if (strlist2) {
             SDL_strlcat(str, " ", len);
-            for (i = 0; i < numitems2-1; i++) {
+            for (i = 0; i < numitems2 - 1; i++) {
                 SDL_strlcat(str, strlist2[i], len);
                 SDL_strlcat(str, " ", len);
             }
@@ -635,22 +631,21 @@ static char *common_usage_audio = NULL;
 static char *common_usage_videoaudio = NULL;
 
 const char *
-SDLTest_CommonUsage(SDLTest_CommonState * state)
+SDLTest_CommonUsage(SDLTest_CommonState *state)
 {
 
     switch (state->flags & (SDL_INIT_VIDEO | SDL_INIT_AUDIO)) {
-        case SDL_INIT_VIDEO:
-            return BuildCommonUsageString(&common_usage_video, video_usage, SDL_arraysize(video_usage), NULL, 0);
-        case SDL_INIT_AUDIO:
-            return BuildCommonUsageString(&common_usage_audio, audio_usage, SDL_arraysize(audio_usage), NULL, 0);
-        case (SDL_INIT_VIDEO | SDL_INIT_AUDIO):
-            return BuildCommonUsageString(&common_usage_videoaudio, video_usage, SDL_arraysize(video_usage), audio_usage, SDL_arraysize(audio_usage));
-        default:
-            return "[--trackmem]";
+    case SDL_INIT_VIDEO:
+        return BuildCommonUsageString(&common_usage_video, video_usage, SDL_arraysize(video_usage), NULL, 0);
+    case SDL_INIT_AUDIO:
+        return BuildCommonUsageString(&common_usage_audio, audio_usage, SDL_arraysize(audio_usage), NULL, 0);
+    case (SDL_INIT_VIDEO | SDL_INIT_AUDIO):
+        return BuildCommonUsageString(&common_usage_videoaudio, video_usage, SDL_arraysize(video_usage), audio_usage, SDL_arraysize(audio_usage));
+    default:
+        return "[--trackmem]";
     }
 }
 
-
 SDL_bool
 SDLTest_CommonDefaultArgs(SDLTest_CommonState *state, const int argc, char **argv)
 {
@@ -666,8 +661,7 @@ SDLTest_CommonDefaultArgs(SDLTest_CommonState *state, const int argc, char **arg
     return SDL_TRUE;
 }
 
-static void
-SDLTest_PrintDisplayOrientation(char* text, size_t maxlen, SDL_DisplayOrientation orientation)
+static void SDLTest_PrintDisplayOrientation(char *text, size_t maxlen, SDL_DisplayOrientation orientation)
 {
     switch (orientation) {
     case SDL_ORIENTATION_UNKNOWN:
@@ -691,8 +685,7 @@ SDLTest_PrintDisplayOrientation(char* text, size_t maxlen, SDL_DisplayOrientatio
     }
 }
 
-static void
-SDLTest_PrintWindowFlag(char* text, size_t maxlen, Uint32 flag)
+static void SDLTest_PrintWindowFlag(char *text, size_t maxlen, Uint32 flag)
 {
     switch (flag) {
     case SDL_WINDOW_FULLSCREEN:
@@ -770,8 +763,7 @@ SDLTest_PrintWindowFlag(char* text, size_t maxlen, Uint32 flag)
     }
 }
 
-static void
-SDLTest_PrintWindowFlags(char* text, size_t maxlen, Uint32 flags)
+static void SDLTest_PrintWindowFlags(char *text, size_t maxlen, Uint32 flags)
 {
     const Uint32 window_flags[] = {
         SDL_WINDOW_FULLSCREEN,
@@ -813,8 +805,7 @@ SDLTest_PrintWindowFlags(char* text, size_t maxlen, Uint32 flags)
     }
 }
 
-static void
-SDLTest_PrintButtonMask(char* text, size_t maxlen, Uint32 flags)
+static void SDLTest_PrintButtonMask(char *text, size_t maxlen, Uint32 flags)
 {
     int i;
     int count = 0;
@@ -830,8 +821,7 @@ SDLTest_PrintButtonMask(char* text, size_t maxlen, Uint32 flags)
     }
 }
 
-static void
-SDLTest_PrintRendererFlag(char *text, size_t maxlen, Uint32 flag)
+static void SDLTest_PrintRendererFlag(char *text, size_t maxlen, Uint32 flag)
 {
     switch (flag) {
     case SDL_RENDERER_SOFTWARE:
@@ -852,8 +842,7 @@ SDLTest_PrintRendererFlag(char *text, size_t maxlen, Uint32 flag)
     }
 }
 
-static void
-SDLTest_PrintPixelFormat(char *text, size_t maxlen, Uint32 format)
+static void SDLTest_PrintPixelFormat(char *text, size_t maxlen, Uint32 format)
 {
     switch (format) {
     case SDL_PIXELFORMAT_UNKNOWN:
@@ -961,18 +950,17 @@ SDLTest_PrintPixelFormat(char *text, size_t maxlen, Uint32 format)
     }
 }
 
-static void
-SDLTest_PrintRenderer(SDL_RendererInfo * info)
+static void SDLTest_PrintRenderer(SDL_RendererInfo *info)
 {
     int i, count;
     char text[1024];
 
     SDL_Log("  Renderer %s:\n", info->name);
 
-    SDL_snprintf(text, sizeof(text), "    Flags: 0x%8.8" SDL_PRIX32, info->flags);
+    (void)SDL_snprintf(text, sizeof(text), "    Flags: 0x%8.8" SDL_PRIX32, info->flags);
     SDL_snprintfcat(text, sizeof(text), " (");
     count = 0;
-    for (i = 0; i < sizeof(info->flags) * 8; ++i) {
+    for (i = 0; i < 8 * sizeof(info->flags); ++i) {
         Uint32 flag = (1 << i);
         if (info->flags & flag) {
             if (count > 0) {
@@ -985,8 +973,8 @@ SDLTest_PrintRenderer(SDL_RendererInfo * info)
     SDL_snprintfcat(text, sizeof(text), ")");
     SDL_Log("%s\n", text);
 
-    SDL_snprintf(text, sizeof(text), "    Texture formats (%" SDL_PRIu32 "): ", info->num_texture_formats);
-    for (i = 0; i < (int) info->num_texture_formats; ++i) {
+    (void)SDL_snprintf(text, sizeof(text), "    Texture formats (%" SDL_PRIu32 "): ", info->num_texture_formats);
+    for (i = 0; i < (int)info->num_texture_formats; ++i) {
         if (i > 0) {
             SDL_snprintfcat(text, sizeof(text), ", ");
         }
@@ -1000,8 +988,7 @@ SDLTest_PrintRenderer(SDL_RendererInfo * info)
     }
 }
 
-static SDL_Surface *
-SDLTest_LoadIcon(const char *file)
+static SDL_Surface *SDLTest_LoadIcon(const char *file)
 {
     SDL_Surface *icon;
 
@@ -1009,19 +996,18 @@ SDLTest_LoadIcon(const char *file)
     icon = SDL_LoadBMP(file);
     if (icon == NULL) {
         SDL_Log("Couldn't load %s: %s\n", file, SDL_GetError());
-        return (NULL);
+        return NULL;
     }
 
     if (icon->format->palette) {
         /* Set the colorkey */
-        SDL_SetColorKey(icon, 1, *((Uint8 *) icon->pixels));
+        SDL_SetColorKey(icon, 1, *((Uint8 *)icon->pixels));
     }
 
-    return (icon);
+    return icon;
 }
 
-static SDL_HitTestResult SDLCALL
-SDLTest_ExampleHitTestCallback(SDL_Window *win, const SDL_Point *area, void *data)
+static SDL_HitTestResult SDLCALL SDLTest_ExampleHitTestCallback(SDL_Window *win, const SDL_Point *area, void *data)
 {
     int w, h;
     const int RESIZE_BORDER = 8;
@@ -1035,25 +1021,25 @@ SDLTest_ExampleHitTestCallback(SDL_Window *win, const SDL_Point *area, void *dat
         if (area->y < RESIZE_BORDER) {
             SDL_Log("SDL_HITTEST_RESIZE_TOPLEFT\n");
             return SDL_HITTEST_RESIZE_TOPLEFT;
-        } else if (area->y >= (h-RESIZE_BORDER)) {
+        } else if (area->y >= (h - RESIZE_BORDER)) {
             SDL_Log("SDL_HITTEST_RESIZE_BOTTOMLEFT\n");
             return SDL_HITTEST_RESIZE_BOTTOMLEFT;
         } else {
             SDL_Log("SDL_HITTEST_RESIZE_LEFT\n");
             return SDL_HITTEST_RESIZE_LEFT;
         }
-    } else if (area->x >= (w-RESIZE_BORDER)) {
+    } else if (area->x >= (w - RESIZE_BORDER)) {
         if (area->y < RESIZE_BORDER) {
             SDL_Log("SDL_HITTEST_RESIZE_TOPRIGHT\n");
             return SDL_HITTEST_RESIZE_TOPRIGHT;
-        } else if (area->y >= (h-RESIZE_BORDER)) {
+        } else if (area->y >= (h - RESIZE_BORDER)) {
             SDL_Log("SDL_HITTEST_RESIZE_BOTTOMRIGHT\n");
             return SDL_HITTEST_RESIZE_BOTTOMRIGHT;
         } else {
             SDL_Log("SDL_HITTEST_RESIZE_RIGHT\n");
             return SDL_HITTEST_RESIZE_RIGHT;
         }
-    } else if (area->y >= (h-RESIZE_BORDER)) {
+    } else if (area->y >= (h - RESIZE_BORDER)) {
         SDL_Log("SDL_HITTEST_RESIZE_BOTTOM\n");
         return SDL_HITTEST_RESIZE_BOTTOM;
     } else if (area->y < RESIZE_BORDER) {
@@ -1067,7 +1053,7 @@ SDLTest_ExampleHitTestCallback(SDL_Window *win, const SDL_Point *area, void *dat
 }
 
 SDL_bool
-SDLTest_CommonInit(SDLTest_CommonState * state)
+SDLTest_CommonInit(SDLTest_CommonState *state)
 {
     int i, j, m, n, w, h;
     SDL_DisplayMode fullscreen_mode;
@@ -1079,7 +1065,7 @@ SDLTest_CommonInit(SDLTest_CommonState * state)
             if (n == 0) {
                 SDL_Log("No built-in video drivers\n");
             } else {
-                SDL_snprintf(text, sizeof(text), "Built-in video drivers:");
+                (void)SDL_snprintf(text, sizeof(text), "Built-in video drivers:");
                 for (i = 0; i < n; ++i) {
                     if (i > 0) {
                         SDL_snprintfcat(text, sizeof(text), ",");
@@ -1169,8 +1155,9 @@ SDLTest_CommonInit(SDLTest_CommonState * state)
                     SDL_Log("      Red Mask   = 0x%.8" SDL_PRIx32 "\n", Rmask);
                     SDL_Log("      Green Mask = 0x%.8" SDL_PRIx32 "\n", Gmask);
                     SDL_Log("      Blue Mask  = 0x%.8" SDL_PRIx32 "\n", Bmask);
-                    if (Amask)
+                    if (Amask) {
                         SDL_Log("      Alpha Mask = 0x%.8" SDL_PRIx32 "\n", Amask);
+                    }
                 }
 
                 /* Print available fullscreen video modes */
@@ -1193,16 +1180,16 @@ SDLTest_CommonInit(SDLTest_CommonState * state)
                                     Gmask);
                             SDL_Log("        Blue Mask  = 0x%.8" SDL_PRIx32 "\n",
                                     Bmask);
-                            if (Amask)
-                                SDL_Log("        Alpha Mask = 0x%.8" SDL_PRIx32 "\n",
-                                        Amask);
+                            if (Amask) {
+                                SDL_Log("        Alpha Mask = 0x%.8" SDL_PRIx32 "\n", Amask);
+                            }
                         }
                     }
                 }
 
 #if SDL_VIDEO_DRIVER_WINDOWS && !defined(__XBOXONE__) && !defined(__XBOXSERIES__)
                 /* Print the D3D9 adapter index */
-                adapterIndex = SDL_Direct3D9GetAdapterIndex( i );
+                adapterIndex = SDL_Direct3D9GetAdapterIndex(i);
                 SDL_Log("D3D9 Adapter Index: %d", adapterIndex);
 
                 /* Print the DXGI adapter and output indices */
@@ -1248,14 +1235,14 @@ SDLTest_CommonInit(SDLTest_CommonState * state)
         fullscreen_mode.refresh_rate = state->refresh_rate;
 
         state->windows =
-            (SDL_Window **) SDL_calloc(state->num_windows,
-                                        sizeof(*state->windows));
+            (SDL_Window **)SDL_calloc(state->num_windows,
+                                      sizeof(*state->windows));
         state->renderers =
-            (SDL_Renderer **) SDL_calloc(state->num_windows,
+            (SDL_Renderer **)SDL_calloc(state->num_windows,
                                         sizeof(*state->renderers));
         state->targets =
-            (SDL_Texture **) SDL_calloc(state->num_windows,
-                                        sizeof(*state->targets));
+            (SDL_Texture **)SDL_calloc(state->num_windows,
+                                       sizeof(*state->targets));
         if (!state->windows || !state->renderers) {
             SDL_Log("Out of memory!\n");
             return SDL_FALSE;
@@ -1275,8 +1262,8 @@ SDLTest_CommonInit(SDLTest_CommonState * state)
             }
 
             if (state->num_windows > 1) {
-                SDL_snprintf(title, SDL_arraysize(title), "%s %d",
-                             state->window_title, i + 1);
+                (void)SDL_snprintf(title, SDL_arraysize(title), "%s %d",
+                                   state->window_title, i + 1);
             } else {
                 SDL_strlcpy(title, state->window_title, SDL_arraysize(title));
             }
@@ -1300,6 +1287,8 @@ SDLTest_CommonInit(SDLTest_CommonState * state)
                 state->window_w = w;
                 state->window_h = h;
             }
+            fullscreen_mode.w = state->window_w;
+            fullscreen_mode.h = state->window_h;
             if (SDL_SetWindowDisplayMode(state->windows[i], &fullscreen_mode) < 0) {
                 SDL_Log("Can't set up fullscreen display mode: %s\n",
                         SDL_GetError());
@@ -1307,8 +1296,8 @@ SDLTest_CommonInit(SDLTest_CommonState * state)
             }
 
             /* Add resize/drag areas for windows that are borderless and resizable */
-            if ((state->window_flags & (SDL_WINDOW_RESIZABLE|SDL_WINDOW_BORDERLESS)) ==
-                (SDL_WINDOW_RESIZABLE|SDL_WINDOW_BORDERLESS)) {
+            if ((state->window_flags & (SDL_WINDOW_RESIZABLE | SDL_WINDOW_BORDERLESS)) ==
+                (SDL_WINDOW_RESIZABLE | SDL_WINDOW_BORDERLESS)) {
                 SDL_SetWindowHitTest(state->windows[i], SDLTest_ExampleHitTestCallback, NULL);
             }
 
@@ -1326,9 +1315,7 @@ SDLTest_CommonInit(SDLTest_CommonState * state)
                 SDL_SetWindowMouseRect(state->windows[i], &state->confine);
             }
 
-            if (!state->skip_renderer
-                && (state->renderdriver
-                    || !(state->window_flags & (SDL_WINDOW_OPENGL | SDL_WINDOW_VULKAN | SDL_WINDOW_METAL)))) {
+            if (!state->skip_renderer && (state->renderdriver || !(state->window_flags & (SDL_WINDOW_OPENGL | SDL_WINDOW_VULKAN | SDL_WINDOW_METAL)))) {
                 m = -1;
                 if (state->renderdriver) {
                     SDL_RendererInfo info;
@@ -1347,7 +1334,7 @@ SDLTest_CommonInit(SDLTest_CommonState * state)
                     }
                 }
                 state->renderers[i] = SDL_CreateRenderer(state->windows[i],
-                                            m, state->render_flags);
+                                                         m, state->render_flags);
                 if (!state->renderers[i]) {
                     SDL_Log("Couldn't create renderer: %s\n",
                             SDL_GetError());
@@ -1375,7 +1362,7 @@ SDLTest_CommonInit(SDLTest_CommonState * state)
             if (n == 0) {
                 SDL_Log("No built-in audio drivers\n");
             } else {
-                SDL_snprintf(text, sizeof(text), "Built-in audio drivers:");
+                (void)SDL_snprintf(text, sizeof(text), "Built-in audio drivers:");
                 for (i = 0; i < n; ++i) {
                     if (i > 0) {
                         SDL_snprintfcat(text, sizeof(text), ",");
@@ -1404,28 +1391,29 @@ SDLTest_CommonInit(SDLTest_CommonState * state)
     return SDL_TRUE;
 }
 
-static const char *
-DisplayOrientationName(int orientation)
+static const char *DisplayOrientationName(int orientation)
 {
-    switch (orientation)
-    {
-#define CASE(X) case SDL_ORIENTATION_##X: return #X
+    switch (orientation) {
+#define CASE(X)               \
+    case SDL_ORIENTATION_##X: \
+        return #X
         CASE(UNKNOWN);
         CASE(LANDSCAPE);
         CASE(LANDSCAPE_FLIPPED);
         CASE(PORTRAIT);
         CASE(PORTRAIT_FLIPPED);
 #undef CASE
-default: return "???";
+    default:
+        return "???";
     }
 }
 
-static const char *
-ControllerAxisName(const SDL_GameControllerAxis axis)
+static const char *ControllerAxisName(const SDL_GameControllerAxis axis)
 {
-    switch (axis)
-    {
-#define AXIS_CASE(ax) case SDL_CONTROLLER_AXIS_##ax: return #ax
+    switch (axis) {
+#define AXIS_CASE(ax)              \
+    case SDL_CONTROLLER_AXIS_##ax: \
+        return #ax
         AXIS_CASE(INVALID);
         AXIS_CASE(LEFTX);
         AXIS_CASE(LEFTY);
@@ -1434,16 +1422,17 @@ ControllerAxisName(const SDL_GameControllerAxis axis)
         AXIS_CASE(TRIGGERLEFT);
         AXIS_CASE(TRIGGERRIGHT);
 #undef AXIS_CASE
-default: return "???";
+    default:
+        return "???";
     }
 }
 
-static const char *
-ControllerButtonName(const SDL_GameControllerButton button)
+static const char *ControllerButtonName(const SDL_GameControllerButton button)
 {
-    switch (button)
-    {
-#define BUTTON_CASE(btn) case SDL_CONTROLLER_BUTTON_##btn: return #btn
+    switch (button) {
+#define BUTTON_CASE(btn)              \
+    case SDL_CONTROLLER_BUTTON_##btn: \
+        return #btn
         BUTTON_CASE(INVALID);
         BUTTON_CASE(A);
         BUTTON_CASE(B);
@@ -1461,12 +1450,12 @@ ControllerButtonName(const SDL_GameControllerButton button)
         BUTTON_CASE(DPAD_LEFT);
         BUTTON_CASE(DPAD_RIGHT);
 #undef BUTTON_CASE
-default: return "???";
+    default:
+        return "???";
     }
 }
 
-static void
-SDLTest_PrintEvent(SDL_Event * event)
+static void SDLTest_PrintEvent(SDL_Event *event)
 {
     switch (event->type) {
     case SDL_DISPLAYEVENT:
@@ -1475,6 +1464,10 @@ SDLTest_PrintEvent(SDL_Event * event)
             SDL_Log("SDL EVENT: Display %" SDL_PRIu32 " connected",
                     event->display.display);
             break;
+        case SDL_DISPLAY

(Patch may be truncated, please check the link at the top of this post.)