Partially implement #220: tests: replace all printf error messages with gdTestErrorMsg

master
Christoph M. Becker 2016-07-13 04:44:04 +02:00
parent 5a3f19e962
commit e210ff1149
20 changed files with 99 additions and 99 deletions

View File

@ -12,7 +12,7 @@ int main()
src = gdImageCreate(100, 100);
if (src == NULL) {
printf("could not create src\n");
gdTestErrorMsg("could not create src\n");
return 1;
}
r = gdImageColorAllocate(src, 0xFF, 0, 0);
@ -32,26 +32,26 @@ int main()
p = gdImageBmpPtr(src, &size, 1);
if (p == NULL) {
status = 1;
printf("p is null\n");
gdTestErrorMsg("p is null\n");
goto door0;
}
if (size <= 0) {
status = 1;
printf("size is non-positive\n");
gdTestErrorMsg("size is non-positive\n");
goto door1;
}
dst = gdImageCreateFromBmpPtr(size, p);
if (dst == NULL) {
status = 1;
printf("could not create dst\n");
gdTestErrorMsg("could not create dst\n");
goto door1;
}
OUTPUT_BMP(dst);
gdTestImageDiff(src, dst, NULL, &result);
if (result.pixels_changed > 0) {
status = 1;
printf("pixels changed: %d\n", result.pixels_changed);
gdTestErrorMsg("pixels changed: %d\n", result.pixels_changed);
}
gdImageDestroy(dst);
door1:

View File

@ -16,7 +16,7 @@ int main()
im = gdImageCreateTrueColor(50, 30);
if (!im) {
printf("can't get truecolor image\n");
gdTestErrorMsg("can't get truecolor image\n");
return 1;
}
@ -28,11 +28,11 @@ int main()
free(path);
if (ret) {
error = 1;
printf("%s\n", ret);
gdTestErrorMsg("%s\n", ret);
} else {
if (!gdAssertImageEqualsToFile("freetype/bug00132_exp.png", im)) {
error = 1;
printf("Reference image and destination differ\n");
gdTestErrorMsg("Reference image and destination differ\n");
}
}
gdImageDestroy(im);

View File

@ -12,7 +12,7 @@ int main()
src = gdImageCreate(100, 100);
if (src == NULL) {
printf("could not create src\n");
gdTestErrorMsg("could not create src\n");
return 1;
}
r = gdImageColorAllocate(src, 0xFF, 0, 0);
@ -32,26 +32,26 @@ int main()
p = gdImageGdPtr(src, &size);
if (p == NULL) {
status = 1;
printf("p is null\n");
gdTestErrorMsg("p is null\n");
goto door0;
}
if (size <= 0) {
status = 1;
printf("size is non-positive\n");
gdTestErrorMsg("size is non-positive\n");
goto door1;
}
dst = gdImageCreateFromGdPtr(size, p);
if (dst == NULL) {
status = 1;
printf("could not create dst\n");
gdTestErrorMsg("could not create dst\n");
goto door1;
}
OUTPUT_GD(dst);
gdTestImageDiff(src, dst, NULL, &result);
if (result.pixels_changed > 0) {
status = 1;
printf("pixels changed: %d\n", result.pixels_changed);
gdTestErrorMsg("pixels changed: %d\n", result.pixels_changed);
}
gdImageDestroy(dst);
door1:

View File

@ -12,7 +12,7 @@ int main()
src = gdImageCreate(100, 100);
if (src == NULL) {
printf("could not create src\n");
gdTestErrorMsg("could not create src\n");
return 1;
}
r = gdImageColorAllocate(src, 0xFF, 0, 0);
@ -32,26 +32,26 @@ int main()
p = gdImageGd2Ptr(src, (GD2_CHUNKSIZE_MIN+GD2_CHUNKSIZE_MAX)/2, GD2_FMT_COMPRESSED, &size);
if (p == NULL) {
status = 1;
printf("p is null\n");
gdTestErrorMsg("p is null\n");
goto door0;
}
if (size <= 0) {
status = 1;
printf("size is non-positive\n");
gdTestErrorMsg("size is non-positive\n");
goto door1;
}
dst = gdImageCreateFromGd2Ptr(size, p);
if (dst == NULL) {
status = 1;
printf("could not create dst\n");
gdTestErrorMsg("could not create dst\n");
goto door1;
}
OUTPUT_GD2(dst);
gdTestImageDiff(src, dst, NULL, &result);
if (result.pixels_changed > 0) {
status = 1;
printf("pixels changed: %d\n", result.pixels_changed);
gdTestErrorMsg("pixels changed: %d\n", result.pixels_changed);
}
gdImageDestroy(dst);
door1:

View File

@ -44,22 +44,22 @@ static void run_tests(gdImagePtr im, int *error)
COLOR(yellow, 0xFF, 0xFF, 0);
#undef COLOR
#define CHECK_VALUE(n, expected) do { \
if (gdTestAssert((n) == (expected)) != 1) { \
printf("%d is expected, but %d\n", expected, n); \
*error = -1; \
} \
#define CHECK_VALUE(n, expected) do { \
if (gdTestAssert((n) == (expected)) != 1) { \
gdTestErrorMsg("%d is expected, but %d\n", expected, n);\
*error = -1; \
} \
} while (0)
#define CHECK_PIXEL(x, y, expected) \
do { \
int pix; \
gdImageSetClip(im, 0, 0, 4, 4); \
pix = gdImageGetPixel(im, (x), (y)); \
if (gdTestAssert(pix == (expected)) != 1) { \
printf("%d is expected, but %d\n", expected, pix); \
*error = -1; \
} \
do { \
int pix; \
gdImageSetClip(im, 0, 0, 4, 4); \
pix = gdImageGetPixel(im, (x), (y)); \
if (gdTestAssert(pix == (expected)) != 1) { \
gdTestErrorMsg("%d is expected, but %d\n", expected, pix); \
*error = -1; \
} \
} while (0)
c = gdImageColorAllocate(im, 0xFF, 0, 0xFF);

View File

@ -12,7 +12,7 @@ int main()
im = gdImageCreateTrueColor(5, 5);
if (!im) {
printf("can't create the src truecolor image\n");
gdTestErrorMsg("can't create the src truecolor image\n");
return 1;
}
@ -22,7 +22,7 @@ int main()
im2 = gdImageCreateTrueColor(20, 20);
if (!im2) {
printf("can't create the dst truecolor image\n");
gdTestErrorMsg("can't create the dst truecolor image\n");
gdImageDestroy(im);
return 1;
}
@ -31,7 +31,7 @@ int main()
if (!gdAssertImageEqualsToFile("gdimagecopy/bug00081_exp.png", im2)) {
error = 1;
printf("Reference image and destination differ\n");
gdTestErrorMsg("Reference image and destination differ\n");
}
gdImageDestroy(im);

View File

@ -22,7 +22,7 @@ int main()
if (gdTestAssert(color==0x1000000)) {
return 0;
} else {
printf("c: %X, expected %X\n", color, 0x1000000);
gdTestErrorMsg("c: %X, expected %X\n", color, 0x1000000);
return -1;
}

View File

@ -12,7 +12,7 @@ int main()
im = gdImageCreateTrueColor(10, 10);
if (!im) {
printf("can't get truecolor image\n");
gdTestErrorMsg("can't get truecolor image\n");
return 1;
}
@ -23,7 +23,7 @@ int main()
if (!gdAssertImageEqualsToFile("gdimageline/bug00111_exp.png", im)) {
error = 1;
printf("Reference image and destination differ\n");
gdTestErrorMsg("Reference image and destination differ\n");
}
gdImageDestroy(im);

View File

@ -27,28 +27,28 @@ static const int expected_average[][3] = {
} \
} while (0)
#define CHECK_PIXELS(im, expected) do { \
int x, y; \
for (y = 0; y < (im)->sy; y++) { \
for (x = 0; x < (im)->sx; x++) { \
int p = gdImageGetPixel(im, x, y); \
int r = ((expected)[y/BLOCK_SIZE][x/BLOCK_SIZE]>>16)&0xFF; \
int g = ((expected)[y/BLOCK_SIZE][x/BLOCK_SIZE]>> 8)&0xFF; \
int b = ((expected)[y/BLOCK_SIZE][x/BLOCK_SIZE] )&0xFF; \
if (r != gdImageRed(im, p)) { \
printf("Red %x is expected, but %x\n", r, gdImageRed(im, p)); \
return 0; \
} \
if (g != gdImageGreen(im, p)) { \
printf("Green %x is expected, but %x\n", g, gdImageGreen(im, p)); \
return 0; \
} \
if (b != gdImageBlue(im, p)) { \
printf("Blue %x is expected, but %x\n", b, gdImageBlue(im, p)); \
return 0; \
} \
} \
} \
#define CHECK_PIXELS(im, expected) do { \
int x, y; \
for (y = 0; y < (im)->sy; y++) { \
for (x = 0; x < (im)->sx; x++) { \
int p = gdImageGetPixel(im, x, y); \
int r = ((expected)[y/BLOCK_SIZE][x/BLOCK_SIZE]>>16)&0xFF; \
int g = ((expected)[y/BLOCK_SIZE][x/BLOCK_SIZE]>> 8)&0xFF; \
int b = ((expected)[y/BLOCK_SIZE][x/BLOCK_SIZE] )&0xFF; \
if (r != gdImageRed(im, p)) { \
gdTestErrorMsg("Red %x is expected, but %x\n", r, gdImageRed(im, p)); \
return 0; \
} \
if (g != gdImageGreen(im, p)) { \
gdTestErrorMsg("Green %x is expected, but %x\n", g, gdImageGreen(im, p)); \
return 0; \
} \
if (b != gdImageBlue(im, p)) { \
gdTestErrorMsg("Blue %x is expected, but %x\n", b, gdImageBlue(im, p)); \
return 0; \
} \
} \
} \
} while (0)
static int testPixelate(gdImagePtr im)

View File

@ -33,7 +33,7 @@ int main()
}
if (!gdAssertImageEqualsToFile("gdimagerotate/php_bug_64898_exp.png", exp)) {
printf("comparing rotated image failed.\n");
gdTestErrorMsg("comparing rotated image failed.\n");
error = 1;
}

View File

@ -9,7 +9,7 @@ int main()
im = gdImageCreate(5,5);
dest = gdImageScale(im, 0, 1);
if (dest != NULL) {
printf("expecting NULL result\n");
gdTestErrorMsg("expecting NULL result\n");
status = 1;
} else {
status = 0;

View File

@ -12,7 +12,7 @@ int main()
im = gdImageCreateFromPng(fp);
fclose(fp);
if (!im) {
fprintf(stderr, "could not create image\n");
gdTestErrorMsg("could not create image\n");
return 1;
}
@ -22,7 +22,7 @@ int main()
s.num_colors = 0;
if (!gdImageScatterEx(im, &s)) {
gdImageDestroy(im);
fprintf(stderr, "could not scatter\n");
gdTestErrorMsg("could not scatter\n");
return 1;
}
@ -30,7 +30,7 @@ int main()
ex = gdImageCreateFromPng(fp);
fclose(fp);
if (!ex) {
fprintf(stderr, "could not create image\n");
gdTestErrorMsg("could not create image\n");
gdImageDestroy(im);
return 1;
}
@ -39,7 +39,7 @@ int main()
gdImageDestroy(ex);
gdImageDestroy(im);
if (r.pixels_changed > 10000) {
fprintf(stderr, "too much diff: %d\n", r.pixels_changed);
gdTestErrorMsg("too much diff: %d\n", r.pixels_changed);
return 1;
}
return 0;

View File

@ -13,7 +13,7 @@ int main()
im = gdImageCreateFromPng(fp);
fclose(fp);
if (!im) {
fprintf(stderr, "could not create image\n");
gdTestErrorMsg("could not create image\n");
return 1;
}
@ -24,7 +24,7 @@ int main()
s.colors = colors;
if (!gdImageScatterEx(im, &s)) {
gdImageDestroy(im);
fprintf(stderr, "could not scatter\n");
gdTestErrorMsg("could not scatter\n");
return 1;
}
@ -32,7 +32,7 @@ int main()
ex = gdImageCreateFromPng(fp);
fclose(fp);
if (!ex) {
fprintf(stderr, "could not create image\n");
gdTestErrorMsg("could not create image\n");
gdImageDestroy(im);
return 1;
}
@ -41,7 +41,7 @@ int main()
gdImageDestroy(ex);
gdImageDestroy(im);
if (r.pixels_changed > 10000) {
fprintf(stderr, "too much diff: %d\n", r.pixels_changed);
gdTestErrorMsg("too much diff: %d\n", r.pixels_changed);
return 1;
}
return 0;

View File

@ -12,7 +12,7 @@ int main()
src = gdImageCreate(100, 100);
if (src == NULL) {
printf("could not create src\n");
gdTestErrorMsg("could not create src\n");
return 1;
}
r = gdImageColorAllocate(src, 0xFF, 0, 0);
@ -32,26 +32,26 @@ int main()
p = gdImageGifPtr(src, &size);
if (p == NULL) {
status = 1;
printf("p is null\n");
gdTestErrorMsg("p is null\n");
goto door0;
}
if (size <= 0) {
status = 1;
printf("size is non-positive\n");
gdTestErrorMsg("size is non-positive\n");
goto door1;
}
dst = gdImageCreateFromGifPtr(size, p);
if (dst == NULL) {
status = 1;
printf("could not create dst\n");
gdTestErrorMsg("could not create dst\n");
goto door1;
}
OUTPUT_GIF(dst);
gdTestImageDiff(src, dst, NULL, &result);
if (result.pixels_changed > 0) {
status = 1;
printf("pixels changed: %d\n", result.pixels_changed);
gdTestErrorMsg("pixels changed: %d\n", result.pixels_changed);
}
gdImageDestroy(dst);
door1:

View File

@ -14,7 +14,7 @@ int main()
src = gdImageCreateTrueColor(100, 100);
if (src == NULL) {
printf("could not create src\n");
gdTestErrorMsg("could not create src\n");
return 1;
}
r = gdImageColorAllocate(src, 0xFF, 0, 0);
@ -34,19 +34,19 @@ int main()
p = gdImageJpegPtr(src, &size, 100);
if (p == NULL) {
status = 1;
printf("p is null\n");
gdTestErrorMsg("p is null\n");
goto door0;
}
if (size <= 0) {
status = 1;
printf("size is non-positive\n");
gdTestErrorMsg("size is non-positive\n");
goto door1;
}
dst = gdImageCreateFromJpegPtr(size, p);
if (dst == NULL) {
status = 1;
printf("could not create dst\n");
gdTestErrorMsg("could not create dst\n");
goto door1;
}
OUTPUT_JPEG(dst);

View File

@ -17,7 +17,7 @@ int main(void)
if ( ( im = gdImageCreateFromPngPtr(93, (char*) &pngdata[0]) ) == NULL) {
return 0;
} else {
fprintf(stderr, "failed!\n");
gdTestErrorMsg("failed!\n");
gdImageDestroy(im);
return 1;
}

View File

@ -12,7 +12,7 @@ int main()
src = gdImageCreate(100, 100);
if (src == NULL) {
printf("could not create src\n");
gdTestErrorMsg("could not create src\n");
return 1;
}
r = gdImageColorAllocate(src, 0xFF, 0, 0);
@ -32,26 +32,26 @@ int main()
p = gdImagePngPtr(src, &size);
if (p == NULL) {
status = 1;
printf("p is null\n");
gdTestErrorMsg("p is null\n");
goto door0;
}
if (size <= 0) {
status = 1;
printf("size is non-positive\n");
gdTestErrorMsg("size is non-positive\n");
goto door1;
}
dst = gdImageCreateFromPngPtr(size, p);
if (dst == NULL) {
status = 1;
printf("could not create dst\n");
gdTestErrorMsg("could not create dst\n");
goto door1;
}
OUTPUT_PNG(dst);
gdTestImageDiff(src, dst, NULL, &result);
if (result.pixels_changed > 0) {
status = 1;
printf("pixels changed: %d\n", result.pixels_changed);
gdTestErrorMsg("pixels changed: %d\n", result.pixels_changed);
}
gdImageDestroy(dst);
door1:

View File

@ -16,7 +16,7 @@ int main()
src = gdImageCreate(100, 100);
if (src == NULL) {
printf("could not create src\n");
gdTestErrorMsg("could not create src\n");
return 1;
}
r = gdImageColorAllocate(src, 0xFF, 0, 0);
@ -40,30 +40,30 @@ int main()
p = gdImageTiffPtr(src, &size);
if (p == NULL) {
status = 1;
printf("p is null\n");
gdTestErrorMsg("p is null\n");
goto door0;
}
if (size <= 0) {
status = 1;
printf("size is non-positive\n");
gdTestErrorMsg("size is non-positive\n");
goto door1;
}
dst = gdImageCreateFromTiffPtr(size, p);
if (dst == NULL) {
status = 1;
printf("could not create dst\n");
gdTestErrorMsg("could not create dst\n");
goto door1;
}
if (dst->res_x != res_x) {
status = 1;
printf("mismatch in res_x (got %d, expected %d)", dst->res_x, res_x);
gdTestErrorMsg("mismatch in res_x (got %d, expected %d)", dst->res_x, res_x);
}
if (dst->res_y != res_y) {
status = 1;
printf("mismatch in res_y (got %d, expected %d)", dst->res_y, res_y);
gdTestErrorMsg("mismatch in res_y (got %d, expected %d)", dst->res_y, res_y);
}
gdImageDestroy(dst);

View File

@ -14,7 +14,7 @@ int main()
src = gdImageCreate(100, 100);
if (src == NULL) {
printf("could not create src\n");
gdTestErrorMsg("could not create src\n");
return 1;
}
r = gdImageColorAllocate(src, 0xFF, 0, 0);
@ -34,19 +34,19 @@ int main()
p = gdImageTiffPtr(src, &size);
if (p == NULL) {
status = 1;
printf("p is null\n");
gdTestErrorMsg("p is null\n");
goto door0;
}
if (size <= 0) {
status = 1;
printf("size is non-positive\n");
gdTestErrorMsg("size is non-positive\n");
goto door1;
}
dst = gdImageCreateFromTiffPtr(size, p);
if (dst == NULL) {
status = 1;
printf("could not create dst\n");
gdTestErrorMsg("could not create dst\n");
goto door1;
}
OUTPUT_TIFF(dst);

View File

@ -12,7 +12,7 @@ int main()
src = gdImageCreate(100, 100);
if (src == NULL) {
printf("could not create src\n");
gdTestErrorMsg("could not create src\n");
return 1;
}
gdImageColorAllocate(src, 0xFF, 0xFF, 0xFF); /* allocate white for background color */
@ -30,26 +30,26 @@ int main()
p = gdImageWBMPPtr(src, &size, 1);
if (p == NULL) {
status = 1;
printf("p is null\n");
gdTestErrorMsg("p is null\n");
goto door0;
}
if (size <= 0) {
status = 1;
printf("size is non-positive\n");
gdTestErrorMsg("size is non-positive\n");
goto door1;
}
dst = gdImageCreateFromWBMPPtr(size, p);
if (dst == NULL) {
status = 1;
printf("could not create dst\n");
gdTestErrorMsg("could not create dst\n");
goto door1;
}
OUTPUT_WBMP(dst);
gdTestImageDiff(src, dst, NULL, &result);
if (result.pixels_changed > 0) {
status = 1;
printf("pixels changed: %d\n", result.pixels_changed);
gdTestErrorMsg("pixels changed: %d\n", result.pixels_changed);
}
gdImageDestroy(dst);
door1: