SDL: testautomation_pixels: calling SDL_DestroyPixelFormat or SDL_DestroyPalette with NULL parameter doesn't generate an error

From 4286f463a8421b4c9954b84bb07e5f154009c3b5 Mon Sep 17 00:00:00 2001
From: Sylvain <[EMAIL REDACTED]>
Date: Fri, 17 Mar 2023 10:13:17 +0100
Subject: [PATCH] testautomation_pixels: calling SDL_DestroyPixelFormat or
 SDL_DestroyPalette with NULL parameter doesn't generate an error

---
 test/testautomation_pixels.c | 26 ++++++++------------------
 1 file changed, 8 insertions(+), 18 deletions(-)

diff --git a/test/testautomation_pixels.c b/test/testautomation_pixels.c
index 3df9165f377d..5ec65515a969 100644
--- a/test/testautomation_pixels.c
+++ b/test/testautomation_pixels.c
@@ -113,8 +113,7 @@ static const char *g_invalidPixelFormatsVerbose[] = {
 static int pixels_allocFreeFormat(void *arg)
 {
     const char *unknownFormat = "SDL_PIXELFORMAT_UNKNOWN";
-    const char *expectedError = "Parameter 'format' is invalid";
-    const char *expectedError2 = "Unknown pixel format";
+    const char *expectedError = "Unknown pixel format";
     const char *error;
     int i;
     Uint32 format;
@@ -179,8 +178,8 @@ static int pixels_allocFreeFormat(void *arg)
         SDLTest_AssertPass("Call to SDL_GetError()");
         SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
         if (error != NULL) {
-            SDLTest_AssertCheck(SDL_strcmp(error, expectedError2) == 0,
-                                "Validate error message, expected: '%s', got: '%s'", expectedError2, error);
+            SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0,
+                                "Validate error message, expected: '%s', got: '%s'", expectedError, error);
         }
     }
 
@@ -191,11 +190,7 @@ static int pixels_allocFreeFormat(void *arg)
     SDLTest_AssertPass("Call to SDL_DestroyPixelFormat(NULL)");
     error = SDL_GetError();
     SDLTest_AssertPass("Call to SDL_GetError()");
-    SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
-    if (error != NULL) {
-        SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0,
-                            "Validate error message, expected: '%s', got: '%s'", expectedError, error);
-    }
+    SDLTest_AssertCheck(error == NULL || error[0] == '\0', "Validate that error message is empty");
 
     return TEST_COMPLETED;
 }
@@ -275,8 +270,7 @@ static int pixels_getPixelFormatName(void *arg)
  */
 static int pixels_allocFreePalette(void *arg)
 {
-    const char *expectedError1 = "Parameter 'ncolors' is invalid";
-    const char *expectedError2 = "Parameter 'palette' is invalid";
+    const char *expectedError = "Parameter 'ncolors' is invalid";
     const char *error;
     int variation;
     int i;
@@ -336,8 +330,8 @@ static int pixels_allocFreePalette(void *arg)
         SDLTest_AssertPass("Call to SDL_GetError()");
         SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
         if (error != NULL) {
-            SDLTest_AssertCheck(SDL_strcmp(error, expectedError1) == 0,
-                                "Validate error message, expected: '%s', got: '%s'", expectedError1, error);
+            SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0,
+                                "Validate error message, expected: '%s', got: '%s'", expectedError, error);
         }
     }
 
@@ -348,11 +342,7 @@ static int pixels_allocFreePalette(void *arg)
     SDLTest_AssertPass("Call to SDL_DestroyPalette(NULL)");
     error = SDL_GetError();
     SDLTest_AssertPass("Call to SDL_GetError()");
-    SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
-    if (error != NULL) {
-        SDLTest_AssertCheck(SDL_strcmp(error, expectedError2) == 0,
-                            "Validate error message, expected: '%s', got: '%s'", expectedError2, error);
-    }
+    SDLTest_AssertCheck(error == NULL || error[0] == '\0', "Validate that error message is empty");
 
     return TEST_COMPLETED;
 }