diff options
author | Benjamin Otte <otte@redhat.com> | 2015-10-04 02:23:41 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2015-10-06 04:13:20 +0200 |
commit | d1b7a484c0cdd01c3552fb2259cc4a60dea5a726 (patch) | |
tree | 8536c9625118d02a872c40bd2266635bfff1a565 | |
parent | e2e0000c7ae0356af302bddfbeb3a9e33dbe5437 (diff) | |
download | gdk-pixbuf-d1b7a484c0cdd01c3552fb2259cc4a60dea5a726.tar.gz |
test-common: Rename function arguments
Instead of p1 and p2, name the arguments "test" and "ref". This makes
the arguments more meaningful and easier to distinguish.
-rw-r--r-- | tests/pixbuf-slow-load.c | 2 | ||||
-rw-r--r-- | tests/test-common.c | 87 | ||||
-rw-r--r-- | tests/test-common.h | 2 |
3 files changed, 52 insertions, 39 deletions
diff --git a/tests/pixbuf-slow-load.c b/tests/pixbuf-slow-load.c index 47e252315..d22217ec2 100644 --- a/tests/pixbuf-slow-load.c +++ b/tests/pixbuf-slow-load.c @@ -127,7 +127,7 @@ test_reftest_success (gconstpointer file) g_assert (loaded != NULL); - success = pixdata_equal (reference, loaded, &error); + success = pixdata_equal (loaded, reference, &error); g_assert_no_error (error); g_assert (success); diff --git a/tests/test-common.c b/tests/test-common.c index 1bca8da19..738153d15 100644 --- a/tests/test-common.c +++ b/tests/test-common.c @@ -79,58 +79,71 @@ skip_if_insufficient_memory (GError **err) } gboolean -pixdata_equal (GdkPixbuf *p1, GdkPixbuf *p2, GError **error) +pixdata_equal (GdkPixbuf *test, + GdkPixbuf *ref, + GError **error) { - if (gdk_pixbuf_get_colorspace (p1) != gdk_pixbuf_get_colorspace (p2)) { - g_set_error_literal (error, GDK_PIXBUF_ERROR, 0, "Colorspaces differ"); - return FALSE; - } - if (gdk_pixbuf_get_n_channels (p1) != gdk_pixbuf_get_n_channels (p2)) { - g_set_error_literal (error, GDK_PIXBUF_ERROR, 0, "Channels differ"); - return FALSE; - } - if (gdk_pixbuf_get_bits_per_sample (p1) != gdk_pixbuf_get_bits_per_sample (p2)) { - g_set_error_literal (error, GDK_PIXBUF_ERROR, 0, "BPP differ"); - return FALSE; - } - if (gdk_pixbuf_get_width (p1) != gdk_pixbuf_get_width (p2)) { - g_set_error_literal (error, GDK_PIXBUF_ERROR, 0, "Widths differ"); - return FALSE; - } - if (gdk_pixbuf_get_height (p1) != gdk_pixbuf_get_height (p2)) { - g_set_error_literal (error, GDK_PIXBUF_ERROR, 0, "Heights differ"); - return FALSE; - } - if (gdk_pixbuf_get_rowstride (p1) != gdk_pixbuf_get_rowstride (p2)) { - g_set_error_literal (error, GDK_PIXBUF_ERROR, 0, "Rowstrides differ"); - return FALSE; - } + if (gdk_pixbuf_get_colorspace (test) != gdk_pixbuf_get_colorspace (ref)) + { + g_set_error_literal (error, GDK_PIXBUF_ERROR, 0, "Colorspaces differ"); + return FALSE; + } + + if (gdk_pixbuf_get_n_channels (test) != gdk_pixbuf_get_n_channels (ref)) + { + g_set_error_literal (error, GDK_PIXBUF_ERROR, 0, "Channels differ"); + return FALSE; + } + + if (gdk_pixbuf_get_bits_per_sample (test) != gdk_pixbuf_get_bits_per_sample (ref)) + { + g_set_error_literal (error, GDK_PIXBUF_ERROR, 0, "BPP differ"); + return FALSE; + } + + if (gdk_pixbuf_get_width (test) != gdk_pixbuf_get_width (ref)) + { + g_set_error_literal (error, GDK_PIXBUF_ERROR, 0, "Widths differ"); + return FALSE; + } + + if (gdk_pixbuf_get_height (test) != gdk_pixbuf_get_height (ref)) + { + g_set_error_literal (error, GDK_PIXBUF_ERROR, 0, "Heights differ"); + return FALSE; + } + + if (gdk_pixbuf_get_rowstride (test) != gdk_pixbuf_get_rowstride (ref)) + { + g_set_error_literal (error, GDK_PIXBUF_ERROR, 0, "Rowstrides differ"); + return FALSE; + } - if (memcmp (gdk_pixbuf_get_pixels (p1), gdk_pixbuf_get_pixels (p2), - gdk_pixbuf_get_byte_length (p1)) != 0) + if (memcmp (gdk_pixbuf_get_pixels (test), gdk_pixbuf_get_pixels (ref), + gdk_pixbuf_get_byte_length (test)) != 0) { guint x, y, width, height, n_channels, rowstride; - const guchar *pixels1, *pixels2; + const guchar *test_pixels, *ref_pixels; - rowstride = gdk_pixbuf_get_rowstride (p1); - n_channels = gdk_pixbuf_get_n_channels (p1); - width = gdk_pixbuf_get_width (p1); - height = gdk_pixbuf_get_height (p1); - pixels1 = gdk_pixbuf_get_pixels (p1); - pixels2 = gdk_pixbuf_get_pixels (p2); + rowstride = gdk_pixbuf_get_rowstride (test); + n_channels = gdk_pixbuf_get_n_channels (test); + width = gdk_pixbuf_get_width (test); + height = gdk_pixbuf_get_height (test); + test_pixels = gdk_pixbuf_get_pixels (test); + ref_pixels = gdk_pixbuf_get_pixels (ref); for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { - if (memcmp (&pixels1[x * n_channels], &pixels2[x * n_channels], n_channels) != 0) + if (memcmp (&test_pixels[x * n_channels], &ref_pixels[x * n_channels], n_channels) != 0) { g_set_error (error, GDK_PIXBUF_ERROR, 0, "Data differ at %ux%u", x, y); return FALSE; } } - pixels1 += rowstride; - pixels2 += rowstride; + test_pixels += rowstride; + ref_pixels += rowstride; } } diff --git a/tests/test-common.h b/tests/test-common.h index 5c8e3e7a4..4273f7198 100644 --- a/tests/test-common.h +++ b/tests/test-common.h @@ -29,7 +29,7 @@ G_BEGIN_DECLS gboolean format_supported (const gchar *filename); gboolean skip_if_insufficient_memory (GError **err); -gboolean pixdata_equal (GdkPixbuf *p1, GdkPixbuf *p2, GError **error); +gboolean pixdata_equal (GdkPixbuf *test, GdkPixbuf *ref, GError **error); void add_test_for_all_images (const gchar *prefix, const gchar *dir, GTestDataFunc test_func); |