summaryrefslogtreecommitdiff
path: root/Build/source/libs/gd/libgd-src/tests/gdtest/gdtest.c
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/gd/libgd-src/tests/gdtest/gdtest.c')
-rw-r--r--Build/source/libs/gd/libgd-src/tests/gdtest/gdtest.c39
1 files changed, 22 insertions, 17 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);