summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2020-01-04 18:04:10 +0100
committerChristoph M. Becker <cmbecker69@gmx.de>2020-01-04 19:06:51 +0100
commit6d21d304295731d67db324dc3bf4630a69ebc5d6 (patch)
treeba1d7f5e8faec7c97af5f59a33df6d0fa2c36c02 /tests
parent7a06c1669c563917bc48c464521e3de962ddb4e8 (diff)
downloadlibgd-6d21d304295731d67db324dc3bf4630a69ebc5d6.tar.gz
Fix #584: gdImageSetInterpolationMethod(im, GD_DEFAULT) inconsistent
We have to avoid the unintended fall through.
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt1
-rw-r--r--tests/Makefile.am1
-rw-r--r--tests/gdimagesetinterpolationmethod/.gitignore1
-rw-r--r--tests/gdimagesetinterpolationmethod/CMakeLists.txt5
-rw-r--r--tests/gdimagesetinterpolationmethod/Makemodule.am5
-rw-r--r--tests/gdimagesetinterpolationmethod/github_bug_00584.c31
6 files changed, 44 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 8a39995..33aa8e1 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -62,6 +62,7 @@ if (BUILD_TEST)
gdimagerotate
gdimagescale
gdimagescatterex
+ gdimagesetinterpolationmethod
gdimagesetpixel
gdimagestring
gdimagestring16
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 9c98a3c..e9e5113 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -58,6 +58,7 @@ include gdimagerectangle/Makemodule.am
include gdimagerotate/Makemodule.am
include gdimagescale/Makemodule.am
include gdimagescatterex/Makemodule.am
+include gdimagesetinterpolationmethod/Makemodule.am
include gdimagesetpixel/Makemodule.am
include gdimagestring/Makemodule.am
include gdimagestring16/Makemodule.am
diff --git a/tests/gdimagesetinterpolationmethod/.gitignore b/tests/gdimagesetinterpolationmethod/.gitignore
new file mode 100644
index 0000000..db7b3af
--- /dev/null
+++ b/tests/gdimagesetinterpolationmethod/.gitignore
@@ -0,0 +1 @@
+/github_bug_00584
diff --git a/tests/gdimagesetinterpolationmethod/CMakeLists.txt b/tests/gdimagesetinterpolationmethod/CMakeLists.txt
new file mode 100644
index 0000000..6551062
--- /dev/null
+++ b/tests/gdimagesetinterpolationmethod/CMakeLists.txt
@@ -0,0 +1,5 @@
+LIST(APPEND TESTS_FILES
+ github_bug_00584
+)
+
+ADD_GD_TESTS()
diff --git a/tests/gdimagesetinterpolationmethod/Makemodule.am b/tests/gdimagesetinterpolationmethod/Makemodule.am
new file mode 100644
index 0000000..1b83336
--- /dev/null
+++ b/tests/gdimagesetinterpolationmethod/Makemodule.am
@@ -0,0 +1,5 @@
+libgd_test_programs += \
+ gdimagesetinterpolationmethod/github_bug_00584
+
+EXTRA_DIST += \
+ gdimagesetinterpolationmethod/CMakeLists.txt
diff --git a/tests/gdimagesetinterpolationmethod/github_bug_00584.c b/tests/gdimagesetinterpolationmethod/github_bug_00584.c
new file mode 100644
index 0000000..e11f9f0
--- /dev/null
+++ b/tests/gdimagesetinterpolationmethod/github_bug_00584.c
@@ -0,0 +1,31 @@
+/**
+ * Test that gdImageSetInterpolationMethod(im, GD_DEFAULT) is consistent
+ *
+ * See <https://github.com/libgd/libgd/issues/584>
+ */
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+int main()
+{
+ gdImagePtr im;
+ gdInterpolationMethod old_m, new_m;
+ interpolation_method old_f, new_f;
+
+ im = gdImageCreateTrueColor(8, 8);
+ gdTestAssert(im != NULL);
+ gdTestAssert(gdImageSetInterpolationMethod(im, GD_SINC));
+ old_m = gdImageGetInterpolationMethod(im);
+ gdTestAssert(old_m == GD_SINC);
+ old_f = im->interpolation;
+ gdTestAssert(gdImageSetInterpolationMethod(im, GD_DEFAULT));
+ new_m = gdImageGetInterpolationMethod(im);
+ gdTestAssert(new_m == GD_LINEAR);
+ new_f = im->interpolation;
+ gdTestAssert(new_m != old_m);
+ gdTestAssert(new_f != old_f);
+ gdImageDestroy(im);
+ return gdNumFailures();
+}