SDL_image: test: add a few SDLTest_AssertPass

From a94f8d838bdf3d5619ab114af8e58a6311f4f18f Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Fri, 3 Jan 2025 17:33:03 +0100
Subject: [PATCH] test: add a few SDLTest_AssertPass

---
 src/IMG.c         | 18 ++++++++++--------
 src/IMG_ImageIO.m | 12 ++++++++----
 src/IMG_webp.c    |  2 ++
 test/main.c       | 11 +++++++++++
 4 files changed, 31 insertions(+), 12 deletions(-)

diff --git a/src/IMG.c b/src/IMG.c
index 28a9c509..082d2935 100644
--- a/src/IMG.c
+++ b/src/IMG.c
@@ -142,8 +142,9 @@ SDL_Surface *IMG_LoadTyped_IO(SDL_IOStream *src, bool closeio, const char *type)
     /* See whether or not this data source can handle seeking */
     if (SDL_SeekIO(src, 0, SDL_IO_SEEK_CUR) < 0 ) {
         SDL_SetError("Can't seek in this data source");
-        if (closeio)
+        if (closeio) {
             SDL_CloseIO(src);
+        }
         return NULL;
     }
 
@@ -175,20 +176,22 @@ SDL_Surface *IMG_LoadTyped_IO(SDL_IOStream *src, bool closeio, const char *type)
     /* Detect the type of image being loaded */
     for ( i=0; i < SDL_arraysize(supported); ++i ) {
         if (supported[i].is) {
-            if (!supported[i].is(src))
+            if (!supported[i].is(src)) {
                 continue;
+            }
         } else {
             /* magicless format */
-            if (!type || SDL_strcasecmp(type, supported[i].type) != 0)
+            if (!type || SDL_strcasecmp(type, supported[i].type) != 0) {
                 continue;
+            }
         }
 #ifdef DEBUG_IMGLIB
-        fprintf(stderr, "IMGLIB: Loading image as %s\n",
-            supported[i].type);
+        SDL_Log("IMGLIB: Loading image as %s\n", supported[i].type);
 #endif
         image = supported[i].load(src);
-        if (closeio)
+        if (closeio) {
             SDL_CloseIO(src);
+        }
         return image;
     }
 
@@ -285,8 +288,7 @@ IMG_Animation *IMG_LoadAnimationTyped_IO(SDL_IOStream *src, bool closeio, const
                 continue;
         }
 #ifdef DEBUG_IMGLIB
-        fprintf(stderr, "IMGLIB: Loading image as %s\n",
-            supported_anims[i].type);
+        SDL_Log("IMGLIB: Loading image as %s\n", supported_anims[i].type);
 #endif
         anim = supported_anims[i].load(src);
         if (closeio)
diff --git a/src/IMG_ImageIO.m b/src/IMG_ImageIO.m
index 1aeba26d..c357195e 100644
--- a/src/IMG_ImageIO.m
+++ b/src/IMG_ImageIO.m
@@ -459,14 +459,16 @@ bool IMG_isTIF(SDL_IOStream *src)
     if (hint_dictionary != NULL)
         CFRelease(hint_dictionary);
 
-    if (NULL == image_source)
+    if (NULL == image_source) {
         return NULL;
+    }
 
     CGImageRef image_ref = CreateCGImageFromCGImageSource(image_source);
     CFRelease(image_source);
 
-    if (NULL == image_ref)
+    if (NULL == image_ref) {
         return NULL;
+    }
     SDL_Surface *sdl_surface = Create_SDL_Surface_From_CGImage(image_ref);
     CFRelease(image_ref);
 
@@ -479,14 +481,16 @@ bool IMG_isTIF(SDL_IOStream *src)
 
     image_source = CreateCGImageSourceFromFile(file);
 
-    if(NULL == image_source)
+    if (NULL == image_source) {
         return NULL;
+    }
 
     CGImageRef image_ref = CreateCGImageFromCGImageSource(image_source);
     CFRelease(image_source);
 
-    if (NULL == image_ref)
+    if (NULL == image_ref) {
         return NULL;
+    }
     SDL_Surface *sdl_surface = Create_SDL_Surface_From_CGImage(image_ref);
     CFRelease(image_ref);
     return sdl_surface;
diff --git a/src/IMG_webp.c b/src/IMG_webp.c
index 0f1490e4..0e4dc200 100644
--- a/src/IMG_webp.c
+++ b/src/IMG_webp.c
@@ -80,10 +80,12 @@ static bool IMG_InitWEBP(void)
     if (lib.loaded == 0) {
 #if defined(LOAD_WEBP_DYNAMIC) && defined(LOAD_WEBPDEMUX_DYNAMIC)
         lib.handle_libwebpdemux = SDL_LoadObject(LOAD_WEBPDEMUX_DYNAMIC);
+        SDL_Log("SDL_LoadObject(\"" LOAD_WEBPDEMUX_DYNAMIC "\") -> %p", lib.handle_libwebpdemux);
         if (lib.handle_libwebpdemux == NULL) {
             return false;
         }
         lib.handle_libwebp = SDL_LoadObject(LOAD_WEBP_DYNAMIC);
+        SDL_Log("SDL_LoadObject(\"" LOAD_WEBPDEMUX_DYNAMIC "\") -> %p", lib.handle_libwebp);
         if (lib.handle_libwebp == NULL) {
             return false;
         }
diff --git a/test/main.c b/test/main.c
index 69c6dc84..ee88cad9 100644
--- a/test/main.c
+++ b/test/main.c
@@ -622,6 +622,7 @@ FormatLoadTest(const Format *format,
 
     if (StrHasSuffix(format->reference, ".bmp")) {
         SDL_ClearError();
+        SDLTest_AssertPass("About to call SDL_LoadBMP(\"%s\")", refFilename);
         reference = SDL_LoadBMP(refFilename);
         if (!SDLTest_AssertCheck(reference != NULL,
                                  "Loading reference should succeed (%s)",
@@ -632,6 +633,7 @@ FormatLoadTest(const Format *format,
     else if (StrHasSuffix (format->reference, ".png")) {
 #ifdef LOAD_PNG
         SDL_ClearError();
+        SDLTest_AssertPass("About to call IMG_Load(\"%s\")", refFilename);
         reference = IMG_Load(refFilename);
         if (!SDLTest_AssertCheck(reference != NULL,
                                  "Loading reference should succeed (%s)",
@@ -643,6 +645,7 @@ FormatLoadTest(const Format *format,
 
     if (mode != LOAD_CONVENIENCE) {
         SDL_ClearError();
+        SDLTest_AssertPass("About to call SDL_IOFromFile(\"%s\", \"rb\")", refFilename);
         src = SDL_IOFromFile(filename, "rb");
         SDLTest_AssertCheck(src != NULL,
                             "Opening %s should succeed (%s)",
@@ -654,6 +657,7 @@ FormatLoadTest(const Format *format,
     SDL_ClearError();
     switch (mode) {
         case LOAD_CONVENIENCE:
+            SDLTest_AssertPass("About to call IMG_Load(\"%s\")", filename);
             surface = IMG_Load(filename);
             break;
 
@@ -662,11 +666,13 @@ FormatLoadTest(const Format *format,
                 SDL_IOStream *ref_src;
                 int check;
 
+                SDLTest_AssertPass("About to call SDL_IOFromFile(\"%s\", \"rb\")", refFilename);
                 ref_src = SDL_IOFromFile(refFilename, "rb");
                 SDLTest_AssertCheck(ref_src != NULL,
                                     "Opening %s should succeed (%s)",
                                     refFilename, SDL_GetError());
                 if (ref_src != NULL) {
+                    SDLTest_AssertPass("About to call IMG_Is%s(<reference>)", format->name);
                     check = format->checkFunction(ref_src);
                     SDLTest_AssertCheck(!check,
                                         "Should not detect %s as %s -> %d",
@@ -676,6 +682,7 @@ FormatLoadTest(const Format *format,
             }
 
             if (format->checkFunction != NULL) {
+                SDLTest_AssertPass("About to call IMG_Is%s(<src>)", format->name);
                 int check = format->checkFunction(src);
 
                 SDLTest_AssertCheck(check,
@@ -684,16 +691,19 @@ FormatLoadTest(const Format *format,
             }
 
             SDL_ClearError();
+            SDLTest_AssertPass("About to call IMG_Load_IO(<src>, true)");
             surface = IMG_Load_IO(src, true);
             src = NULL;      /* ownership taken */
             break;
 
         case LOAD_TYPED_IO:
+            SDLTest_AssertPass("About to call IMG_LoadTyped_IO(<src>, true, \"%s\")", format->name);
             surface = IMG_LoadTyped_IO(src, true, format->name);
             src = NULL;      /* ownership taken */
             break;
 
         case LOAD_FORMAT_SPECIFIC:
+            SDLTest_AssertPass("About to call IMG_Load%s_IO(<src>)", format->name);
             surface = format->loadFunction(src);
             break;
 
@@ -818,6 +828,7 @@ FormatSaveTest(const Format *format,
 
     if (format->canLoad) {
         SDL_ClearError();
+        SDLTest_AssertPass("About to call IMG_Load(\"%s\")", filename);
         surface = IMG_Load(filename);
 
         if (!SDLTest_AssertCheck(surface != NULL,