summaryrefslogtreecommitdiff
path: root/tests/gdimagesquaretocircle
diff options
context:
space:
mode:
authorwilson chen <willson.chenwx@gmail.com>2020-03-08 19:57:34 +0800
committerGitHub <noreply@github.com>2020-03-08 19:57:34 +0800
commitaa21ec9a61d98ab3f0a1338131e142f7efbf8694 (patch)
tree7c94a1fbcfcd2ff2232ce0650bb96d210cbd94ac /tests/gdimagesquaretocircle
parentcc02e8878dfaee6f879f47f53bc0407026f555f2 (diff)
downloadlibgd-aa21ec9a61d98ab3f0a1338131e142f7efbf8694.tar.gz
add testcase for gdimagesquaretocircle()
Diffstat (limited to 'tests/gdimagesquaretocircle')
-rw-r--r--tests/gdimagesquaretocircle/.gitignore1
-rw-r--r--tests/gdimagesquaretocircle/CMakeLists.txt7
-rw-r--r--tests/gdimagesquaretocircle/Makemodule.am6
-rw-r--r--tests/gdimagesquaretocircle/gdimagesquaretocircle.c32
-rw-r--r--tests/gdimagesquaretocircle/gdimagesquaretocircle_exp.pngbin0 -> 1414 bytes
5 files changed, 46 insertions, 0 deletions
diff --git a/tests/gdimagesquaretocircle/.gitignore b/tests/gdimagesquaretocircle/.gitignore
new file mode 100644
index 0000000..bf6e191
--- /dev/null
+++ b/tests/gdimagesquaretocircle/.gitignore
@@ -0,0 +1 @@
+/gdimagesquaretocircle
diff --git a/tests/gdimagesquaretocircle/CMakeLists.txt b/tests/gdimagesquaretocircle/CMakeLists.txt
new file mode 100644
index 0000000..a8c9430
--- /dev/null
+++ b/tests/gdimagesquaretocircle/CMakeLists.txt
@@ -0,0 +1,7 @@
+IF(PNG_FOUND)
+LIST(APPEND TESTS_FILES
+ gdimagesquaretocircle
+)
+ENDIF(PNG_FOUND)
+
+ADD_GD_TESTS()
diff --git a/tests/gdimagesquaretocircle/Makemodule.am b/tests/gdimagesquaretocircle/Makemodule.am
new file mode 100644
index 0000000..5b30300
--- /dev/null
+++ b/tests/gdimagesquaretocircle/Makemodule.am
@@ -0,0 +1,6 @@
+libgd_test_programs += \
+ gdimagesquaretocircle/gdimagesquaretocircle
+
+EXTRA_DIST += \
+ gdimagesquaretocircle/CMakeLists.txt \
+ gdimagesquaretocircle/gdimagesquaretocircle_exp.png
diff --git a/tests/gdimagesquaretocircle/gdimagesquaretocircle.c b/tests/gdimagesquaretocircle/gdimagesquaretocircle.c
new file mode 100644
index 0000000..f8fba91
--- /dev/null
+++ b/tests/gdimagesquaretocircle/gdimagesquaretocircle.c
@@ -0,0 +1,32 @@
+/**
+ * Basic test for gdImageSquareToCircle()
+ */
+#include "gd.h"
+#include "gdfx.h"
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr im1, im2;
+ int white;
+ int black;
+
+ im1 = gdImageCreateTrueColor(128, 128);
+ white = gdImageColorAllocate(im1, 255, 255, 255);
+ black = gdImageColorAllocate(im1, 0, 0, 0);
+ gdImageFilledRectangle(im1, 0, 0, 127, 127, white);
+
+ /* Draw a cross line in the middle of im1 */
+ /* The horizonal line will become a circle in im2 */
+ /* The vertical line will become a horizonal with half len in im2 */
+ gdImageLine(im1, 0, 63, 127, 63, black);
+ gdImageLine(im1, 63, 0, 63, 127, black);
+ im2 = gdImageSquareToCircle(im1, 64);
+
+ gdAssertImageEqualsToFile("gdimagesquaretocircle/gdimagesquaretocircle_exp.png", im2);
+
+ gdImageDestroy(im1);
+ gdImageDestroy(im2);
+
+ return gdNumFailures();
+}
diff --git a/tests/gdimagesquaretocircle/gdimagesquaretocircle_exp.png b/tests/gdimagesquaretocircle/gdimagesquaretocircle_exp.png
new file mode 100644
index 0000000..222bb13
--- /dev/null
+++ b/tests/gdimagesquaretocircle/gdimagesquaretocircle_exp.png
Binary files differ