summaryrefslogtreecommitdiff
path: root/Build/source/libs/gd/libgd-src/tests/xbm/github_bug_170.c
blob: 8134fb82fdb8166fcc4a03fa0d7fe87c9b928c1a (plain)
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
/*
	Test writing of XBM images with a width that is not a multiple of 8

	We create an image with a width of 11 pixels, and draw a circle on it.
	To test that the padding is correctly applied, we write the image to disk
	and assert that the number of bytes written matches our expectation.

	See also <https://github.com/libgd/libgd/issues/170>.
*/

#include <inttypes.h>
#include "gd.h"
#include "gdtest.h"
#ifdef _WIN32

int main()
{
	/* skip for now */
	return 0;
}
#else
int main()
{
	gdImagePtr im;
	int black;
	FILE *outFile;
	gdIOCtx *out;
	off_t length;

	/* create the test image */
	im = gdImageCreate(11, 11);
	gdImageColorAllocate(im, 255, 255, 255);
	black = gdImageColorAllocate(im, 0, 0, 0);
	gdImageArc(im, 5, 5, 10, 10, 0, 360, black);

	/* write the file to disk, note the file length and delete the file */
	outFile = gdTestTempFp();
	out = gdNewFileCtx(outFile);
	gdTestAssert(out != NULL);
	gdImageXbmCtx(im, "github_bug_170.xbm", 1, out);
	out->gd_free(out);
	length = ftello(outFile);
	fclose(outFile);

	gdImageDestroy(im);

	gdTestAssertMsg(length == 250, "expected to write 250 bytes; %jd bytes written", (intmax_t) length);
	return gdNumFailures();
}
#endif