summaryrefslogtreecommitdiff
path: root/Build/source/libs/gd/libgd-2.1.0/tests/tiff
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/gd/libgd-2.1.0/tests/tiff')
-rw-r--r--Build/source/libs/gd/libgd-2.1.0/tests/tiff/CMakeLists.txt12
-rw-r--r--Build/source/libs/gd/libgd-2.1.0/tests/tiff/tiff_im2im.c70
-rw-r--r--Build/source/libs/gd/libgd-2.1.0/tests/tiff/tiff_null.c14
3 files changed, 96 insertions, 0 deletions
diff --git a/Build/source/libs/gd/libgd-2.1.0/tests/tiff/CMakeLists.txt b/Build/source/libs/gd/libgd-2.1.0/tests/tiff/CMakeLists.txt
new file mode 100644
index 00000000000..aefdaf7e032
--- /dev/null
+++ b/Build/source/libs/gd/libgd-2.1.0/tests/tiff/CMakeLists.txt
@@ -0,0 +1,12 @@
+
+SET(TESTS_FILES
+ tiff_im2im
+ tiff_null
+)
+
+FOREACH(test_name ${TESTS_FILES})
+ add_executable(${test_name} "${test_name}.c")
+ target_link_libraries (${test_name} gdTest)
+ get_target_property(test_path ${test_name} LOCATION)
+ ADD_TEST(${test_name} ${test_path})
+ENDFOREACH(test_name)
diff --git a/Build/source/libs/gd/libgd-2.1.0/tests/tiff/tiff_im2im.c b/Build/source/libs/gd/libgd-2.1.0/tests/tiff/tiff_im2im.c
new file mode 100644
index 00000000000..4b6136d4b92
--- /dev/null
+++ b/Build/source/libs/gd/libgd-2.1.0/tests/tiff/tiff_im2im.c
@@ -0,0 +1,70 @@
+#include "gd.h"
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr src, dst;
+ int r, g, b;
+ void *p;
+ int size = 0;
+ int status = 0;
+#if 0
+ CuTestImageResult result = {0, 0};
+#endif
+
+ 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_TIFF(name) do { \
+ FILE *fp; \
+ \
+ fp = fopen("tiff_im2im_" #name ".tiff", "wb"); \
+ if (fp) { \
+ gdImageTiff(name, fp); \
+ fclose(fp); \
+ } \
+ } while (0)
+
+ OUTPUT_TIFF(src);
+ p = gdImageTiffPtr(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 = gdImageCreateFromTiffPtr(size, p);
+ if (dst == NULL) {
+ status = 1;
+ printf("could not create dst\n");
+ goto door1;
+ }
+ OUTPUT_TIFF(dst);
+#if 0
+ gdTestImageDiff(src, dst, NULL, &result);
+ if (result.pixels_changed > 0) {
+ status = 1;
+ printf("pixels changed: %d\n", result.pixels_changed);
+ }
+#endif
+ gdImageDestroy(dst);
+door1:
+ gdFree(p);
+door0:
+ gdImageDestroy(src);
+ return status;
+}
diff --git a/Build/source/libs/gd/libgd-2.1.0/tests/tiff/tiff_null.c b/Build/source/libs/gd/libgd-2.1.0/tests/tiff/tiff_null.c
new file mode 100644
index 00000000000..ccaade7498f
--- /dev/null
+++ b/Build/source/libs/gd/libgd-2.1.0/tests/tiff/tiff_null.c
@@ -0,0 +1,14 @@
+#include "gd.h"
+
+int main()
+{
+ gdImagePtr im;
+
+ im = gdImageCreateFromTiff(NULL);
+ if (im != NULL) {
+ gdImageDestroy(im);
+ return 1;
+ }
+ gdImageTiff(im, NULL); /* noop safely */
+ return 0;
+}