diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 60a33d8..4c92507 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -34,6 +34,7 @@ if (BUILD_TEST) gdimagecolorreplace gdimagecolorresolve gdimagecolortransparent + gdimagecompare gdimagecontrast gdimageconvolution gdimagecopy diff --git a/tests/Makefile.am b/tests/Makefile.am index 9d4f1ac..da69971 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 diff --git a/tests/gdimagecompare/.gitignore b/tests/gdimagecompare/.gitignore new file mode 100755 index 0000000..312a8c8 --- /dev/null +++ b/tests/gdimagecompare/.gitignore @@ -0,0 +1 @@ +/gdimagecompare diff --git a/tests/gdimagecompare/CMakeLists.txt b/tests/gdimagecompare/CMakeLists.txt new file mode 100644 index 0000000..2974a07 --- /dev/null +++ b/tests/gdimagecompare/CMakeLists.txt @@ -0,0 +1,4 @@ +LIST(APPEND TESTS_FILES + gdimagecompare +) +ADD_GD_TESTS() diff --git a/tests/gdimagecompare/Makemodule.am b/tests/gdimagecompare/Makemodule.am new file mode 100644 index 0000000..b4b0ebb --- /dev/null +++ b/tests/gdimagecompare/Makemodule.am @@ -0,0 +1,5 @@ +libgd_test_programs += \ + gdimagecompare/gdimagecompare + +EXTRA_DIST += \ + gdimagecompare/CMakeLists.txt diff --git a/tests/gdimagecompare/gdimagecompare.c b/tests/gdimagecompare/gdimagecompare.c new file mode 100644 index 0000000..0e8367a --- /dev/null +++ b/tests/gdimagecompare/gdimagecompare.c @@ -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(); +}