Skip to content

Commit 3e44505

Browse files
committed
Updated automated test for saving new formats
1 parent 70dad26 commit 3e44505

File tree

1 file changed

+13
-34
lines changed

1 file changed

+13
-34
lines changed

test/main.c

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ static const Format formats[] =
132132
#else
133133
false,
134134
#endif
135-
SDL_IMAGE_SAVE_AVIF,
135+
SAVE_AVIF,
136136
IMG_isAVIF,
137137
IMG_LoadAVIF_IO,
138138
},
@@ -148,7 +148,7 @@ static const Format formats[] =
148148
#else
149149
false,
150150
#endif
151-
false, /* can save */
151+
SAVE_BMP,
152152
IMG_isBMP,
153153
IMG_LoadBMP_IO,
154154
},
@@ -174,13 +174,13 @@ static const Format formats[] =
174174
"palette.bmp",
175175
23,
176176
42,
177-
0, /* lossless */
177+
10, /* lossless indexed, dithered rgba */
178178
#if USING_IMAGEIO || defined(LOAD_GIF)
179179
true,
180180
#else
181181
false,
182182
#endif
183-
false, /* can save */
183+
SAVE_GIF,
184184
IMG_isGIF,
185185
IMG_LoadGIF_IO,
186186
},
@@ -212,7 +212,7 @@ static const Format formats[] =
212212
#else
213213
false,
214214
#endif
215-
SDL_IMAGE_SAVE_JPG,
215+
SAVE_JPG,
216216
IMG_isJPG,
217217
IMG_LoadJPG_IO,
218218
},
@@ -280,7 +280,7 @@ static const Format formats[] =
280280
#else
281281
false,
282282
#endif
283-
SDL_IMAGE_SAVE_PNG,
283+
SAVE_PNG,
284284
IMG_isPNG,
285285
IMG_LoadPNG_IO,
286286
},
@@ -376,7 +376,7 @@ static const Format formats[] =
376376
#else
377377
false,
378378
#endif
379-
false, /* can save */
379+
SAVE_TGA, /* can save */
380380
NULL,
381381
IMG_LoadTGA_IO,
382382
},
@@ -408,7 +408,7 @@ static const Format formats[] =
408408
#else
409409
false,
410410
#endif
411-
false, /* can save */
411+
SAVE_WEBP, /* can save */
412412
IMG_isWEBP,
413413
IMG_LoadWEBP_IO,
414414
},
@@ -795,33 +795,12 @@ FormatSaveTest(const Format *format,
795795
}
796796

797797
SDL_ClearError();
798-
if (SDL_strcmp (format->name, "AVIF") == 0) {
799-
if (rw) {
800-
dest = SDL_IOFromFile(filename, "wb");
801-
result = IMG_SaveAVIF_IO(reference, dest, false, 90);
802-
SDL_CloseIO(dest);
803-
} else {
804-
result = IMG_SaveAVIF(reference, filename, 90);
805-
}
806-
} else if (SDL_strcmp(format->name, "JPG") == 0) {
807-
if (rw) {
808-
dest = SDL_IOFromFile(filename, "wb");
809-
result = IMG_SaveJPG_IO(reference, dest, false, 90);
810-
SDL_CloseIO(dest);
811-
} else {
812-
result = IMG_SaveJPG(reference, filename, 90);
813-
}
814-
} else if (SDL_strcmp (format->name, "PNG") == 0) {
815-
if (rw) {
816-
dest = SDL_IOFromFile(filename, "wb");
817-
result = IMG_SavePNG_IO(reference, dest, false);
818-
SDL_CloseIO(dest);
819-
} else {
820-
result = IMG_SavePNG(reference, filename);
821-
}
798+
if (rw) {
799+
dest = SDL_IOFromFile(filename, "wb");
800+
result = IMG_SaveTyped_IO(reference, dest, false, format->name);
801+
SDL_CloseIO(dest);
822802
} else {
823-
SDLTest_AssertCheck(false, "How do I save %s?", format->name);
824-
goto out;
803+
result = IMG_Save(reference, filename);
825804
}
826805

827806
SDLTest_AssertCheck(result, "Save %s (%s)", filename, SDL_GetError());

0 commit comments

Comments
 (0)