diff options
Diffstat (limited to 'Build/source/libs/gd/libgd-src/tests/png')
7 files changed, 39 insertions, 47 deletions
diff --git a/Build/source/libs/gd/libgd-src/tests/png/CMakeLists.txt b/Build/source/libs/gd/libgd-src/tests/png/CMakeLists.txt index 128b51df0ce..5235417eaae 100644 --- a/Build/source/libs/gd/libgd-src/tests/png/CMakeLists.txt +++ b/Build/source/libs/gd/libgd-src/tests/png/CMakeLists.txt @@ -1,4 +1,4 @@ - +IF(PNG_FOUND) SET(TESTS_FILES png_im2im png_null @@ -9,9 +9,6 @@ SET(TESTS_FILES bug00088 bug00193 ) +ENDIF(PNG_FOUND) -FOREACH(test_name ${TESTS_FILES}) - add_executable(${test_name} "${test_name}.c") - target_link_libraries (${test_name} gdTest) - add_test(NAME ${test_name} COMMAND ${test_name}) -ENDFOREACH(test_name) +ADD_GD_TESTS() diff --git a/Build/source/libs/gd/libgd-src/tests/png/Makemodule.am b/Build/source/libs/gd/libgd-src/tests/png/Makemodule.am new file mode 100644 index 00000000000..01c48036cc7 --- /dev/null +++ b/Build/source/libs/gd/libgd-src/tests/png/Makemodule.am @@ -0,0 +1,20 @@ +if HAVE_LIBPNG +libgd_test_programs += \ + png/bug00011 \ + png/bug00033 \ + png/bug00086 \ + png/bug00088 \ + png/bug00193 \ + png/png_im2im \ + png/png_null \ + png/png_resolution +endif + +EXTRA_DIST += \ + png/CMakeLists.txt \ + png/bug00033.png \ + png/bug00088_1.png \ + png/bug00088_1_exp.png \ + png/bug00088_2.png \ + png/bug00088_2_exp.png \ + png/emptyfile diff --git a/Build/source/libs/gd/libgd-src/tests/png/bug00011.c b/Build/source/libs/gd/libgd-src/tests/png/bug00011.c index 865c87ea5cd..f58ab61e2aa 100644 --- a/Build/source/libs/gd/libgd-src/tests/png/bug00011.c +++ b/Build/source/libs/gd/libgd-src/tests/png/bug00011.c @@ -1,4 +1,3 @@ -/* $Id$ */ #include "gd.h" #include <stdio.h> #include <stdlib.h> @@ -8,14 +7,8 @@ int main() { gdImagePtr im; FILE *fp; - char path[2048]; - sprintf(path, "%s/png/emptyfile", GDTEST_TOP_DIR); - fp = fopen(path, "rb"); - if (!fp) { - fprintf(stderr, "failed, cannot open file: %s\n", path); - return 1; - } + fp = gdTestFileOpen("png/emptyfile"); im = gdImageCreateFromPng(fp); fclose(fp); diff --git a/Build/source/libs/gd/libgd-src/tests/png/bug00033.c b/Build/source/libs/gd/libgd-src/tests/png/bug00033.c index f7e90f0824c..faf0a183590 100644 --- a/Build/source/libs/gd/libgd-src/tests/png/bug00033.c +++ b/Build/source/libs/gd/libgd-src/tests/png/bug00033.c @@ -1,4 +1,3 @@ -/* $Id$ */ #include "gd.h" #include <stdio.h> #include <stdlib.h> @@ -8,17 +7,10 @@ int main() { gdImagePtr im; FILE *fp; - char path[1024]; gdSetErrorMethod(gdSilence); - sprintf(path, "%s/png/bug00033.png", GDTEST_TOP_DIR); - fp = fopen(path, "rb"); - if (!fp) { - printf("failed, cannot open file <%s>\n", path); - return 1; - } - + fp = gdTestFileOpen("png/bug00033.png"); im = gdImageCreateFromPng(fp); fclose(fp); diff --git a/Build/source/libs/gd/libgd-src/tests/png/bug00086.c b/Build/source/libs/gd/libgd-src/tests/png/bug00086.c index ef9d43b2b56..f29b5d73e20 100644 --- a/Build/source/libs/gd/libgd-src/tests/png/bug00086.c +++ b/Build/source/libs/gd/libgd-src/tests/png/bug00086.c @@ -1,4 +1,3 @@ -/* $Id$ */ /* id: gdbad3.c, Xavier Roche, May. 2007 */ /* gcc gdbad3.c -o bad -lgd && ./bad */ @@ -17,7 +16,7 @@ int main(void) if ( ( im = gdImageCreateFromPngPtr(93, (char*) &pngdata[0]) ) == NULL) { return 0; } else { - fprintf(stderr, "failed!\n"); + gdTestErrorMsg("failed!\n"); gdImageDestroy(im); return 1; } diff --git a/Build/source/libs/gd/libgd-src/tests/png/bug00088.c b/Build/source/libs/gd/libgd-src/tests/png/bug00088.c index 78495aa4410..5c0ab5834a0 100644 --- a/Build/source/libs/gd/libgd-src/tests/png/bug00088.c +++ b/Build/source/libs/gd/libgd-src/tests/png/bug00088.c @@ -1,4 +1,3 @@ -/* $Id$ */ #include "gd.h" #include <stdio.h> #include <stdlib.h> @@ -9,7 +8,7 @@ int main() int error; gdImagePtr im; FILE *fp; - char path[1024]; + char *path; const char * files[2] = {"bug00088_1.png", "bug00088_2.png"}; const char * files_exp[2] = {"bug00088_1_exp.png", "bug00088_2_exp.png"}; @@ -18,13 +17,7 @@ int main() for (i = 0; i < cnt; i++) { - sprintf(path, "%s/png/%s", GDTEST_TOP_DIR, files[i]); - fp = fopen(path, "rb"); - if (!fp) { - printf("failed, cannot open file <%s>\n", path); - return 1; - } - + fp = gdTestFileOpen2("png", files[i]); im = gdImageCreateFromPng(fp); fclose(fp); @@ -33,10 +26,12 @@ int main() continue; } - sprintf(path, "%s/png/%s", GDTEST_TOP_DIR, files_exp[i]); + path = gdTestFilePath2("png", files_exp[i]); + if (!gdAssertImageEqualsToFile(path, im)) { error |= 1; } + free(path); gdImageDestroy(im); } diff --git a/Build/source/libs/gd/libgd-src/tests/png/png_im2im.c b/Build/source/libs/gd/libgd-src/tests/png/png_im2im.c index bac5e13aeb7..e02d057c220 100644 --- a/Build/source/libs/gd/libgd-src/tests/png/png_im2im.c +++ b/Build/source/libs/gd/libgd-src/tests/png/png_im2im.c @@ -12,7 +12,7 @@ int main() src = gdImageCreate(100, 100); if (src == NULL) { - printf("could not create src\n"); + gdTestErrorMsg("could not create src\n"); return 1; } r = gdImageColorAllocate(src, 0xFF, 0, 0); @@ -23,39 +23,35 @@ int main() gdImageEllipse(src, 70, 25, 30, 20, b); #define OUTPUT_PNG(name) do { \ - FILE *fp; \ - \ - fp = fopen("png_im2im_" #name ".png", "wb"); \ - if (fp) { \ - gdImagePng(name, fp); \ - fclose(fp); \ - } \ + FILE *fp = gdTestTempFp(); \ + gdImagePng(name, fp); \ + fclose(fp); \ } while (0) OUTPUT_PNG(src); p = gdImagePngPtr(src, &size); if (p == NULL) { status = 1; - printf("p is null\n"); + gdTestErrorMsg("p is null\n"); goto door0; } if (size <= 0) { status = 1; - printf("size is non-positive\n"); + gdTestErrorMsg("size is non-positive\n"); goto door1; } dst = gdImageCreateFromPngPtr(size, p); if (dst == NULL) { status = 1; - printf("could not create dst\n"); + gdTestErrorMsg("could not create dst\n"); goto door1; } OUTPUT_PNG(dst); gdTestImageDiff(src, dst, NULL, &result); if (result.pixels_changed > 0) { status = 1; - printf("pixels changed: %d\n", result.pixels_changed); + gdTestErrorMsg("pixels changed: %d\n", result.pixels_changed); } gdImageDestroy(dst); door1: |