summaryrefslogtreecommitdiff
path: root/Build/source/libs/gd/libgd-2.1.1/tests/png
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/gd/libgd-2.1.1/tests/png')
-rw-r--r--Build/source/libs/gd/libgd-2.1.1/tests/png/CMakeLists.txt17
-rw-r--r--Build/source/libs/gd/libgd-2.1.1/tests/png/bug00011.c27
-rw-r--r--Build/source/libs/gd/libgd-2.1.1/tests/png/bug00033.c32
-rw-r--r--Build/source/libs/gd/libgd-2.1.1/tests/png/bug00033.pngbin0 -> 393216 bytes
-rw-r--r--Build/source/libs/gd/libgd-2.1.1/tests/png/bug00086.c33
-rw-r--r--Build/source/libs/gd/libgd-2.1.1/tests/png/bug00088.c44
-rw-r--r--Build/source/libs/gd/libgd-2.1.1/tests/png/bug00088_1.pngbin0 -> 1892 bytes
-rw-r--r--Build/source/libs/gd/libgd-2.1.1/tests/png/bug00088_1_exp.pngbin0 -> 2791 bytes
-rw-r--r--Build/source/libs/gd/libgd-2.1.1/tests/png/bug00088_2.pngbin0 -> 238 bytes
-rw-r--r--Build/source/libs/gd/libgd-2.1.1/tests/png/bug00088_2_exp.pngbin0 -> 284 bytes
-rw-r--r--Build/source/libs/gd/libgd-2.1.1/tests/png/bug00193.c43
-rw-r--r--Build/source/libs/gd/libgd-2.1.1/tests/png/emptyfile0
-rw-r--r--Build/source/libs/gd/libgd-2.1.1/tests/png/png_im2im.c66
-rw-r--r--Build/source/libs/gd/libgd-2.1.1/tests/png/png_null.c17
-rw-r--r--Build/source/libs/gd/libgd-2.1.1/tests/png/png_resolution.c30
15 files changed, 309 insertions, 0 deletions
diff --git a/Build/source/libs/gd/libgd-2.1.1/tests/png/CMakeLists.txt b/Build/source/libs/gd/libgd-2.1.1/tests/png/CMakeLists.txt
new file mode 100644
index 00000000000..128b51df0ce
--- /dev/null
+++ b/Build/source/libs/gd/libgd-2.1.1/tests/png/CMakeLists.txt
@@ -0,0 +1,17 @@
+
+SET(TESTS_FILES
+ png_im2im
+ png_null
+ png_resolution
+ bug00011
+ bug00033
+ bug00086
+ bug00088
+ bug00193
+)
+
+FOREACH(test_name ${TESTS_FILES})
+ add_executable(${test_name} "${test_name}.c")
+ target_link_libraries (${test_name} gdTest)
+ add_test(NAME ${test_name} COMMAND ${test_name})
+ENDFOREACH(test_name)
diff --git a/Build/source/libs/gd/libgd-2.1.1/tests/png/bug00011.c b/Build/source/libs/gd/libgd-2.1.1/tests/png/bug00011.c
new file mode 100644
index 00000000000..865c87ea5cd
--- /dev/null
+++ b/Build/source/libs/gd/libgd-2.1.1/tests/png/bug00011.c
@@ -0,0 +1,27 @@
+/* $Id$ */
+#include "gd.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr im;
+ FILE *fp;
+ char path[2048];
+
+ sprintf(path, "%s/png/emptyfile", GDTEST_TOP_DIR);
+ fp = fopen(path, "rb");
+ if (!fp) {
+ fprintf(stderr, "failed, cannot open file: %s\n", path);
+ return 1;
+ }
+ im = gdImageCreateFromPng(fp);
+ fclose(fp);
+
+ if (!im) {
+ return 0;
+ } else {
+ return 1;
+ }
+}
diff --git a/Build/source/libs/gd/libgd-2.1.1/tests/png/bug00033.c b/Build/source/libs/gd/libgd-2.1.1/tests/png/bug00033.c
new file mode 100644
index 00000000000..f7e90f0824c
--- /dev/null
+++ b/Build/source/libs/gd/libgd-2.1.1/tests/png/bug00033.c
@@ -0,0 +1,32 @@
+/* $Id$ */
+#include "gd.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr im;
+ FILE *fp;
+ char path[1024];
+
+ gdSetErrorMethod(gdSilence);
+
+ sprintf(path, "%s/png/bug00033.png", GDTEST_TOP_DIR);
+ fp = fopen(path, "rb");
+ if (!fp) {
+ printf("failed, cannot open file <%s>\n", path);
+ return 1;
+ }
+
+ im = gdImageCreateFromPng(fp);
+ fclose(fp);
+
+ if (im) {
+ gdImageDestroy(im);
+ return 1;
+ } else {
+ return 0;
+ }
+
+}
diff --git a/Build/source/libs/gd/libgd-2.1.1/tests/png/bug00033.png b/Build/source/libs/gd/libgd-2.1.1/tests/png/bug00033.png
new file mode 100644
index 00000000000..73a7d6a3e77
--- /dev/null
+++ b/Build/source/libs/gd/libgd-2.1.1/tests/png/bug00033.png
Binary files differ
diff --git a/Build/source/libs/gd/libgd-2.1.1/tests/png/bug00086.c b/Build/source/libs/gd/libgd-2.1.1/tests/png/bug00086.c
new file mode 100644
index 00000000000..ef9d43b2b56
--- /dev/null
+++ b/Build/source/libs/gd/libgd-2.1.1/tests/png/bug00086.c
@@ -0,0 +1,33 @@
+/* $Id$ */
+/* id: gdbad3.c, Xavier Roche, May. 2007 */
+/* gcc gdbad3.c -o bad -lgd && ./bad */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "gd.h"
+#include "gdtest.h"
+
+static const unsigned char pngdata[93];
+int main(void)
+{
+ gdImagePtr im;
+
+ gdSetErrorMethod(gdSilence);
+
+ if ( ( im = gdImageCreateFromPngPtr(93, (char*) &pngdata[0]) ) == NULL) {
+ return 0;
+ } else {
+ fprintf(stderr, "failed!\n");
+ gdImageDestroy(im);
+ return 1;
+ }
+ return 0;
+}
+
+/* PNG data */
+static const unsigned char pngdata[93] = {137,80,78,71,13,10,26,10,0,0,
+ 0,13,73,72,68,82,0,0,0,120,0,0,0,131,8,6,0,0,0,70,49,223,8,0,0,0,6,98,
+ 75,71,68,0,255,0,255,0,255,160,189,167,147,0,0,0,9,112,72,89,115,0,0,92,
+ 70,0,0,92,70,1,20,148,67,65,0,0,0,9,118,112,65,103,0,0,0,120,0,0,0,131,
+ 0,226,13,249,45
+};
diff --git a/Build/source/libs/gd/libgd-2.1.1/tests/png/bug00088.c b/Build/source/libs/gd/libgd-2.1.1/tests/png/bug00088.c
new file mode 100644
index 00000000000..78495aa4410
--- /dev/null
+++ b/Build/source/libs/gd/libgd-2.1.1/tests/png/bug00088.c
@@ -0,0 +1,44 @@
+/* $Id$ */
+#include "gd.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include "gdtest.h"
+
+int main()
+{
+ int error;
+ gdImagePtr im;
+ FILE *fp;
+ char path[1024];
+ const char * files[2] = {"bug00088_1.png", "bug00088_2.png"};
+ const char * files_exp[2] = {"bug00088_1_exp.png", "bug00088_2_exp.png"};
+
+ int i, cnt = 2;
+ error = 0;
+
+ for (i = 0; i < cnt; i++) {
+
+ sprintf(path, "%s/png/%s", GDTEST_TOP_DIR, files[i]);
+ fp = fopen(path, "rb");
+ if (!fp) {
+ printf("failed, cannot open file <%s>\n", path);
+ return 1;
+ }
+
+ im = gdImageCreateFromPng(fp);
+ fclose(fp);
+
+ if (!im) {
+ error |= 1;
+ continue;
+ }
+
+ sprintf(path, "%s/png/%s", GDTEST_TOP_DIR, files_exp[i]);
+ if (!gdAssertImageEqualsToFile(path, im)) {
+ error |= 1;
+ }
+ gdImageDestroy(im);
+ }
+
+ return error;
+}
diff --git a/Build/source/libs/gd/libgd-2.1.1/tests/png/bug00088_1.png b/Build/source/libs/gd/libgd-2.1.1/tests/png/bug00088_1.png
new file mode 100644
index 00000000000..3f9a5c7d408
--- /dev/null
+++ b/Build/source/libs/gd/libgd-2.1.1/tests/png/bug00088_1.png
Binary files differ
diff --git a/Build/source/libs/gd/libgd-2.1.1/tests/png/bug00088_1_exp.png b/Build/source/libs/gd/libgd-2.1.1/tests/png/bug00088_1_exp.png
new file mode 100644
index 00000000000..25ee05a93c9
--- /dev/null
+++ b/Build/source/libs/gd/libgd-2.1.1/tests/png/bug00088_1_exp.png
Binary files differ
diff --git a/Build/source/libs/gd/libgd-2.1.1/tests/png/bug00088_2.png b/Build/source/libs/gd/libgd-2.1.1/tests/png/bug00088_2.png
new file mode 100644
index 00000000000..fa58ffe61c9
--- /dev/null
+++ b/Build/source/libs/gd/libgd-2.1.1/tests/png/bug00088_2.png
Binary files differ
diff --git a/Build/source/libs/gd/libgd-2.1.1/tests/png/bug00088_2_exp.png b/Build/source/libs/gd/libgd-2.1.1/tests/png/bug00088_2_exp.png
new file mode 100644
index 00000000000..a21c8408679
--- /dev/null
+++ b/Build/source/libs/gd/libgd-2.1.1/tests/png/bug00088_2_exp.png
Binary files differ
diff --git a/Build/source/libs/gd/libgd-2.1.1/tests/png/bug00193.c b/Build/source/libs/gd/libgd-2.1.1/tests/png/bug00193.c
new file mode 100644
index 00000000000..67acf545f67
--- /dev/null
+++ b/Build/source/libs/gd/libgd-2.1.1/tests/png/bug00193.c
@@ -0,0 +1,43 @@
+#include <stdlib.h>
+#include "gd.h"
+#include "gdhelpers.h"
+#include "gdtest.h"
+
+static gdImagePtr im;
+
+#define TERMINATE(ctx, status) do { \
+ free(ctx); \
+ gdImageDestroy(im); \
+ exit(status); \
+ } while (0)
+
+static void
+failPutC(gdIOCtxPtr ctx, int c)
+{
+ (void)c;
+ TERMINATE(ctx, 1);
+}
+
+static int
+failPutBuf(gdIOCtxPtr ctx, const void * data, int size)
+{
+ (void)data;
+ (void)size;
+ TERMINATE(ctx, 1);
+ return -1;
+}
+
+int main()
+{
+ gdIOCtxPtr ctx;
+
+ gdSetErrorMethod(gdSilence);
+
+ im = gdImageCreate(100, 100);
+ ctx = (gdIOCtxPtr)malloc(sizeof(gdIOCtx));
+ ctx->putC = failPutC;
+ ctx->putBuf = failPutBuf;
+ gdImagePngCtx(im, ctx);
+ TERMINATE(ctx, 0);
+ return 0;
+}
diff --git a/Build/source/libs/gd/libgd-2.1.1/tests/png/emptyfile b/Build/source/libs/gd/libgd-2.1.1/tests/png/emptyfile
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/Build/source/libs/gd/libgd-2.1.1/tests/png/emptyfile
diff --git a/Build/source/libs/gd/libgd-2.1.1/tests/png/png_im2im.c b/Build/source/libs/gd/libgd-2.1.1/tests/png/png_im2im.c
new file mode 100644
index 00000000000..bac5e13aeb7
--- /dev/null
+++ b/Build/source/libs/gd/libgd-2.1.1/tests/png/png_im2im.c
@@ -0,0 +1,66 @@
+#include "gd.h"
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr src, dst;
+ int r, g, b;
+ void *p;
+ int size = 0;
+ int status = 0;
+ CuTestImageResult result = {0, 0};
+
+ src = gdImageCreate(100, 100);
+ if (src == NULL) {
+ printf("could not create src\n");
+ return 1;
+ }
+ r = gdImageColorAllocate(src, 0xFF, 0, 0);
+ g = gdImageColorAllocate(src, 0, 0xFF, 0);
+ b = gdImageColorAllocate(src, 0, 0, 0xFF);
+ gdImageFilledRectangle(src, 0, 0, 99, 99, r);
+ gdImageRectangle(src, 20, 20, 79, 79, g);
+ gdImageEllipse(src, 70, 25, 30, 20, b);
+
+#define OUTPUT_PNG(name) do { \
+ FILE *fp; \
+ \
+ fp = fopen("png_im2im_" #name ".png", "wb"); \
+ if (fp) { \
+ gdImagePng(name, fp); \
+ fclose(fp); \
+ } \
+ } while (0)
+
+ OUTPUT_PNG(src);
+ p = gdImagePngPtr(src, &size);
+ if (p == NULL) {
+ status = 1;
+ printf("p is null\n");
+ goto door0;
+ }
+ if (size <= 0) {
+ status = 1;
+ printf("size is non-positive\n");
+ goto door1;
+ }
+
+ dst = gdImageCreateFromPngPtr(size, p);
+ if (dst == NULL) {
+ status = 1;
+ printf("could not create dst\n");
+ goto door1;
+ }
+ OUTPUT_PNG(dst);
+ gdTestImageDiff(src, dst, NULL, &result);
+ if (result.pixels_changed > 0) {
+ status = 1;
+ printf("pixels changed: %d\n", result.pixels_changed);
+ }
+ gdImageDestroy(dst);
+door1:
+ gdFree(p);
+door0:
+ gdImageDestroy(src);
+ return status;
+}
diff --git a/Build/source/libs/gd/libgd-2.1.1/tests/png/png_null.c b/Build/source/libs/gd/libgd-2.1.1/tests/png/png_null.c
new file mode 100644
index 00000000000..d3b5e6a963b
--- /dev/null
+++ b/Build/source/libs/gd/libgd-2.1.1/tests/png/png_null.c
@@ -0,0 +1,17 @@
+#include "gd.h"
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr im;
+
+ gdSetErrorMethod(gdSilence);
+
+ im = gdImageCreateFromPng(NULL);
+ if (im != NULL) {
+ gdImageDestroy(im);
+ return 1;
+ }
+ gdImagePng(im, NULL); /* noop safely */
+ return 0;
+}
diff --git a/Build/source/libs/gd/libgd-2.1.1/tests/png/png_resolution.c b/Build/source/libs/gd/libgd-2.1.1/tests/png/png_resolution.c
new file mode 100644
index 00000000000..aed7545ba51
--- /dev/null
+++ b/Build/source/libs/gd/libgd-2.1.1/tests/png/png_resolution.c
@@ -0,0 +1,30 @@
+#include "gd.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr im;
+ void *data;
+ int size, red;
+
+ im = gdImageCreate(100, 100);
+ gdImageSetResolution(im, 72, 300);
+ red = gdImageColorAllocate(im, 0xFF, 0x00, 0x00);
+ gdImageFilledRectangle(im, 0, 0, 99, 99, red);
+ data = gdImagePngPtr(im, &size);
+ gdImageDestroy(im);
+
+ im = gdImageCreateFromPngPtr(size, data);
+ gdFree(data);
+
+ if (!gdTestAssert(gdImageResolutionX(im) == 72) || !gdTestAssert(gdImageResolutionY(im) == 300)) {
+ gdTestErrorMsg("failed image resolution X (%d != 72) or Y (%d != 300)\n", gdImageResolutionX(im), gdImageResolutionY(im));
+ gdImageDestroy(im);
+ return 1;
+ }
+
+ gdImageDestroy(im);
+ return 0;
+}