add testcase gdImageCopyResized

master
wilson chen 2020-01-23 16:59:35 +08:00 committed by GitHub
parent 39d8665d06
commit 6271c38065
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 53 additions and 0 deletions

View File

@ -40,6 +40,7 @@ if (BUILD_TEST)
gdimagecopymerge
gdimagecopymergegray
gdimagecopyresampled
gdimagecopyresized
gdimagecopyrotated
gdimagecreate
gdimagecrop

View File

@ -36,6 +36,7 @@ include gdimagecopy/Makemodule.am
include gdimagecopymerge/Makemodule.am
include gdimagecopymergegray/Makemodule.am
include gdimagecopyresampled/Makemodule.am
include gdimagecopyresized/Makemodule.am
include gdimagecopyrotated/Makemodule.am
include gdimagecreate/Makemodule.am
include gdimagecrop/Makemodule.am

1
tests/gdimagecopyresized/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/gdimagecopyresized

View File

@ -0,0 +1,7 @@
IF(PNG_FOUND)
LIST(APPEND TESTS_FILES
gdimagecopyresized
)
ENDIF(PNG_FOUND)
ADD_GD_TESTS()

View File

@ -0,0 +1,8 @@
if HAVE_LIBPNG
libgd_test_programs += \
gdimagecopyresized/gdimagecopyresized
endif
EXTRA_DIST += \
gdimagecopyresized/CMakeLists.txt \
gdimagecopyresized/gdimagecopyresized_exp.png

View File

@ -0,0 +1,35 @@
/**
* add test case for gdImageCopyResized
*/
#include "gd.h"
#include "gdtest.h"
int main()
{
gdImagePtr src;
gdImagePtr dst;
gdImagePtr dst_tc;
/* We prepare two image type: Palette and True Color */
/* src image is white, while dst and dst_tc is black */
src = gdImageCreate(64, 64);
gdImageColorAllocate(src, 255, 255, 255);
dst = gdImageCreate(128, 128);
gdImageColorAllocate(dst, 0, 0, 0);
dst_tc = gdImageCreateTrueColor(128, 128);
/* Copy src to two image type separately */
/* We copy src to the center of dst and dst_tc */
gdImageCopyResized(dst, src, 32, 32, 0, 0, 64, 64, 64, 64);
gdImageCopyResized(dst_tc, src, 32, 32, 0, 0, 64, 64, 64, 64);
gdAssertImageEqualsToFile("gdimagecopyresized/gdimagecopyresized_exp.png", dst);
gdAssertImageEqualsToFile("gdimagecopyresized/gdimagecopyresized_exp.png", dst_tc);
gdImageDestroy(src);
gdImageDestroy(dst);
gdImageDestroy(dst_tc);
return gdNumFailures();
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 B