[sapwood] move the pixbuf comparison into the shared stuff
- From: Sven Herzberg <herzi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sapwood] move the pixbuf comparison into the shared stuff
- Date: Fri, 6 Aug 2010 12:05:48 +0000 (UTC)
commit 404f237f0b397190e95a9c54b868e7b46b0cc0b3
Author: Sven Herzberg <herzi gnome-de org>
Date: Thu Aug 5 14:08:03 2010 +0200
move the pixbuf comparison into the shared stuff
* tests/test-framework.c,
* tests/test-sapwood.c: move the pixbuf comparison into a better place
tests/test-framework.h | 59 ++++++++++++++++++++++++++++++++++++++++++++++++
tests/test-sapwood.c | 59 +-----------------------------------------------
2 files changed, 60 insertions(+), 58 deletions(-)
---
diff --git a/tests/test-framework.h b/tests/test-framework.h
index 83c940f..35556c6 100644
--- a/tests/test-framework.h
+++ b/tests/test-framework.h
@@ -21,6 +21,65 @@
#ifndef TEST_FRAMEWORK_H
#define TEST_FRAMEWORK_H
+#define assert_cmp_pixbuf(a,op,b) \
+ G_STMT_START { \
+ if (a && b) \
+ { \
+ int cmp_x, cmp_y; \
+ guchar* pixels_##a; \
+ guchar* pixels_##b; \
+ g_assert_cmpint (gdk_pixbuf_get_n_channels (a), \
+ ==, \
+ gdk_pixbuf_get_n_channels (b)); \
+ g_assert_cmpint (gdk_pixbuf_get_bits_per_sample (a), \
+ ==, \
+ gdk_pixbuf_get_bits_per_sample (b)); \
+ g_assert_cmpint (gdk_pixbuf_get_colorspace (a), \
+ ==, \
+ gdk_pixbuf_get_colorspace (b)); \
+ g_assert_cmpint (gdk_pixbuf_get_has_alpha (a), \
+ ==, \
+ gdk_pixbuf_get_has_alpha (b)); \
+ g_assert_cmpint (gdk_pixbuf_get_height (a), \
+ ==, \
+ gdk_pixbuf_get_height (b)); \
+ g_assert_cmpint (gdk_pixbuf_get_width (a), \
+ ==, \
+ gdk_pixbuf_get_width (b)); \
+ pixels_##a = gdk_pixbuf_get_pixels (a); \
+ pixels_##b = gdk_pixbuf_get_pixels (b); \
+ for (cmp_y = 0; cmp_y < gdk_pixbuf_get_height (a); cmp_y++) \
+ { \
+ for (cmp_x = 0; cmp_x < gdk_pixbuf_get_width (a); cmp_x++) \
+ { \
+ guchar* pixel_##a = pixels_##a + cmp_y * gdk_pixbuf_get_rowstride (a) + cmp_x * gdk_pixbuf_get_n_channels (a); \
+ guchar* pixel_##b = pixels_##b + cmp_y * gdk_pixbuf_get_rowstride (b) + cmp_x * gdk_pixbuf_get_n_channels (b); \
+ guint value_##a = (pixel_##a[0] << 16) + (pixel_##a[1] << 8) + pixel_##a[2]; \
+ guint value_##b = (pixel_##b[0] << 16) + (pixel_##b[1] << 8) + pixel_##b[2]; \
+ if (gdk_pixbuf_get_has_alpha (a)) \
+ { \
+ value_##a <<= 8; value_##a += pixel_##a[3]; \
+ value_##b <<= 8; value_##b += pixel_##b[3]; \
+ } \
+ if (value_##a op value_##b) ; else \
+ { \
+ gchar const* name_one = G_STRINGIFY (a) ".png"; \
+ gchar const* name_two = G_STRINGIFY (b) ".png"; \
+ gdk_pixbuf_save (a, name_one, "png", NULL, NULL); \
+ gdk_pixbuf_save (b, name_two, "png", NULL, NULL); \
+ g_message ("pixels at (%d;%d) differ: output images at \"%s\" and \"%s\"", \
+ cmp_x, cmp_y, name_one, name_two); \
+ g_assert_cmphex (value_##a, op, value_##b); \
+ } \
+ } \
+ } \
+ } \
+ else \
+ { \
+ g_assert_cmpuint ((uintptr_t)a, ==, (uintptr_t)b); \
+ } \
+ } G_STMT_END
+
#endif /* !TEST_FRAMEWORK_H */
diff --git a/tests/test-sapwood.c b/tests/test-sapwood.c
index 7b5d539..e4d49b7 100644
--- a/tests/test-sapwood.c
+++ b/tests/test-sapwood.c
@@ -26,64 +26,7 @@
#include <sapwood-pixmap.h>
#include <gdk/gdkx.h> /* GDK_DISPLAY_XDISPLAY() */
-#define assert_cmp_pixbuf(a,op,b) \
- G_STMT_START { \
- if (a && b) \
- { \
- int cmp_x, cmp_y; \
- guchar* pixels_##a; \
- guchar* pixels_##b; \
- g_assert_cmpint (gdk_pixbuf_get_n_channels (a), \
- ==, \
- gdk_pixbuf_get_n_channels (b)); \
- g_assert_cmpint (gdk_pixbuf_get_bits_per_sample (a), \
- ==, \
- gdk_pixbuf_get_bits_per_sample (b)); \
- g_assert_cmpint (gdk_pixbuf_get_colorspace (a), \
- ==, \
- gdk_pixbuf_get_colorspace (b)); \
- g_assert_cmpint (gdk_pixbuf_get_has_alpha (a), \
- ==, \
- gdk_pixbuf_get_has_alpha (b)); \
- g_assert_cmpint (gdk_pixbuf_get_height (a), \
- ==, \
- gdk_pixbuf_get_height (b)); \
- g_assert_cmpint (gdk_pixbuf_get_width (a), \
- ==, \
- gdk_pixbuf_get_width (b)); \
- pixels_##a = gdk_pixbuf_get_pixels (a); \
- pixels_##b = gdk_pixbuf_get_pixels (b); \
- for (cmp_y = 0; cmp_y < gdk_pixbuf_get_height (a); cmp_y++) \
- { \
- for (cmp_x = 0; cmp_x < gdk_pixbuf_get_width (a); cmp_x++) \
- { \
- guchar* pixel_##a = pixels_##a + cmp_y * gdk_pixbuf_get_rowstride (a) + cmp_x * gdk_pixbuf_get_n_channels (a); \
- guchar* pixel_##b = pixels_##b + cmp_y * gdk_pixbuf_get_rowstride (b) + cmp_x * gdk_pixbuf_get_n_channels (b); \
- guint value_##a = (pixel_##a[0] << 16) + (pixel_##a[1] << 8) + pixel_##a[2]; \
- guint value_##b = (pixel_##b[0] << 16) + (pixel_##b[1] << 8) + pixel_##b[2]; \
- if (gdk_pixbuf_get_has_alpha (a)) \
- { \
- value_##a <<= 8; value_##a += pixel_##a[3]; \
- value_##b <<= 8; value_##b += pixel_##b[3]; \
- } \
- if (value_##a op value_##b) ; else \
- { \
- gchar const* name_one = G_STRINGIFY (a) ".png"; \
- gchar const* name_two = G_STRINGIFY (b) ".png"; \
- gdk_pixbuf_save (a, name_one, "png", NULL, NULL); \
- gdk_pixbuf_save (b, name_two, "png", NULL, NULL); \
- g_message ("pixels at (%d;%d) differ: output images at \"%s\" and \"%s\"", \
- cmp_x, cmp_y, name_one, name_two); \
- g_assert_cmphex (value_##a, op, value_##b); \
- } \
- } \
- } \
- } \
- else \
- { \
- g_assert_cmpuint ((uintptr_t)a, ==, (uintptr_t)b); \
- } \
- } G_STMT_END
+#include "test-framework.h"
static void
test_larger (void)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]