1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
#include "gd.h"
#include <stdio.h>
#include <stdlib.h>
#include "gdtest.h"
int main(int argc, char *argv[])
{
int error = 0, i = 0;
gdImagePtr im, exp;
FILE *fp;
char *path[] = {
"conv_test.gd2",
"invalid_neg_size.gd2",
"invalid_header.gd2",
NULL
};
char *path_exp[] = {
"conv_test_exp.png",
NULL,
NULL,
NULL
};
while (path[i] != NULL) {
fp = gdTestFileOpen2("gd2", path[i]);
if (!fp) {
gdTestErrorMsg("failed, cannot open file: %s\n", path[0]);
return 1;
}
im = gdImageCreateFromGd2(fp);
fclose(fp);
if (path_exp[i] != NULL) {
fp = gdTestFileOpen2("gd2", path_exp[i]);
if (!fp) {
gdTestErrorMsg("failed, cannot open file: %s\n", path_exp[i]);
return 1;
}
exp = gdImageCreateFromPng(fp);
if (!gdAssertImageEquals(exp, im)) {
gdTestErrorMsg("image %s differs from expected result\n", path[i]);
gdImageDestroy(im);
error = 1;
} else {
error = 0;
}
if (exp) {
gdImageDestroy(exp);
}
} else {
/* expected to fail */
if (im) {
gdTestErrorMsg("image %s should have failed to be loaded\n", path[i]);
gdImageDestroy(im);
error = 1;
} else {
error = 0;
}
}
i++;
}
return error;
}
|