sdl2-compat: update tests and testlib from latest SDL2

From c5faaac86d7d051db4e8b9a6a18bdd5bcaf74c77 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Wed, 10 Jan 2024 17:25:24 +0300
Subject: [PATCH] update tests and testlib from latest SDL2

---
 src/test/SDL_test_imageBlit.c            | 45 ++------------
 src/test/SDL_test_imageBlitBlend.c       | 75 ++++--------------------
 src/test/SDL_test_imageFace.c            | 15 +----
 src/test/SDL_test_imagePrimitives.c      | 15 +----
 src/test/SDL_test_imagePrimitivesBlend.c | 15 +----
 test/testautomation_audio.c              |  4 +-
 6 files changed, 24 insertions(+), 145 deletions(-)

diff --git a/src/test/SDL_test_imageBlit.c b/src/test/SDL_test_imageBlit.c
index 53c2338..bf1cf2f 100644
--- a/src/test/SDL_test_imageBlit.c
+++ b/src/test/SDL_test_imageBlit.c
@@ -542,24 +542,13 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlit = {
  */
 SDL_Surface *SDLTest_ImageBlit()
 {
-    SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(
+    SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom(
         (void *)SDLTest_imageBlit.pixel_data,
         SDLTest_imageBlit.width,
         SDLTest_imageBlit.height,
         SDLTest_imageBlit.bytes_per_pixel * 8,
         SDLTest_imageBlit.width * SDLTest_imageBlit.bytes_per_pixel,
-#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
-        0xff000000, /* Red bit mask. */
-        0x00ff0000, /* Green bit mask. */
-        0x0000ff00, /* Blue bit mask. */
-        0x000000ff  /* Alpha bit mask. */
-#else
-        0x000000ff, /* Red bit mask. */
-        0x0000ff00, /* Green bit mask. */
-        0x00ff0000, /* Blue bit mask. */
-        0xff000000  /* Alpha bit mask. */
-#endif
-    );
+        SDL_PIXELFORMAT_RGB24);
     return surface;
 }
 
@@ -1027,24 +1016,13 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitColor = {
  */
 SDL_Surface *SDLTest_ImageBlitColor()
 {
-    SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(
+    SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom(
         (void *)SDLTest_imageBlitColor.pixel_data,
         SDLTest_imageBlitColor.width,
         SDLTest_imageBlitColor.height,
         SDLTest_imageBlitColor.bytes_per_pixel * 8,
         SDLTest_imageBlitColor.width * SDLTest_imageBlitColor.bytes_per_pixel,
-#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
-        0xff000000, /* Red bit mask. */
-        0x00ff0000, /* Green bit mask. */
-        0x0000ff00, /* Blue bit mask. */
-        0x000000ff  /* Alpha bit mask. */
-#else
-        0x000000ff, /* Red bit mask. */
-        0x0000ff00, /* Green bit mask. */
-        0x00ff0000, /* Blue bit mask. */
-        0xff000000  /* Alpha bit mask. */
-#endif
-    );
+        SDL_PIXELFORMAT_RGB24);
     return surface;
 }
 
@@ -1675,24 +1653,13 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitAlpha = {
  */
 SDL_Surface *SDLTest_ImageBlitAlpha()
 {
-    SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(
+    SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom(
         (void *)SDLTest_imageBlitAlpha.pixel_data,
         SDLTest_imageBlitAlpha.width,
         SDLTest_imageBlitAlpha.height,
         SDLTest_imageBlitAlpha.bytes_per_pixel * 8,
         SDLTest_imageBlitAlpha.width * SDLTest_imageBlitAlpha.bytes_per_pixel,
-#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
-        0xff000000, /* Red bit mask. */
-        0x00ff0000, /* Green bit mask. */
-        0x0000ff00, /* Blue bit mask. */
-        0x000000ff  /* Alpha bit mask. */
-#else
-        0x000000ff, /* Red bit mask. */
-        0x0000ff00, /* Green bit mask. */
-        0x00ff0000, /* Blue bit mask. */
-        0xff000000  /* Alpha bit mask. */
-#endif
-    );
+        SDL_PIXELFORMAT_RGB24);
     return surface;
 }
 
diff --git a/src/test/SDL_test_imageBlitBlend.c b/src/test/SDL_test_imageBlitBlend.c
index 2f8ddbf..520cfff 100644
--- a/src/test/SDL_test_imageBlitBlend.c
+++ b/src/test/SDL_test_imageBlitBlend.c
@@ -582,24 +582,13 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendAdd = {
  */
 SDL_Surface *SDLTest_ImageBlitBlendAdd()
 {
-    SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(
+    SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom(
         (void *)SDLTest_imageBlitBlendAdd.pixel_data,
         SDLTest_imageBlitBlendAdd.width,
         SDLTest_imageBlitBlendAdd.height,
         SDLTest_imageBlitBlendAdd.bytes_per_pixel * 8,
         SDLTest_imageBlitBlendAdd.width * SDLTest_imageBlitBlendAdd.bytes_per_pixel,
-#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
-        0xff000000, /* Red bit mask. */
-        0x00ff0000, /* Green bit mask. */
-        0x0000ff00, /* Blue bit mask. */
-        0x000000ff  /* Alpha bit mask. */
-#else
-        0x000000ff, /* Red bit mask. */
-        0x0000ff00, /* Green bit mask. */
-        0x00ff0000, /* Blue bit mask. */
-        0xff000000  /* Alpha bit mask. */
-#endif
-    );
+        SDL_PIXELFORMAT_RGB24);
     return surface;
 }
 
@@ -1184,24 +1173,13 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlend = {
  */
 SDL_Surface *SDLTest_ImageBlitBlend()
 {
-    SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(
+    SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom(
         (void *)SDLTest_imageBlitBlend.pixel_data,
         SDLTest_imageBlitBlend.width,
         SDLTest_imageBlitBlend.height,
         SDLTest_imageBlitBlend.bytes_per_pixel * 8,
         SDLTest_imageBlitBlend.width * SDLTest_imageBlitBlend.bytes_per_pixel,
-#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
-        0xff000000, /* Red bit mask. */
-        0x00ff0000, /* Green bit mask. */
-        0x0000ff00, /* Blue bit mask. */
-        0x000000ff  /* Alpha bit mask. */
-#else
-        0x000000ff, /* Red bit mask. */
-        0x0000ff00, /* Green bit mask. */
-        0x00ff0000, /* Blue bit mask. */
-        0xff000000  /* Alpha bit mask. */
-#endif
-    );
+        SDL_PIXELFORMAT_RGB24);
     return surface;
 }
 
@@ -1616,24 +1594,13 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendMod = {
  */
 SDL_Surface *SDLTest_ImageBlitBlendMod()
 {
-    SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(
+    SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom(
         (void *)SDLTest_imageBlitBlendMod.pixel_data,
         SDLTest_imageBlitBlendMod.width,
         SDLTest_imageBlitBlendMod.height,
         SDLTest_imageBlitBlendMod.bytes_per_pixel * 8,
         SDLTest_imageBlitBlendMod.width * SDLTest_imageBlitBlendMod.bytes_per_pixel,
-#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
-        0xff000000, /* Red bit mask. */
-        0x00ff0000, /* Green bit mask. */
-        0x0000ff00, /* Blue bit mask. */
-        0x000000ff  /* Alpha bit mask. */
-#else
-        0x000000ff, /* Red bit mask. */
-        0x0000ff00, /* Green bit mask. */
-        0x00ff0000, /* Blue bit mask. */
-        0xff000000  /* Alpha bit mask. */
-#endif
-    );
+        SDL_PIXELFORMAT_RGB24);
     return surface;
 }
 
@@ -2431,24 +2398,13 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendNone = {
  */
 SDL_Surface *SDLTest_ImageBlitBlendNone()
 {
-    SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(
+    SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom(
         (void *)SDLTest_imageBlitBlendNone.pixel_data,
         SDLTest_imageBlitBlendNone.width,
         SDLTest_imageBlitBlendNone.height,
         SDLTest_imageBlitBlendNone.bytes_per_pixel * 8,
         SDLTest_imageBlitBlendNone.width * SDLTest_imageBlitBlendNone.bytes_per_pixel,
-#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
-        0xff000000, /* Red bit mask. */
-        0x00ff0000, /* Green bit mask. */
-        0x0000ff00, /* Blue bit mask. */
-        0x000000ff  /* Alpha bit mask. */
-#else
-        0x000000ff, /* Red bit mask. */
-        0x0000ff00, /* Green bit mask. */
-        0x00ff0000, /* Blue bit mask. */
-        0xff000000  /* Alpha bit mask. */
-#endif
-    );
+        SDL_PIXELFORMAT_RGB24);
     return surface;
 }
 
@@ -2978,24 +2934,13 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendAll = {
  */
 SDL_Surface *SDLTest_ImageBlitBlendAll()
 {
-    SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(
+    SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom(
         (void *)SDLTest_imageBlitBlendAll.pixel_data,
         SDLTest_imageBlitBlendAll.width,
         SDLTest_imageBlitBlendAll.height,
         SDLTest_imageBlitBlendAll.bytes_per_pixel * 8,
         SDLTest_imageBlitBlendAll.width * SDLTest_imageBlitBlendAll.bytes_per_pixel,
-#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
-        0xff000000, /* Red bit mask. */
-        0x00ff0000, /* Green bit mask. */
-        0x0000ff00, /* Blue bit mask. */
-        0x000000ff  /* Alpha bit mask. */
-#else
-        0x000000ff, /* Red bit mask. */
-        0x0000ff00, /* Green bit mask. */
-        0x00ff0000, /* Blue bit mask. */
-        0xff000000  /* Alpha bit mask. */
-#endif
-    );
+        SDL_PIXELFORMAT_RGB24);
     return surface;
 }
 
diff --git a/src/test/SDL_test_imageFace.c b/src/test/SDL_test_imageFace.c
index d4c778c..255acad 100644
--- a/src/test/SDL_test_imageFace.c
+++ b/src/test/SDL_test_imageFace.c
@@ -225,24 +225,13 @@ static const SDLTest_SurfaceImage_t SDLTest_imageFace = {
  */
 SDL_Surface *SDLTest_ImageFace()
 {
-    SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(
+    SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom(
         (void *)SDLTest_imageFace.pixel_data,
         SDLTest_imageFace.width,
         SDLTest_imageFace.height,
         SDLTest_imageFace.bytes_per_pixel * 8,
         SDLTest_imageFace.width * SDLTest_imageFace.bytes_per_pixel,
-#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
-        0xff000000, /* Red bit mask. */
-        0x00ff0000, /* Green bit mask. */
-        0x0000ff00, /* Blue bit mask. */
-        0x000000ff  /* Alpha bit mask. */
-#else
-        0x000000ff, /* Red bit mask. */
-        0x0000ff00, /* Green bit mask. */
-        0x00ff0000, /* Blue bit mask. */
-        0xff000000  /* Alpha bit mask. */
-#endif
-    );
+        SDL_PIXELFORMAT_RGBA32);
     return surface;
 }
 
diff --git a/src/test/SDL_test_imagePrimitives.c b/src/test/SDL_test_imagePrimitives.c
index ec70fa1..6ef05c5 100644
--- a/src/test/SDL_test_imagePrimitives.c
+++ b/src/test/SDL_test_imagePrimitives.c
@@ -506,24 +506,13 @@ static const SDLTest_SurfaceImage_t SDLTest_imagePrimitives = {
  */
 SDL_Surface *SDLTest_ImagePrimitives()
 {
-    SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(
+    SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom(
         (void *)SDLTest_imagePrimitives.pixel_data,
         SDLTest_imagePrimitives.width,
         SDLTest_imagePrimitives.height,
         SDLTest_imagePrimitives.bytes_per_pixel * 8,
         SDLTest_imagePrimitives.width * SDLTest_imagePrimitives.bytes_per_pixel,
-#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
-        0xff000000, /* Red bit mask. */
-        0x00ff0000, /* Green bit mask. */
-        0x0000ff00, /* Blue bit mask. */
-        0x000000ff  /* Alpha bit mask. */
-#else
-        0x000000ff, /* Red bit mask. */
-        0x0000ff00, /* Green bit mask. */
-        0x00ff0000, /* Blue bit mask. */
-        0xff000000  /* Alpha bit mask. */
-#endif
-    );
+        SDL_PIXELFORMAT_RGB24);
     return surface;
 }
 
diff --git a/src/test/SDL_test_imagePrimitivesBlend.c b/src/test/SDL_test_imagePrimitivesBlend.c
index c3fe053..8ee9f41 100644
--- a/src/test/SDL_test_imagePrimitivesBlend.c
+++ b/src/test/SDL_test_imagePrimitivesBlend.c
@@ -679,24 +679,13 @@ static const SDLTest_SurfaceImage_t SDLTest_imagePrimitivesBlend = {
  */
 SDL_Surface *SDLTest_ImagePrimitivesBlend()
 {
-    SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(
+    SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom(
         (void *)SDLTest_imagePrimitivesBlend.pixel_data,
         SDLTest_imagePrimitivesBlend.width,
         SDLTest_imagePrimitivesBlend.height,
         SDLTest_imagePrimitivesBlend.bytes_per_pixel * 8,
         SDLTest_imagePrimitivesBlend.width * SDLTest_imagePrimitivesBlend.bytes_per_pixel,
-#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
-        0xff000000, /* Red bit mask. */
-        0x00ff0000, /* Green bit mask. */
-        0x0000ff00, /* Blue bit mask. */
-        0x000000ff  /* Alpha bit mask. */
-#else
-        0x000000ff, /* Red bit mask. */
-        0x0000ff00, /* Green bit mask. */
-        0x00ff0000, /* Blue bit mask. */
-        0xff000000  /* Alpha bit mask. */
-#endif
-    );
+        SDL_PIXELFORMAT_RGB24);
     return surface;
 }
 
diff --git a/test/testautomation_audio.c b/test/testautomation_audio.c
index 0e75e19..03cc646 100644
--- a/test/testautomation_audio.c
+++ b/test/testautomation_audio.c
@@ -1040,8 +1040,8 @@ int audio_resampleLoss()
     SDLTest_AssertPass("Test resampling of %i s %i Hz %f phase sine wave from sampling rate of %i Hz to %i Hz",
                        spec->time, spec->freq, spec->phase, spec->rate_in, spec->rate_out);
 
-    ret = SDL_BuildAudioCVT(&cvt, AUDIO_F32, 1, spec->rate_in, AUDIO_F32, 1, spec->rate_out);
-    SDLTest_AssertPass("Call to SDL_BuildAudioCVT(&cvt, AUDIO_F32, 1, %i, AUDIO_F32, 1, %i)", spec->rate_in, spec->rate_out);
+    ret = SDL_BuildAudioCVT(&cvt, AUDIO_F32SYS, 1, spec->rate_in, AUDIO_F32SYS, 1, spec->rate_out);
+    SDLTest_AssertPass("Call to SDL_BuildAudioCVT(&cvt, AUDIO_F32SYS, 1, %i, AUDIO_F32SYS, 1, %i)", spec->rate_in, spec->rate_out);
     SDLTest_AssertCheck(ret == 1, "Expected SDL_BuildAudioCVT to succeed and conversion to be needed.");
     if (ret != 1) {
       return TEST_ABORTED;