|
Packit |
ed3af9 |
#ifndef GD_TEST_H
|
|
Packit |
ed3af9 |
#define GD_TEST_H
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
#include <stdarg.h>
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
#define GDTEST_STRING_MAX 1024
|
|
Packit |
ed3af9 |
typedef struct CuTestImageResult CuTestImageResult;
|
|
Packit |
ed3af9 |
struct CuTestImageResult {
|
|
Packit |
ed3af9 |
unsigned int pixels_changed;
|
|
Packit |
ed3af9 |
unsigned int max_diff;
|
|
Packit |
ed3af9 |
};
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
/* Internal versions of assert functions -- use the public versions */
|
|
Packit |
ed3af9 |
gdImagePtr gdTestImageFromPng(const char *filename);
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
/* Return a path to a writable temp dir. The common test code will make sure
|
|
Packit |
ed3af9 |
* it's cleaned up when the test exits. Feel free to write whatever in here.
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
const char *gdTestTempDir(void);
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
/* Return a path to a writable file inside of the tempdir (see above).
|
|
Packit |
ed3af9 |
* You should free the pointer when you're done.
|
|
Packit |
ed3af9 |
* If |template| is NULL, you'll get a random file name, otherwise you'll get
|
|
Packit |
ed3af9 |
* that under the tempdir.
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
char *gdTestTempFile(const char *template);
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
/* Return an open (writable) file handle to a temp file. */
|
|
Packit |
ed3af9 |
FILE *gdTestTempFp(void);
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
/* Return the full path to a test file. The path should be relative
|
|
Packit |
ed3af9 |
* to the tests/ dir. The caller should free the pointer when finished.
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
char *gdTestFilePathV(const char *path, va_list args);
|
|
Packit |
ed3af9 |
char *gdTestFilePathX(const char *path, ...);
|
|
Packit |
ed3af9 |
#define gdTestFilePath(p) gdTestFilePathX(p, NULL)
|
|
Packit |
ed3af9 |
#define gdTestFilePath2(p1, p2) gdTestFilePathX(p1, p2, NULL)
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
/* Return an open (read-only) file handle to a test file.
|
|
Packit |
ed3af9 |
* The path should be relative to the tests/ dir.
|
|
Packit |
ed3af9 |
*/
|
|
Packit |
ed3af9 |
FILE *gdTestFileOpenX(const char *path, ...);
|
|
Packit |
ed3af9 |
#define gdTestFileOpen(p) gdTestFileOpenX(p, NULL)
|
|
Packit |
ed3af9 |
#define gdTestFileOpen2(p1, p2) gdTestFileOpenX(p1, p2, NULL)
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
void gdTestImageDiff(gdImagePtr buf_a, gdImagePtr buf_b,
|
|
Packit |
ed3af9 |
gdImagePtr buf_diff, CuTestImageResult *result_ret);
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
int gdTestImageCompareToImage(const char* file, unsigned int line, const char* message,
|
|
Packit |
ed3af9 |
gdImagePtr expected, gdImagePtr actual);
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
int gdTestImageCompareToFile(const char* file, unsigned int line, const char* message,
|
|
Packit |
ed3af9 |
const char *expected_file, gdImagePtr actual);
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
unsigned int gdMaxPixelDiff(gdImagePtr a, gdImagePtr b);
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
int _gdTestAssert(const char* file, unsigned int line, int condition);
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
int _gdTestAssertMsg(const char* file, unsigned int line, int condition, const char* message, ...);
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
int _gdTestErrorMsg(const char* file, unsigned int line, const char* string, ...);
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
/* public assert functions */
|
|
Packit |
ed3af9 |
#define gdAssertImageEqualsToFile(ex,ac) gdTestImageCompareToFile(__FILE__,__LINE__,NULL,(ex),(ac))
|
|
Packit |
ed3af9 |
#define gdAssertImageFileEqualsMsg(ex,ac,ms) gdTestImageCompareFiles(__FILE__,__LINE__,(ms),(ex),(ac))
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
#define gdAssertImageEquals(ex,ac) gdTestImageCompareToImage(__FILE__,__LINE__,NULL,(ex),(ac))
|
|
Packit |
ed3af9 |
#define gdAssertImageEqualsMsg(ex,ac,ms) gdTestImageCompareToImage(__FILE__,__LINE__,(ms),(ex),(ac))
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
#define gdTestAssert(cond) _gdTestAssert(__FILE__, __LINE__, (cond))
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
#define gdTestAssertMsg(cond, message, ...) _gdTestAssertMsg(__FILE__, __LINE__, (cond), (message), ## __VA_ARGS__)
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
#define gdTestErrorMsg(...) _gdTestErrorMsg(__FILE__, __LINE__, __VA_ARGS__)
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
void gdSilence(int priority, const char *format, va_list args);
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
int gdNumFailures(void);
|
|
Packit |
ed3af9 |
|
|
Packit |
ed3af9 |
#endif /* GD_TEST_H */
|