Make tests less chatty; silence them using our shiny new gdSetErrorMethod

master
Ondřej Surý 2013-04-22 17:16:44 +02:00
parent f3375cbc33
commit 83f5b748c3
15 changed files with 41 additions and 23 deletions

View File

@ -134,6 +134,8 @@ int main()
gdImagePtr im;
int error = 0;
gdSetErrorMethod(gdSilence);
/* true color */
im = gdImageCreateTrueColor(5, 5);
run_tests(im, &error);

View File

@ -9,14 +9,14 @@ int main()
FILE *fp;
char path[1024];
fputs("flag 0\n", stdout);
/* fputs("flag 0\n", stdout); */
im = gdImageCreateTrueColor(100, 100);
fputs("flag 1\n", stdout);
/* fputs("flag 1\n", stdout); */
gdImageFill(im, 0, 0, 0xffffff);
fputs("flag 2\n", stdout);
/* fputs("flag 2\n", stdout); */
gdImageFill(im, 0, 0, 0xffffff);
fputs("flag 3\n", stdout);
/* fputs("flag 3\n", stdout); */
fp = fopen("a.png", "wb");
/* Write img to stdout */

View File

@ -9,7 +9,7 @@ int main()
int x,y, error = 0;
char path[1024];
fputs("flag 0\n", stdout);
/* fputs("flag 0\n", stdout); */
im = gdImageCreate(150, 150);
tile = gdImageCreate(36, 36);
gdImageColorAllocate(tile,255,255,255); /* allocate white for background color */
@ -31,11 +31,11 @@ int main()
gdImageFill(im, 11,12, gdTiled);
fputs("flag 1\n", stdout);
/* fputs("flag 1\n", stdout); */
gdImageFill(im, 0, 0, 0xffffff);
fputs("flag 2\n", stdout);
/* fputs("flag 2\n", stdout); */
gdImageFill(im, 0, 0, 0xffffff);
fputs("flag 2\n", stdout);
/* fputs("flag 2\n", stdout); */
sprintf(path, "%s/gdimagefill/bug00002_2_exp.png", GDTEST_TOP_DIR);

View File

@ -10,7 +10,7 @@ int main()
int x,y, error = 0;
char path[1024];
fputs("flag 0\n", stdout);
/* fputs("flag 0\n", stdout); */
im = gdImageCreate(150, 150);
@ -38,11 +38,11 @@ int main()
gdImageFill(im, 11,12, gdTiled);
fputs("flag 1\n", stdout);
/* fputs("flag 1\n", stdout); */
gdImageFill(im, 0, 0, 0xffffff);
fputs("flag 2\n", stdout);
/* fputs("flag 2\n", stdout); */
gdImageFill(im, 0, 0, 0xffffff);
fputs("flag 3\n", stdout);
/* fputs("flag 3\n", stdout); */
sprintf(path, "%s/gdimagefill/bug00002_3_exp.png", GDTEST_TOP_DIR);
if (!gdAssertImageEqualsToFile(path, im)) {

View File

@ -9,6 +9,10 @@
#include "gdtest.h"
#include "test_config.h"
void gdSilence(int priority, const char *format, ...)
{
return;
}
gdImagePtr gdTestImageFromPng(const char *filename)
{

View File

@ -39,4 +39,6 @@ int _gdTestErrorMsg(const char* file, int line, const char* string, ...);
#define gdTestErrorMsg(format, ...) _gdTestErrorMsg(__FILE__, __LINE__, format, ## __VA_ARGS__)
void gdSilence(int priority, const char *format, ...);
#endif /* GD_TEST_H */

View File

@ -7,6 +7,11 @@
int main()
{
gdImagePtr im, tile;
char path[1024];
gdSetErrorMethod(gdSilence);
snprintf(path, 1023, "%s/gdtiled/%s", GDTEST_TOP_DIR, exp_img);
tile = gdImageCreateTrueColor(10, 10);
gdImageFill(tile, 0, 0, 0xFFFFFF);
@ -19,7 +24,7 @@ int main()
gdImageSetTile(im, tile);
gdImageFilledRectangle(im, 10, 10, 49, 49, gdTiled);
gdAssertImageEqualsToFile(exp_img, im);
gdAssertImageEqualsToFile(path, im);
/* Destroy it */
gdImageDestroy(im);

View File

@ -446,13 +446,10 @@ static const unsigned char gifdata[8994] = {71,73,70,56,55,97,20,1,110,
int main(void)
{
gdImagePtr im;
if ( ( im = gdImageCreateFromGifPtr(8994,
(char*) &gifdata[0]) ) != NULL) {
fprintf(stderr, "success!\n");
if ((im = gdImageCreateFromGifPtr(8994, (char*) &gifdata[0])) != NULL) {
gdImageDestroy(im);
return 0;
} else {
fprintf(stderr, "failed!\n");
return 1;
}
}

View File

@ -34,7 +34,6 @@ int main()
}
trans_c_f =gdImageGetTransparent(im);
printf("c_f: %i\n", trans_c_f);
if (gdTestAssert(trans_c_f == 1)) {
r_f = gdImageRed(im, trans_c_f);
g_f = gdImageGreen(im, trans_c_f);

View File

@ -10,6 +10,8 @@ int main()
FILE *fp;
char path[1024];
gdSetErrorMethod(gdSilence);
sprintf(path, "%s/jpeg/empty.jpeg", GDTEST_TOP_DIR);
fp = fopen(path, "rb");
if (!fp) {

View File

@ -11,10 +11,9 @@ int main()
char path[2048];
sprintf(path, "%s/png/emptyfile", GDTEST_TOP_DIR);
printf("opening %s\n", path);
fp = fopen(path, "rb");
if (!fp) {
printf("failed, cannot open file\n");
fprintf(stderr, "failed, cannot open file: %s\n", path);
return 1;
}
im = gdImageCreateFromPng(fp);

View File

@ -10,6 +10,8 @@ int main()
FILE *fp;
char path[1024];
gdSetErrorMethod(gdSilence);
sprintf(path, "%s/png/bug00033.png", GDTEST_TOP_DIR);
fp = fopen(path, "rb");
if (!fp) {

View File

@ -5,14 +5,16 @@
#include <stdio.h>
#include <stdlib.h>
#include "gd.h"
#include "gdtest.h"
static const unsigned char pngdata[93];
int main(void)
{
gdImagePtr im;
gdSetErrorMethod(gdSilence);
if ( ( im = gdImageCreateFromPngPtr(93, (char*) &pngdata[0]) ) == NULL) {
fprintf(stderr, "success!\n");
return 0;
} else {
fprintf(stderr, "failed!\n");
@ -28,5 +30,4 @@ static const unsigned char pngdata[93] = {137,80,78,71,13,10,26,10,0,0,
75,71,68,0,255,0,255,0,255,160,189,167,147,0,0,0,9,112,72,89,115,0,0,92,
70,0,0,92,70,1,20,148,67,65,0,0,0,9,118,112,65,103,0,0,0,120,0,0,0,131,
0,226,13,249,45
};
};

View File

@ -31,6 +31,8 @@ int main()
{
gdIOCtxPtr ctx;
gdSetErrorMethod(gdSilence);
im = gdImageCreate(100, 100);
ctx = (gdIOCtxPtr)gdMalloc(sizeof(gdIOCtx));
ctx->putC = failPutC;

View File

@ -1,9 +1,12 @@
#include "gd.h"
#include "gdtest.h"
int main()
{
gdImagePtr im;
gdSetErrorMethod(gdSilence);
im = gdImageCreateFromPng(NULL);
if (im != NULL) {
gdImageDestroy(im);