From 11305b4ecdd36a17592c5c75de9157874853ab20 Mon Sep 17 00:00:00 2001 From: Andrea Canciani Date: Tue, 22 Feb 2011 21:46:37 +0100 Subject: [PATCH 03/40] test: Fix tests for compilation on Windows The Microsoft C compiler cannot handle subobject initialization and Win32 does not provide snprintf. Work around these limitations by using normal struct initialization and using sprintf (a manual check shows that the buffer size is sufficient). --- test/composite.c | 29 +++++++++++++-------------- test/fetch-test.c | 52 ++++++++++++++++++++++---------------------------- test/trap-crasher.c | 20 +++++++++--------- 3 files changed, 47 insertions(+), 54 deletions(-) diff --git a/test/composite.c b/test/composite.c index e14f954..08c6689 100644 --- a/test/composite.c +++ b/test/composite.c @@ -617,18 +617,18 @@ eval_diff (color_t *expected, color_t *test, pixman_format_code_t format) } static char * -describe_image (image_t *info, char *buf, int buflen) +describe_image (image_t *info, char *buf) { if (info->size) { - snprintf (buf, buflen, "%s %dx%d%s", - info->format->name, - info->size, info->size, - info->repeat ? "R" :""); + sprintf (buf, "%s %dx%d%s", + info->format->name, + info->size, info->size, + info->repeat ? "R" :""); } else { - snprintf (buf, buflen, "solid"); + sprintf (buf, "solid"); } return buf; @@ -710,10 +710,9 @@ composite_test (image_t *dst, { char buf[40]; - snprintf (buf, sizeof (buf), - "%s %scomposite", - op->name, - component_alpha ? "CA " : ""); + sprintf (buf, "%s %scomposite", + op->name, + component_alpha ? "CA " : ""); printf ("%s test error of %.4f --\n" " R G B A\n" @@ -735,9 +734,9 @@ composite_test (image_t *dst, mask->color->b, mask->color->a, dst->color->r, dst->color->g, dst->color->b, dst->color->a); - printf ("src: %s, ", describe_image (src, buf, sizeof (buf))); - printf ("mask: %s, ", describe_image (mask, buf, sizeof (buf))); - printf ("dst: %s\n\n", describe_image (dst, buf, sizeof (buf))); + printf ("src: %s, ", describe_image (src, buf)); + printf ("mask: %s, ", describe_image (mask, buf)); + printf ("dst: %s\n\n", describe_image (dst, buf)); } else { @@ -747,8 +746,8 @@ composite_test (image_t *dst, src->color->b, src->color->a, dst->color->r, dst->color->g, dst->color->b, dst->color->a); - printf ("src: %s, ", describe_image (src, buf, sizeof (buf))); - printf ("dst: %s\n\n", describe_image (dst, buf, sizeof (buf))); + printf ("src: %s, ", describe_image (src, buf)); + printf ("dst: %s\n\n", describe_image (dst, buf)); } success = FALSE; diff --git a/test/fetch-test.c b/test/fetch-test.c index 2ca16dd..314a072 100644 --- a/test/fetch-test.c +++ b/test/fetch-test.c @@ -8,7 +8,7 @@ static pixman_indexed_t mono_palette = { - .rgba = { 0x00000000, 0x00ffffff }, + 0, { 0x00000000, 0x00ffffff }, }; @@ -24,57 +24,53 @@ typedef struct { static testcase_t testcases[] = { { - .format = PIXMAN_a8r8g8b8, - .width = 2, .height = 2, - .stride = 8, - .src = { 0x00112233, 0x44556677, - 0x8899aabb, 0xccddeeff }, - .dst = { 0x00112233, 0x44556677, - 0x8899aabb, 0xccddeeff }, - .indexed = NULL, + PIXMAN_a8r8g8b8, + 2, 2, + 8, + { 0x00112233, 0x44556677, + 0x8899aabb, 0xccddeeff }, + { 0x00112233, 0x44556677, + 0x8899aabb, 0xccddeeff }, + NULL, }, { - .format = PIXMAN_g1, - .width = 8, .height = 2, - .stride = 4, + PIXMAN_g1, + 8, 2, + 4, #ifdef WORDS_BIGENDIAN - .src = { 0xaa000000, 0x55000000 }, #else - .src = { 0x00000055, 0x000000aa }, #endif - .dst = { 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff, 0x00000000, 0x00ffffff }, - .indexed = &mono_palette, + &mono_palette, }, #if 0 { - .format = PIXMAN_g8, - .width = 4, .height = 2, - .stride = 4, - .src = { 0x01234567, - 0x89abcdef }, - .dst = { 0x00010101, 0x00232323, 0x00454545, 0x00676767, - 0x00898989, 0x00ababab, 0x00cdcdcd, 0x00efefef, }, + PIXMAN_g8, + 4, 2, + 4, + { 0x01234567, + 0x89abcdef }, + { 0x00010101, 0x00232323, 0x00454545, 0x00676767, + 0x00898989, 0x00ababab, 0x00cdcdcd, 0x00efefef, }, }, #endif /* FIXME: make this work on big endian */ { - .format = PIXMAN_yv12, - .width = 8, .height = 2, - .stride = 8, + PIXMAN_yv12, + 8, 2, + 8, #ifdef WORDS_BIGENDIAN - .src = { 0x00ff00ff, 0x00ff00ff, 0xff00ff00, 0xff00ff00, @@ -82,7 +78,6 @@ static testcase_t testcases[] = 0x800080ff }, #else - .src = { 0xff00ff00, 0xff00ff00, 0x00ff00ff, 0x00ff00ff, @@ -90,7 +85,6 @@ static testcase_t testcases[] = 0xff800080 }, #endif - .dst = { 0xff000000, 0xffffffff, 0xffb80000, 0xffffe113, 0xff000000, 0xffffffff, 0xff0023ee, 0xff4affff, diff --git a/test/trap-crasher.c b/test/trap-crasher.c index 42b82f6..7485e62 100644 --- a/test/trap-crasher.c +++ b/test/trap-crasher.c @@ -7,21 +7,21 @@ main() pixman_image_t *dst; pixman_trapezoid_t traps[1] = { { - .top = 2147483646, - .bottom = 2147483647, - .left = { - .p1 = { .x = 0, .y = 0 }, - .p2 = { .x = 0, .y = 2147483647 } + 2147483646, + 2147483647, + { + { 0, 0 }, + { 0, 2147483647 } }, - .right = { - .p1 = { .x = 65536, .y = 0 }, - .p2 = { .x = 0, .y = 2147483647 } + { + { 65536, 0 }, + { 0, 2147483647 } } }, }; - + dst = pixman_image_create_bits (PIXMAN_a8, 1, 1, NULL, -1); - + pixman_add_trapezoids (dst, 0, 0, sizeof (traps)/sizeof (traps[0]), traps); return (0); } -- 1.6.6.1