diff options
Diffstat (limited to 'Build/source/libs/gd/libgd-src/tests/gdtest')
-rw-r--r-- | Build/source/libs/gd/libgd-src/tests/gdtest/gdtest.c | 39 | ||||
-rw-r--r-- | Build/source/libs/gd/libgd-src/tests/gdtest/gdtest.h | 3 |
2 files changed, 22 insertions, 20 deletions
diff --git a/Build/source/libs/gd/libgd-src/tests/gdtest/gdtest.c b/Build/source/libs/gd/libgd-src/tests/gdtest/gdtest.c index 7e9ee362985..832f27ae303 100644 --- a/Build/source/libs/gd/libgd-src/tests/gdtest/gdtest.c +++ b/Build/source/libs/gd/libgd-src/tests/gdtest/gdtest.c @@ -1,4 +1,6 @@ +#ifdef HAVE_CONFIG_H #include <config.h> +#endif #include <assert.h> #include <setjmp.h> #include <stdlib.h> @@ -21,7 +23,14 @@ #endif #ifdef _WIN32 -# include "readdir.h" +#include "readdir.h" +#include <errno.h> +#endif + +/* GDTEST_TOP_DIR is defined in other compile ways except msys + * test_config.h is created by windows/msys/run_test.sh*/ +#ifndef GDTEST_TOP_DIR +#include <test_config.h> #endif #include "gd.h" @@ -40,7 +49,6 @@ void gdSilence(int priority, const char *format, va_list args) (void)args; } -#ifdef HAVE_LIBPNG gdImagePtr gdTestImageFromPng(const char *filename) { gdImagePtr image; @@ -58,14 +66,13 @@ gdImagePtr gdTestImageFromPng(const char *filename) } if (fp == NULL) { - return NULL; + return NULL; } image = gdImageCreateFromPng(fp); fclose(fp); return image; } -#endif static char *tmpdir_base; @@ -188,11 +195,11 @@ static int getfilesystemtime(struct timeval *tv) fft.LowPart = ft.dwLowDateTime; ff = fft.QuadPart; - ff /= 10Ui64; /* convert to microseconds */ - ff -= 11644473600000000Ui64; /* convert to unix epoch */ + ff /= 10ULL; /* convert to microseconds */ + ff -= 11644473600000000ULL; /* convert to unix epoch */ - tv->tv_sec = (long)(ff / 1000000Ui64); - tv->tv_usec = (long)(ff % 1000000Ui64); + tv->tv_sec = (long)(ff / 1000000ULL); + tv->tv_usec = (long)(ff % 1000000ULL); return 0; } @@ -205,7 +212,7 @@ mkdtemp (char *tmpl) static int counter = 0; char *XXXXXX; struct timeval tv; - _int64 value; + __int64 value; int count; /* find the last occurrence of "XXXXXX" */ @@ -221,7 +228,7 @@ mkdtemp (char *tmpl) value = (tv.tv_usec ^ tv.tv_sec) + counter++; for (count = 0; count < 100; value += 7777, ++count) { - _int64 v = value; + __int64 v = value; /* Fill in the random bits. */ XXXXXX[0] = letters[v % NLETTERS]; @@ -306,7 +313,7 @@ char *gdTestTempFile(const char *template) ret); gdTestAssert(error != 0); } else { - sprintf(ret, "%s\\%s", tempdir, template); + sprintf(ret, "%s\\%s", tempdir, template); } } #else @@ -363,6 +370,7 @@ char *gdTestFilePathV(const char *path, va_list args) strcat(file, "/"); #endif strcat(file, p); + } while ((p = va_arg(args, const char *)) != NULL); va_end(args); @@ -502,7 +510,6 @@ unsigned int gdMaxPixelDiff(gdImagePtr a, gdImagePtr b) return diff; } -#ifdef HAVE_LIBPNG int gdTestImageCompareToImage(const char* file, unsigned int line, const char* message, gdImagePtr expected, gdImagePtr actual) { @@ -562,6 +569,7 @@ int gdTestImageCompareToImage(const char* file, unsigned int line, const char* m if (!fp) goto fail; gdImagePng(surface_diff,fp); fclose(fp); + gdImageDestroy(surface_diff); fp = fopen(file_out, "wb"); if (!fp) goto fail; @@ -581,9 +589,7 @@ fail: } return 1; } -#endif -#ifdef HAVE_LIBPNG int gdTestImageCompareToFile(const char* file, unsigned int line, const char* message, const char *expected_file, gdImagePtr actual) { @@ -601,7 +607,6 @@ int gdTestImageCompareToFile(const char* file, unsigned int line, const char* me } return res; } -#endif static int failureCount = 0; @@ -622,9 +627,9 @@ int _gdTestAssert(const char* file, unsigned int line, int condition) int _gdTestAssertMsg(const char* file, unsigned int line, int condition, const char* message, ...) { va_list args; - + if (condition) return 1; - + fprintf(stderr, "%s:%u: ", file, line); va_start(args, message); vfprintf(stderr, message, args); diff --git a/Build/source/libs/gd/libgd-src/tests/gdtest/gdtest.h b/Build/source/libs/gd/libgd-src/tests/gdtest/gdtest.h index 82d2feba305..16d89aa48cb 100644 --- a/Build/source/libs/gd/libgd-src/tests/gdtest/gdtest.h +++ b/Build/source/libs/gd/libgd-src/tests/gdtest/gdtest.h @@ -3,7 +3,6 @@ #include <stdarg.h> -#define GDTEST_STRING_MAX 1024 typedef struct CuTestImageResult CuTestImageResult; struct CuTestImageResult { unsigned int pixels_changed; @@ -64,10 +63,8 @@ int _gdTestErrorMsg(const char* file, unsigned int line, const char* string, ... /* public assert functions */ #define gdAssertImageEqualsToFile(ex,ac) gdTestImageCompareToFile(__FILE__,__LINE__,NULL,(ex),(ac)) -#define gdAssertImageFileEqualsMsg(ex,ac,ms) gdTestImageCompareFiles(__FILE__,__LINE__,(ms),(ex),(ac)) #define gdAssertImageEquals(ex,ac) gdTestImageCompareToImage(__FILE__,__LINE__,NULL,(ex),(ac)) -#define gdAssertImageEqualsMsg(ex,ac,ms) gdTestImageCompareToImage(__FILE__,__LINE__,(ms),(ex),(ac)) #define gdTestAssert(cond) _gdTestAssert(__FILE__, __LINE__, (cond)) |