diff --git a/src/tests/mockloadsave.c b/src/tests/mockloadsave.c index 5ef04d3d..35f08a68 100644 --- a/src/tests/mockloadsave.c +++ b/src/tests/mockloadsave.c @@ -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", 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) @@ -76,7 +78,7 @@ void Set_saving_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) diff --git a/src/tests/testformats.c b/src/tests/testformats.c index a7c4da2c..221693cb 100644 --- a/src/tests/testformats.c +++ b/src/tests/testformats.c @@ -34,10 +34,11 @@ #include "../gfx2log.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 { const char * name; Func_IO_Test Test; + Func_IO Load; const char * sample; } formats[] = { TESTFMT(PKM, "pkm/EVILNUN.PKM") @@ -58,9 +59,9 @@ static const struct { TESTFMT(GOS, "cpc/iMPdraw_GFX/SONIC.GO1") TESTFMT(MOTO,"thomson/exocet-alientis.map") TESTFMT(HGR, "apple2/hgr/pop-swordfight.hgr") - TESTFMT(ACBM,"iff/ACBM/Jupiter_alt.pic") - TESTFMT(LBM, "iff/Danny_SkyTravellers_ANNO.iff") - TESTFMT(PBM, "iff/pbm/FC.LBM") + {"ACBM",Test_ACBM,Load_IFF, "iff/ACBM/Jupiter_alt.pic"}, + {"LBM", Test_LBM, Load_IFF, "iff/Danny_SkyTravellers_ANNO.iff"}, + {"PBM", Test_PBM, Load_IFF, "iff/pbm/FC.LBM"}, TESTFMT(INFO,"amiga_icons/4colors/Utilities/Calculator.info") #ifndef __no_pnglib__ TESTFMT(PNG, "png/happy-birthday-guys.png") @@ -70,7 +71,7 @@ static const struct { #endif TESTFMT(GPL, "palette-mariage_115.gpl") 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) { T_IO_Context context; @@ -110,7 +114,7 @@ int Test_Formats(void) memset(&context, 0, sizeof(context)); 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 snprintf(path, sizeof(path), "../tests/pic-samples/%s", formats[i].sample); f = fopen(path, "rb"); @@ -159,3 +163,33 @@ int Test_Formats(void) free(context.File_directory); 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 +} diff --git a/src/tests/testlist.h b/src/tests/testlist.h index cbf5f6e3..4d1e6277 100644 --- a/src/tests/testlist.h +++ b/src/tests/testlist.h @@ -6,3 +6,4 @@ TEST(CPC_compare_colors) TEST(Packbits) TEST(Convert_24b_bitmap_to_256) TEST(Formats) +TEST(Load)