summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorwilson chen <willson.chenwx@gmail.com>2020-01-23 16:59:35 +0800
committerGitHub <noreply@github.com>2020-01-23 16:59:35 +0800
commit6271c38065c61caf69a1a334ddcd8cbdea967c8f (patch)
tree9d1d23708a2614e8c2f374538302a1a4f95d734e /tests
parent39d8665d069166e0a4aa90f50c4ce319f38220c8 (diff)
downloadlibgd-6271c38065c61caf69a1a334ddcd8cbdea967c8f.tar.gz
add testcase gdImageCopyResized
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt1
-rw-r--r--tests/Makefile.am1
-rw-r--r--tests/gdimagecopyresized/.gitignore1
-rw-r--r--tests/gdimagecopyresized/CMakeLists.txt7
-rw-r--r--tests/gdimagecopyresized/Makemodule.am8
-rw-r--r--tests/gdimagecopyresized/gdimagecopyresized.c35
-rw-r--r--tests/gdimagecopyresized/gdimagecopyresized_exp.pngbin0 -> 129 bytes
7 files changed, 53 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 33aa8e1..62debae 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -40,6 +40,7 @@ if (BUILD_TEST)
gdimagecopymerge
gdimagecopymergegray
gdimagecopyresampled
+ gdimagecopyresized
gdimagecopyrotated
gdimagecreate
gdimagecrop
diff --git a/tests/Makefile.am b/tests/Makefile.am
index e9e5113..c3e4ca5 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -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
diff --git a/tests/gdimagecopyresized/.gitignore b/tests/gdimagecopyresized/.gitignore
new file mode 100644
index 0000000..185cf1f
--- /dev/null
+++ b/tests/gdimagecopyresized/.gitignore
@@ -0,0 +1 @@
+/gdimagecopyresized
diff --git a/tests/gdimagecopyresized/CMakeLists.txt b/tests/gdimagecopyresized/CMakeLists.txt
new file mode 100644
index 0000000..78b4fa9
--- /dev/null
+++ b/tests/gdimagecopyresized/CMakeLists.txt
@@ -0,0 +1,7 @@
+IF(PNG_FOUND)
+LIST(APPEND TESTS_FILES
+ gdimagecopyresized
+)
+ENDIF(PNG_FOUND)
+
+ADD_GD_TESTS()
diff --git a/tests/gdimagecopyresized/Makemodule.am b/tests/gdimagecopyresized/Makemodule.am
new file mode 100644
index 0000000..9d83e40
--- /dev/null
+++ b/tests/gdimagecopyresized/Makemodule.am
@@ -0,0 +1,8 @@
+if HAVE_LIBPNG
+libgd_test_programs += \
+ gdimagecopyresized/gdimagecopyresized
+endif
+
+EXTRA_DIST += \
+ gdimagecopyresized/CMakeLists.txt \
+ gdimagecopyresized/gdimagecopyresized_exp.png
diff --git a/tests/gdimagecopyresized/gdimagecopyresized.c b/tests/gdimagecopyresized/gdimagecopyresized.c
new file mode 100644
index 0000000..137f84b
--- /dev/null
+++ b/tests/gdimagecopyresized/gdimagecopyresized.c
@@ -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();
+}
diff --git a/tests/gdimagecopyresized/gdimagecopyresized_exp.png b/tests/gdimagecopyresized/gdimagecopyresized_exp.png
new file mode 100644
index 0000000..32fa084
--- /dev/null
+++ b/tests/gdimagecopyresized/gdimagecopyresized_exp.png
Binary files differ