test: Fix tests for compilation on Windows
authorAndrea Canciani <ranma42@gmail.com>
Tue, 22 Feb 2011 20:46:37 +0000 (21:46 +0100)
committerAndrea Canciani <ranma42@gmail.com>
Mon, 28 Feb 2011 09:38:02 +0000 (10:38 +0100)
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
test/fetch-test.c
test/trap-crasher.c

index e14f954be007c42c827423d84d1bbefc1bef6445..08c6689d33626781fadb07ae69b69cede628b4c1 100644 (file)
@@ -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;
index 2ca16ddbf75709463ba087bd9913844fc9afc877..314a072700917ac3c67016961d351432f389ef4a 100644 (file)
@@ -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,
index 42b82f6748997a01864acfcd618aa45f32271192..7485e62fd1d3e7fb1456f0e0cffc0b2a7b31d370 100644 (file)
@@ -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);
 }