Update SDL3 from 3.2.4 to 3.2.20
This commit is contained in:
@@ -112,7 +112,7 @@ static void testBlitBlendModeWithFormats(int mode, SDL_PixelFormat src_format, S
|
||||
int deltaR, deltaG, deltaB, deltaA;
|
||||
|
||||
/* Create dst surface */
|
||||
dst = SDL_CreateSurface(1, 1, dst_format);
|
||||
dst = SDL_CreateSurface(9, 1, dst_format);
|
||||
SDLTest_AssertCheck(dst != NULL, "Verify dst surface is not NULL");
|
||||
if (dst == NULL) {
|
||||
return;
|
||||
@@ -137,7 +137,7 @@ static void testBlitBlendModeWithFormats(int mode, SDL_PixelFormat src_format, S
|
||||
SDL_GetRGBA(color, SDL_GetPixelFormatDetails(dst->format), SDL_GetSurfacePalette(dst), &dstR, &dstG, &dstB, &dstA);
|
||||
|
||||
/* Create src surface */
|
||||
src = SDL_CreateSurface(1, 1, src_format);
|
||||
src = SDL_CreateSurface(9, 1, src_format);
|
||||
SDLTest_AssertCheck(src != NULL, "Verify src surface is not NULL");
|
||||
if (src == NULL) {
|
||||
return;
|
||||
@@ -313,6 +313,24 @@ static void AssertFileExist(const char *filename)
|
||||
|
||||
/* Test case functions */
|
||||
|
||||
/**
|
||||
* Tests creating surface with invalid format
|
||||
*/
|
||||
static int SDLCALL surface_testInvalidFormat(void *arg)
|
||||
{
|
||||
SDL_Surface *surface;
|
||||
|
||||
surface = SDL_CreateSurface(32, 32, SDL_PIXELFORMAT_UNKNOWN);
|
||||
SDLTest_AssertCheck(surface == NULL, "Verify SDL_CreateSurface(SDL_PIXELFORMAT_UNKNOWN) returned NULL");
|
||||
SDL_DestroySurface(surface);
|
||||
|
||||
surface = SDL_CreateSurfaceFrom(32, 32, SDL_PIXELFORMAT_UNKNOWN, NULL, 0);
|
||||
SDLTest_AssertCheck(surface == NULL, "Verify SDL_CreateSurfaceFrom(SDL_PIXELFORMAT_UNKNOWN) returned NULL");
|
||||
SDL_DestroySurface(surface);
|
||||
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests sprite saving and loading
|
||||
*/
|
||||
@@ -941,6 +959,75 @@ static int SDLCALL surface_testBlitBlendMul(void *arg)
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests blitting invalid surfaces.
|
||||
*/
|
||||
static int SDLCALL surface_testBlitInvalid(void *arg)
|
||||
{
|
||||
SDL_Surface *valid, *invalid;
|
||||
bool result;
|
||||
|
||||
valid = SDL_CreateSurface(1, 1, SDL_PIXELFORMAT_RGBA8888);
|
||||
SDLTest_AssertCheck(valid != NULL, "Check surface creation");
|
||||
invalid = SDL_CreateSurface(0, 0, SDL_PIXELFORMAT_RGBA8888);
|
||||
SDLTest_AssertCheck(invalid != NULL, "Check surface creation");
|
||||
SDLTest_AssertCheck(invalid->pixels == NULL, "Check surface pixels are NULL");
|
||||
|
||||
result = SDL_BlitSurface(invalid, NULL, valid, NULL);
|
||||
SDLTest_AssertCheck(result == true, "SDL_BlitSurface(invalid, NULL, valid, NULL), result = %s\n", result ? "true" : "false");
|
||||
result = SDL_BlitSurface(valid, NULL, invalid, NULL);
|
||||
SDLTest_AssertCheck(result == true, "SDL_BlitSurface(valid, NULL, invalid, NULL), result = %s\n", result ? "true" : "false");
|
||||
|
||||
result = SDL_BlitSurfaceScaled(invalid, NULL, valid, NULL, SDL_SCALEMODE_NEAREST);
|
||||
SDLTest_AssertCheck(result == false, "SDL_BlitSurfaceScaled(invalid, NULL, valid, NULL, SDL_SCALEMODE_NEAREST), result = %s\n", result ? "true" : "false");
|
||||
result = SDL_BlitSurfaceScaled(valid, NULL, invalid, NULL, SDL_SCALEMODE_NEAREST);
|
||||
SDLTest_AssertCheck(result == false, "SDL_BlitSurfaceScaled(valid, NULL, invalid, NULL, SDL_SCALEMODE_NEAREST), result = %s\n", result ? "true" : "false");
|
||||
|
||||
SDL_DestroySurface(valid);
|
||||
SDL_DestroySurface(invalid);
|
||||
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
static int SDLCALL surface_testBlitsWithBadCoordinates(void *arg)
|
||||
{
|
||||
const SDL_Rect rect[8] = {
|
||||
{ SDL_MAX_SINT32, 0, 2, 2 },
|
||||
{ 0, SDL_MAX_SINT32, 2, 2 },
|
||||
{ 0, 0, SDL_MAX_SINT32, 2 },
|
||||
{ 0, 0, 2, SDL_MAX_SINT32 },
|
||||
{ SDL_MIN_SINT32, 0, 2, 2 },
|
||||
{ 0, SDL_MIN_SINT32, 2, 2 },
|
||||
{ 0, 0, SDL_MIN_SINT32, 2 },
|
||||
{ 0, 0, 2, SDL_MIN_SINT32 }
|
||||
};
|
||||
|
||||
SDL_Surface *s;
|
||||
bool result;
|
||||
int i;
|
||||
|
||||
s = SDL_CreateSurface(1, 1, SDL_PIXELFORMAT_RGBA8888);
|
||||
SDLTest_AssertCheck(s != NULL, "Check surface creation");
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
result = SDL_BlitSurface(s, NULL, s, &rect[i]);
|
||||
SDLTest_AssertCheck(result == true, "SDL_BlitSurface(valid, NULL, valid, &rect), result = %s", result ? "true" : "false");
|
||||
|
||||
result = SDL_BlitSurface(s, &rect[i], s, NULL);
|
||||
SDLTest_AssertCheck(result == true, "SDL_BlitSurface(valid, &rect, valid, NULL), result = %s", result ? "true" : "false");
|
||||
|
||||
result = SDL_BlitSurfaceScaled(s, NULL, s, &rect[i], SDL_SCALEMODE_NEAREST);
|
||||
SDLTest_AssertCheck(result == true, "SDL_BlitSurfaceScaled(valid, NULL, valid, &rect, SDL_SCALEMODE_NEAREST), result = %s", result ? "true" : "false");
|
||||
|
||||
result = SDL_BlitSurfaceScaled(s, &rect[i], s, NULL, SDL_SCALEMODE_NEAREST);
|
||||
SDLTest_AssertCheck(result == true, "SDL_BlitSurfaceScaled(valid, &rect, valid, NULL, SDL_SCALEMODE_NEAREST), result = %s", result ? "true" : "false");
|
||||
}
|
||||
|
||||
SDL_DestroySurface(s);
|
||||
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
static int SDLCALL surface_testOverflow(void *arg)
|
||||
{
|
||||
char buf[1024];
|
||||
@@ -1540,6 +1627,10 @@ static int SDLCALL surface_testScale(void *arg)
|
||||
/* ================= Test References ================== */
|
||||
|
||||
/* Surface test cases */
|
||||
static const SDLTest_TestCaseReference surfaceTestInvalidFormat = {
|
||||
surface_testInvalidFormat, "surface_testInvalidFormat", "Tests creating surface with invalid format", TEST_ENABLED
|
||||
};
|
||||
|
||||
static const SDLTest_TestCaseReference surfaceTestSaveLoadBitmap = {
|
||||
surface_testSaveLoadBitmap, "surface_testSaveLoadBitmap", "Tests sprite saving and loading.", TEST_ENABLED
|
||||
};
|
||||
@@ -1608,6 +1699,14 @@ static const SDLTest_TestCaseReference surfaceTestBlitBlendMul = {
|
||||
surface_testBlitBlendMul, "surface_testBlitBlendMul", "Tests blitting routines with mul blending mode.", TEST_ENABLED
|
||||
};
|
||||
|
||||
static const SDLTest_TestCaseReference surfaceTestBlitInvalid = {
|
||||
surface_testBlitInvalid, "surface_testBlitInvalid", "Tests blitting routines with invalid surfaces.", TEST_ENABLED
|
||||
};
|
||||
|
||||
static const SDLTest_TestCaseReference surfaceTestBlitsWithBadCoordinates = {
|
||||
surface_testBlitsWithBadCoordinates, "surface_testBlitsWithBadCoordinates", "Test blitting routines with bad coordinates.", TEST_ENABLED
|
||||
};
|
||||
|
||||
static const SDLTest_TestCaseReference surfaceTestOverflow = {
|
||||
surface_testOverflow, "surface_testOverflow", "Test overflow detection.", TEST_ENABLED
|
||||
};
|
||||
@@ -1638,6 +1737,7 @@ static const SDLTest_TestCaseReference surfaceTestScale = {
|
||||
|
||||
/* Sequence of Surface test cases */
|
||||
static const SDLTest_TestCaseReference *surfaceTests[] = {
|
||||
&surfaceTestInvalidFormat,
|
||||
&surfaceTestSaveLoadBitmap,
|
||||
&surfaceTestBlitZeroSource,
|
||||
&surfaceTestBlit,
|
||||
@@ -1655,6 +1755,8 @@ static const SDLTest_TestCaseReference *surfaceTests[] = {
|
||||
&surfaceTestBlitBlendAddPremultiplied,
|
||||
&surfaceTestBlitBlendMod,
|
||||
&surfaceTestBlitBlendMul,
|
||||
&surfaceTestBlitInvalid,
|
||||
&surfaceTestBlitsWithBadCoordinates,
|
||||
&surfaceTestOverflow,
|
||||
&surfaceTestFlip,
|
||||
&surfaceTestPalette,
|
||||
|
||||
Reference in New Issue
Block a user