[gdk-pixbuf/wip/otte/tga] test-common: Rename function arguments



commit d1b7a484c0cdd01c3552fb2259cc4a60dea5a726
Author: Benjamin Otte <otte redhat com>
Date:   Sun Oct 4 02:23:41 2015 +0200

    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.

 tests/pixbuf-slow-load.c |    2 +-
 tests/test-common.c      |   87 ++++++++++++++++++++++++++-------------------
 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 47e2523..d22217e 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 1bca8da..738153d 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 5c8e3e7..4273f71 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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]