[Pixman] [PATCH 2/3] test: Fix tests for compilation on Windows
Andrea Canciani
ranma42 at gmail.com
Tue Feb 22 14:07:43 PST 2011
The Microsoft C compiler cannot handle subobject initialization and
Win32 does not provide snprintf.
Work around these limitations by using normal struct initailization
and directly using printf.
---
test/composite.c | 48 +++++++++++++++++++++++++++-------------------
test/fetch-test.c | 52 ++++++++++++++++++++++----------------------------
test/trap-crasher.c | 20 +++++++++---------
3 files changed, 61 insertions(+), 59 deletions(-)
diff --git a/test/composite.c b/test/composite.c
index e14f954..33e8d97 100644
--- a/test/composite.c
+++ b/test/composite.c
@@ -616,22 +616,20 @@ eval_diff (color_t *expected, color_t *test, pixman_format_code_t format)
return MAX (MAX (MAX (rdiff, gdiff), bdiff), adiff);
}
-static char *
-describe_image (image_t *info, char *buf, int buflen)
+static void
+describe_image (image_t *info)
{
if (info->size)
{
- snprintf (buf, buflen, "%s %dx%d%s",
+ printf ("%s %dx%d%s",
info->format->name,
info->size, info->size,
info->repeat ? "R" :"");
}
else
{
- snprintf (buf, buflen, "solid");
+ printf ("solid");
}
-
- return buf;
}
/* Test a composite of a given operation, source, mask, and destination
@@ -708,18 +706,13 @@ composite_test (image_t *dst,
*/
if (diff > 3.0)
{
- char buf[40];
-
- snprintf (buf, sizeof (buf),
- "%s %scomposite",
- op->name,
- component_alpha ? "CA " : "");
-
- printf ("%s test error of %.4f --\n"
+ printf ("%s %scomposite test error of %.4f --\n"
" R G B A\n"
"got: %.2f %.2f %.2f %.2f [%08lx]\n"
"expected: %.2f %.2f %.2f %.2f\n",
- buf, diff,
+ op->name,
+ component_alpha ? "CA " : "",
+ diff,
result.r, result.g, result.b, result.a,
*(unsigned long *) pixman_image_get_data (dst->image),
expected.r, expected.g, expected.b, expected.a);
@@ -735,9 +728,18 @@ 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: ");
+ describe_image (src);
+ printf (", ");
+
+ printf ("mask: ");
+ describe_image (mask);
+ printf (", ");
+
+ printf ("dst: ");
+ describe_image (dst);
+ printf ("\n\n");
}
else
{
@@ -747,8 +749,14 @@ 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: ");
+ describe_image (src);
+ printf (", ");
+
+ printf ("dst: ");
+ describe_image (dst);
+ printf ("\n\n");
}
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.7.1
More information about the Pixman
mailing list