Load_XXX() functions test

This commit is contained in:
Thomas Bernard 2019-11-29 01:04:23 +01:00
parent 4fa256398c
commit 4918c9efa5
No known key found for this signature in database
GPG Key ID: 0FF11B67A5C0863C
3 changed files with 44 additions and 7 deletions

View File

@ -28,6 +28,8 @@ void Pre_load(T_IO_Context *context, short width, short height, long file_size,
{ {
printf("Pre_load(%p, %hd, %hd, %ld, %d, %d, %hhu)\n", printf("Pre_load(%p, %hd, %hd, %ld, %d, %d, %hhu)\n",
context, width, height, file_size, format, ratio, bpp); context, width, height, file_size, format, ratio, bpp);
context->Width = width;
context->Height = height;
} }
byte Get_pixel(T_IO_Context *context, short x, short y) byte Get_pixel(T_IO_Context *context, short x, short y)
@ -76,7 +78,7 @@ void Set_saving_layer(T_IO_Context *context, int layer)
void Set_loading_layer(T_IO_Context *context, int layer) void Set_loading_layer(T_IO_Context *context, int layer)
{ {
printf("Set_loading_layer(%p, %d)\n", context, layer); //printf("Set_loading_layer(%p, %d)\n", context, layer);
} }
void Set_image_mode(T_IO_Context *context, enum IMAGE_MODES mode) void Set_image_mode(T_IO_Context *context, enum IMAGE_MODES mode)

View File

@ -34,10 +34,11 @@
#include "../gfx2log.h" #include "../gfx2log.h"
#include "../gfx2mem.h" #include "../gfx2mem.h"
#define TESTFMT(fmt, sample) { # fmt, Test_ ## fmt, sample }, #define TESTFMT(fmt, sample) { # fmt, Test_ ## fmt, Load_ ## fmt, sample },
static const struct { static const struct {
const char * name; const char * name;
Func_IO_Test Test; Func_IO_Test Test;
Func_IO Load;
const char * sample; const char * sample;
} formats[] = { } formats[] = {
TESTFMT(PKM, "pkm/EVILNUN.PKM") TESTFMT(PKM, "pkm/EVILNUN.PKM")
@ -58,9 +59,9 @@ static const struct {
TESTFMT(GOS, "cpc/iMPdraw_GFX/SONIC.GO1") TESTFMT(GOS, "cpc/iMPdraw_GFX/SONIC.GO1")
TESTFMT(MOTO,"thomson/exocet-alientis.map") TESTFMT(MOTO,"thomson/exocet-alientis.map")
TESTFMT(HGR, "apple2/hgr/pop-swordfight.hgr") TESTFMT(HGR, "apple2/hgr/pop-swordfight.hgr")
TESTFMT(ACBM,"iff/ACBM/Jupiter_alt.pic") {"ACBM",Test_ACBM,Load_IFF, "iff/ACBM/Jupiter_alt.pic"},
TESTFMT(LBM, "iff/Danny_SkyTravellers_ANNO.iff") {"LBM", Test_LBM, Load_IFF, "iff/Danny_SkyTravellers_ANNO.iff"},
TESTFMT(PBM, "iff/pbm/FC.LBM") {"PBM", Test_PBM, Load_IFF, "iff/pbm/FC.LBM"},
TESTFMT(INFO,"amiga_icons/4colors/Utilities/Calculator.info") TESTFMT(INFO,"amiga_icons/4colors/Utilities/Calculator.info")
#ifndef __no_pnglib__ #ifndef __no_pnglib__
TESTFMT(PNG, "png/happy-birthday-guys.png") TESTFMT(PNG, "png/happy-birthday-guys.png")
@ -70,7 +71,7 @@ static const struct {
#endif #endif
TESTFMT(GPL, "palette-mariage_115.gpl") TESTFMT(GPL, "palette-mariage_115.gpl")
TESTFMT(PAL, "pal/dp4_256.pal") TESTFMT(PAL, "pal/dp4_256.pal")
{ NULL, NULL, NULL} { NULL, NULL, NULL, NULL}
}; };
/** /**
@ -100,6 +101,9 @@ static void context_set_file_path(T_IO_Context * context, const char * filepath)
} }
} }
/**
* test the Test_* functions
*/
int Test_Formats(void) int Test_Formats(void)
{ {
T_IO_Context context; T_IO_Context context;
@ -110,7 +114,7 @@ int Test_Formats(void)
memset(&context, 0, sizeof(context)); memset(&context, 0, sizeof(context));
for (i = 0; formats[i].name != NULL; i++) for (i = 0; formats[i].name != NULL; i++)
{ {
GFX2_Log(GFX2_DEBUG, "Testing format %s\n", formats[i].name); GFX2_Log(GFX2_DEBUG, "Testing format %s (Test)\n", formats[i].name);
// first check that the right sample is recognized // first check that the right sample is recognized
snprintf(path, sizeof(path), "../tests/pic-samples/%s", formats[i].sample); snprintf(path, sizeof(path), "../tests/pic-samples/%s", formats[i].sample);
f = fopen(path, "rb"); f = fopen(path, "rb");
@ -159,3 +163,33 @@ int Test_Formats(void)
free(context.File_directory); free(context.File_directory);
return 1; // OK return 1; // OK
} }
/**
* test the Load_* functions
*/
int Test_Load(void)
{
T_IO_Context context;
char path[256];
int i;
memset(&context, 0, sizeof(context));
for (i = 0; formats[i].name != NULL; i++)
{
GFX2_Log(GFX2_DEBUG, "Testing format %s (Load)\n", formats[i].name);
// first check that the right sample is recognized
snprintf(path, sizeof(path), "../tests/pic-samples/%s", formats[i].sample);
context_set_file_path(&context, path);
File_error = 0;
formats[i].Load(&context);
if (File_error != 0)
{
GFX2_Log(GFX2_ERROR, "Load_%s failed for file %s\n", formats[i].name, formats[i].sample);
return 0;
}
}
//Destroy_context(&context);
free(context.File_name);
free(context.File_directory);
return 1; // OK
}

View File

@ -6,3 +6,4 @@ TEST(CPC_compare_colors)
TEST(Packbits) TEST(Packbits)
TEST(Convert_24b_bitmap_to_256) TEST(Convert_24b_bitmap_to_256)
TEST(Formats) TEST(Formats)
TEST(Load)