summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2021-10-06 22:17:33 +0200
committerBenjamin Otte <otte@redhat.com>2021-10-06 22:50:07 +0200
commit2e555db9a4210480360cde2770981daf22a74619 (patch)
treec7564a8bb948a71eacfe4468690e2ec3714a9578 /testsuite
parent3f4fb93379618626485dac32d15eb389a6b2c10e (diff)
downloadgtk+-2e555db9a4210480360cde2770981daf22a74619.tar.gz
testsuite: Fail more accurately
Don't run the full test and then return "something failed" - instead just explode when you find the failure.
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/gdk/texture.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/testsuite/gdk/texture.c b/testsuite/gdk/texture.c
index fc1f728c7c..1a218ddd4a 100644
--- a/testsuite/gdk/texture.c
+++ b/testsuite/gdk/texture.c
@@ -1,6 +1,6 @@
#include <gtk.h>
-static gboolean
+static void
compare_pixels (int width,
int height,
guchar *data1,
@@ -8,15 +8,17 @@ compare_pixels (int width,
guchar *data2,
gsize stride2)
{
- int i;
- for (i = 0; i < height; i++)
+ int x, y;
+ for (y = 0; y < height; y++)
{
- gconstpointer p1 = data1 + i * stride1;
- gconstpointer p2 = data2 + i * stride2;
- if (memcmp (p1, p2, width * 4) != 0)
- return FALSE;
+ const guint32 *p1 = (const guint32*) (data1 + y * stride1);
+ const guint32 *p2 = (const guint32*) (data2 + y * stride2);
+
+ for (x = 0; x < width; x++)
+ {
+ g_assert_cmphex (p1[x], ==, p2[x]);
+ }
}
- return TRUE;
}
static void
@@ -55,10 +57,10 @@ test_texture_from_pixbuf (void)
cairo_paint (cr);
cairo_destroy (cr);
- g_assert_true (compare_pixels (width, height,
- data, stride,
- cairo_image_surface_get_data (surface),
- cairo_image_surface_get_stride (surface)));
+ compare_pixels (width, height,
+ data, stride,
+ cairo_image_surface_get_data (surface),
+ cairo_image_surface_get_stride (surface));
g_free (data);