gdtest.c (libgd-2.2.4) | : | gdtest.c (libgd-2.2.5) | ||
---|---|---|---|---|
skipping to change at line 43 | skipping to change at line 43 | |||
static inline int max(int a, int b) {return a > b ? a : b;} | static inline int max(int a, int b) {return a > b ? a : b;} | |||
#endif | #endif | |||
void gdSilence(int priority, const char *format, va_list args) | void gdSilence(int priority, const char *format, va_list args) | |||
{ | { | |||
(void)priority; | (void)priority; | |||
(void)format; | (void)format; | |||
(void)args; | (void)args; | |||
} | } | |||
#ifdef HAVE_LIBPNG | ||||
gdImagePtr gdTestImageFromPng(const char *filename) | gdImagePtr gdTestImageFromPng(const char *filename) | |||
{ | { | |||
gdImagePtr image; | gdImagePtr image; | |||
FILE *fp; | FILE *fp; | |||
/* If the path is relative, then assume it's in the tests/ dir. */ | /* If the path is relative, then assume it's in the tests/ dir. */ | |||
if (filename[0] == '/' || filename[0] == '.' | if (filename[0] == '/' || filename[0] == '.' | |||
#ifdef _WIN32 | #ifdef _WIN32 | |||
|| filename[1] == ':' | || filename[1] == ':' | |||
#endif | #endif | |||
skipping to change at line 67 | skipping to change at line 68 | |||
} | } | |||
if (fp == NULL) { | if (fp == NULL) { | |||
return NULL; | return NULL; | |||
} | } | |||
image = gdImageCreateFromPng(fp); | image = gdImageCreateFromPng(fp); | |||
fclose(fp); | fclose(fp); | |||
return image; | return image; | |||
} | } | |||
#endif | ||||
static char *tmpdir_base; | static char *tmpdir_base; | |||
/* This is kind of hacky, but it's meant to be simple. */ | /* This is kind of hacky, but it's meant to be simple. */ | |||
static void _clean_dir(const char *dir) | static void _clean_dir(const char *dir) | |||
{ | { | |||
DIR *d; | DIR *d; | |||
struct dirent *de; | struct dirent *de; | |||
d = opendir(dir); | d = opendir(dir); | |||
skipping to change at line 501 | skipping to change at line 503 | |||
diff = max(diff, abs(gdTrueColorGetAlpha(c1) - gdTrueColorGetAlpha(c 2))); | diff = max(diff, abs(gdTrueColorGetAlpha(c1) - gdTrueColorGetAlpha(c 2))); | |||
diff = max(diff, abs(gdTrueColorGetRed(c1) - gdTrueColorGetRed(c2) )); | diff = max(diff, abs(gdTrueColorGetRed(c1) - gdTrueColorGetRed(c2) )); | |||
diff = max(diff, abs(gdTrueColorGetGreen(c1) - gdTrueColorGetGreen(c 2))); | diff = max(diff, abs(gdTrueColorGetGreen(c1) - gdTrueColorGetGreen(c 2))); | |||
diff = max(diff, abs(gdTrueColorGetBlue(c1) - gdTrueColorGetBlue(c2 ))); | diff = max(diff, abs(gdTrueColorGetBlue(c1) - gdTrueColorGetBlue(c2 ))); | |||
}/* for */ | }/* for */ | |||
}/* for */ | }/* for */ | |||
return diff; | return diff; | |||
} | } | |||
#ifdef HAVE_LIBPNG | ||||
int gdTestImageCompareToImage(const char* file, unsigned int line, const char* m essage, | int gdTestImageCompareToImage(const char* file, unsigned int line, const char* m essage, | |||
gdImagePtr expected, gdImagePtr actual) | gdImagePtr expected, gdImagePtr actual) | |||
{ | { | |||
unsigned int width_a, height_a; | unsigned int width_a, height_a; | |||
unsigned int width_b, height_b; | unsigned int width_b, height_b; | |||
gdImagePtr surface_diff = NULL; | gdImagePtr surface_diff = NULL; | |||
CuTestImageResult result = {0, 0}; | CuTestImageResult result = {0, 0}; | |||
(void)message; | (void)message; | |||
skipping to change at line 577 | skipping to change at line 580 | |||
if (surface_diff) { | if (surface_diff) { | |||
gdImageDestroy(surface_diff); | gdImageDestroy(surface_diff); | |||
} | } | |||
return 1; | return 1; | |||
} | } | |||
fail: | fail: | |||
if (surface_diff) { | if (surface_diff) { | |||
gdImageDestroy(surface_diff); | gdImageDestroy(surface_diff); | |||
} | } | |||
return 0; | return 1; | |||
} | } | |||
#endif | ||||
#ifdef HAVE_LIBPNG | ||||
int gdTestImageCompareToFile(const char* file, unsigned int line, const char* me ssage, | int gdTestImageCompareToFile(const char* file, unsigned int line, const char* me ssage, | |||
const char *expected_file, gdImagePtr actual) | const char *expected_file, gdImagePtr actual) | |||
{ | { | |||
gdImagePtr expected; | gdImagePtr expected = 0; | |||
int res = 1; | int res = 1; | |||
expected = gdTestImageFromPng(expected_file); | expected = gdTestImageFromPng(expected_file); | |||
if (!expected) { | if (!expected) { | |||
_gdTestErrorMsg(file, line, "Cannot open PNG <%s>\n", expected_fi le); | _gdTestErrorMsg(file, line, "Cannot open PNG <%s>\n", expected_fi le); | |||
res = 0; | res = 0; | |||
} else { | } else { | |||
res = gdTestImageCompareToImage(file, line, message, expected, ac tual); | res = gdTestImageCompareToImage(file, line, message, expected, ac tual); | |||
gdImageDestroy(expected); | gdImageDestroy(expected); | |||
} | } | |||
return res; | return res; | |||
} | } | |||
#endif | ||||
static int failureCount = 0; | static int failureCount = 0; | |||
int gdNumFailures() { | int gdNumFailures() { | |||
return failureCount; | return failureCount; | |||
} | } | |||
int _gdTestAssert(const char* file, unsigned int line, int condition) | int _gdTestAssert(const char* file, unsigned int line, int condition) | |||
{ | { | |||
if (condition) return 1; | if (condition) return 1; | |||
End of changes. 8 change blocks. | ||||
2 lines changed or deleted | 8 lines changed or added |