Add testcase for gdimagecompare()
parent
7d90042437
commit
cc02e8878d
|
@ -34,6 +34,7 @@ if (BUILD_TEST)
|
|||
gdimagecolorreplace
|
||||
gdimagecolorresolve
|
||||
gdimagecolortransparent
|
||||
gdimagecompare
|
||||
gdimagecontrast
|
||||
gdimageconvolution
|
||||
gdimagecopy
|
||||
|
|
|
@ -30,6 +30,7 @@ include gdimagecolormatch/Makemodule.am
|
|||
include gdimagecolorreplace/Makemodule.am
|
||||
include gdimagecolorresolve/Makemodule.am
|
||||
include gdimagecolortransparent/Makemodule.am
|
||||
include gdimagecompare/Makemodule.am
|
||||
include gdimagecontrast/Makemodule.am
|
||||
include gdimageconvolution/Makemodule.am
|
||||
include gdimagecopy/Makemodule.am
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
/gdimagecompare
|
|
@ -0,0 +1,4 @@
|
|||
LIST(APPEND TESTS_FILES
|
||||
gdimagecompare
|
||||
)
|
||||
ADD_GD_TESTS()
|
|
@ -0,0 +1,5 @@
|
|||
libgd_test_programs += \
|
||||
gdimagecompare/gdimagecompare
|
||||
|
||||
EXTRA_DIST += \
|
||||
gdimagecompare/CMakeLists.txt
|
|
@ -0,0 +1,56 @@
|
|||
/**
|
||||
* Base test for gdImageCompare()
|
||||
*/
|
||||
|
||||
#include "gd.h"
|
||||
#include "gdtest.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
gdImagePtr im1;
|
||||
gdImagePtr im2;
|
||||
int black;
|
||||
int red1, red2;
|
||||
int yellow1, yellow2;
|
||||
int white;
|
||||
int blue;
|
||||
int ret;
|
||||
|
||||
im1 = gdImageCreate(128, 128);
|
||||
im2 = gdImageCreateTrueColor(256, 256);
|
||||
|
||||
/* Set different interlace */
|
||||
gdImageInterlace(im1, 1);
|
||||
gdImageInterlace(im2, 2);
|
||||
|
||||
/* Set different transparent */
|
||||
gdImageColorTransparent(im1, 10);
|
||||
gdImageColorTransparent(im2, 20);
|
||||
|
||||
/* Allocate different color number */
|
||||
black = gdImageColorAllocate(im1, 0, 0, 0);
|
||||
red1 = gdImageColorAllocate(im1, 255, 0, 0);
|
||||
yellow1 = gdImageColorAllocate(im1, 255, 255, 0);
|
||||
red2 = gdImageColorAllocate(im2, 255, 0, 0);
|
||||
yellow2 = gdImageColorAllocate(im2, 255, 255, 0);
|
||||
white = gdImageColorAllocate(im2, 255, 255, 255);
|
||||
blue = gdImageColorAllocate(im2, 0, 0, 255);
|
||||
|
||||
/* Filled different color */
|
||||
gdImageFilledRectangle(im1, 0, 0, 127, 8, black);
|
||||
gdImageFilledRectangle(im1, 9, 0, 127, 16, red1);
|
||||
gdImageFilledRectangle(im1, 17, 0, 127, 24, yellow1);
|
||||
gdImageFilledRectangle(im2, 0, 0, 127, 8, red2);
|
||||
gdImageFilledRectangle(im2, 9, 0, 127, 16, yellow2);
|
||||
gdImageFilledRectangle(im2, 17, 0, 127, 24, white);
|
||||
gdImageFilledRectangle(im2, 25, 0, 127, 32, blue);
|
||||
|
||||
ret = gdImageCompare(im1, im2);
|
||||
|
||||
gdTestAssert(ret == (GD_CMP_INTERLACE | GD_CMP_TRANSPARENT | GD_CMP_TRUECOLOR | GD_CMP_SIZE_X | GD_CMP_SIZE_Y | GD_CMP_COLOR | GD_CMP_IMAGE | GD_CMP_NUM_COLORS));
|
||||
|
||||
gdImageDestroy(im1);
|
||||
gdImageDestroy(im2);
|
||||
|
||||
return gdNumFailures();
|
||||
}
|
Loading…
Reference in New Issue