[gegl/gsoc2009-gpu] Modify automated test-suites to use GEGL_FLOAT_*() methods to test floats



commit 79f045c787a0ea823954d416ca717f1ddb14c14d
Author: Jerson Michael Perpetua <jersonperpetua gmail com>
Date:   Thu Aug 20 03:18:10 2009 +0800

    Modify automated test-suites to use GEGL_FLOAT_*() methods to test floats

 tests/test-gegl-gpu-texture-clear-subrect.c        |    9 +++++----
 tests/test-gegl-gpu-texture-clear.c                |    3 ++-
 tests/test-gegl-gpu-texture-copy-subrect.c         |    9 +++++----
 tests/test-gegl-gpu-texture-copy.c                 |    3 ++-
 tests/test-gegl-gpu-texture-set-subrect.c          |    9 +++++----
 tests/test-gegl-gpu-texture-set.c                  |    3 ++-
 tests/test-gegl-tile-cow-consistency.c             |    3 ++-
 ...t-gegl-tile-lock-mode-gpu-write-then-gpu-read.c |    3 ++-
 .../test-gegl-tile-lock-mode-gpu-write-then-read.c |    3 ++-
 .../test-gegl-tile-lock-mode-write-then-gpu-read.c |    3 ++-
 tests/test-gegl-tile-lock-mode-write-then-read.c   |    3 ++-
 11 files changed, 31 insertions(+), 20 deletions(-)
---
diff --git a/tests/test-gegl-gpu-texture-clear-subrect.c b/tests/test-gegl-gpu-texture-clear-subrect.c
index c79680f..dc2da5f 100644
--- a/tests/test-gegl-gpu-texture-clear-subrect.c
+++ b/tests/test-gegl-gpu-texture-clear-subrect.c
@@ -19,6 +19,7 @@
 #include <babl/babl.h>
 
 #include "gegl.h"
+#include "gegl-utils.h"
 #include "gegl-gpu-texture.h"
 
 #define SUCCESS 0
@@ -93,10 +94,10 @@ main (gint    argc,
               {
                 gfloat *pixel = &components[(y * 4 * 50) + (x * 4)];
 
-                if (pixel[0] != 0.0
-                    || pixel[1] != 0.0
-                    || pixel[2] != 0.0
-                    || pixel[3] != 0.0)
+                if (   !GEGL_FLOAT_IS_ZERO (pixel[0])
+                    || !GEGL_FLOAT_IS_ZERO (pixel[1])
+                    || !GEGL_FLOAT_IS_ZERO (pixel[2])
+                    || !GEGL_FLOAT_IS_ZERO (pixel[3]))
                   {
                     g_printerr ("The gegl_gpu_texture_clear() (%s) test "
                                 "failed. Aborting.\n", test_cases[cnt].name);
diff --git a/tests/test-gegl-gpu-texture-clear.c b/tests/test-gegl-gpu-texture-clear.c
index 8da5ad5..1399a27 100644
--- a/tests/test-gegl-gpu-texture-clear.c
+++ b/tests/test-gegl-gpu-texture-clear.c
@@ -19,6 +19,7 @@
 #include <babl/babl.h>
 
 #include "gegl.h"
+#include "gegl-utils.h"
 #include "gegl-gpu-texture.h"
 
 #define SUCCESS 0
@@ -45,7 +46,7 @@ main (gint    argc,
       gegl_gpu_texture_get   (texture, NULL, components, NULL);
 
       for (cnt = 0; cnt < 4 * 50 * 50; cnt++)
-        if (components[cnt] != 0.0)
+        if (!GEGL_FLOAT_IS_ZERO (components[cnt]))
           {
             g_printerr ("The gegl_gpu_texture_clear() test failed. "
                         "Aborting.\n");
diff --git a/tests/test-gegl-gpu-texture-copy-subrect.c b/tests/test-gegl-gpu-texture-copy-subrect.c
index d9b1a42..9eb205d 100644
--- a/tests/test-gegl-gpu-texture-copy-subrect.c
+++ b/tests/test-gegl-gpu-texture-copy-subrect.c
@@ -20,6 +20,7 @@
 #include <babl/babl.h>
 
 #include "gegl.h"
+#include "gegl-utils.h"
 #include "gegl-gpu-texture.h"
 
 #define SUCCESS 0
@@ -113,10 +114,10 @@ main (gint    argc,
               {
                 gfloat *pixel = &components[(y * 4 * 50) + (x * 4)];
 
-                if (pixel[0] != 1.0
-                    || pixel[1] != 1.0
-                    || pixel[2] != 1.0
-                    || pixel[3] != 1.0)
+                if (   !GEGL_FLOAT_EQUAL (pixel[0], 1.0)
+                    || !GEGL_FLOAT_EQUAL (pixel[1], 1.0)
+                    || !GEGL_FLOAT_EQUAL (pixel[2], 1.0)
+                    || !GEGL_FLOAT_EQUAL (pixel[3], 1.0))
                   {
                     g_printerr ("The gegl_gpu_texture_copy() (%s) test failed. "
                                 "Aborting.\n", test_cases[cnt].name);
diff --git a/tests/test-gegl-gpu-texture-copy.c b/tests/test-gegl-gpu-texture-copy.c
index 799f04d..b202d42 100644
--- a/tests/test-gegl-gpu-texture-copy.c
+++ b/tests/test-gegl-gpu-texture-copy.c
@@ -19,6 +19,7 @@
 #include <babl/babl.h>
 
 #include "gegl.h"
+#include "gegl-utils.h"
 #include "gegl-gpu-texture.h"
 
 #define SUCCESS 0
@@ -68,7 +69,7 @@ main (gint    argc,
 
       /* compare the two images */
       for (cnt = 0; cnt < 4 * 50 * 50; cnt++)
-        if (components1[cnt] != components2[cnt])
+        if (!GEGL_FLOAT_EQUAL (components1[cnt], components2[cnt]))
           {
             g_printerr ("The gegl_gpu_texture_copy() test failed. "
                         "Aborting.\n");
diff --git a/tests/test-gegl-gpu-texture-set-subrect.c b/tests/test-gegl-gpu-texture-set-subrect.c
index 218ef9c..c9dd4e1 100644
--- a/tests/test-gegl-gpu-texture-set-subrect.c
+++ b/tests/test-gegl-gpu-texture-set-subrect.c
@@ -19,6 +19,7 @@
 #include <babl/babl.h>
 
 #include "gegl.h"
+#include "gegl-utils.h"
 #include "gegl-gpu-texture.h"
 
 #define SUCCESS 0
@@ -99,10 +100,10 @@ main (gint    argc,
               {
                 gfloat *pixel = &components[(y * 4 * 50) + (x * 4)];
 
-                if (pixel[0] != 1.0
-                    || pixel[1] != 1.0
-                    || pixel[2] != 1.0
-                    || pixel[3] != 1.0)
+                if (   !GEGL_FLOAT_EQUAL (pixel[0], 1.0)
+                    || !GEGL_FLOAT_EQUAL (pixel[1], 1.0)
+                    || !GEGL_FLOAT_EQUAL (pixel[2], 1.0)
+                    || !GEGL_FLOAT_EQUAL (pixel[3], 1.0))
                   {
                     g_printerr ("The gegl_gpu_texture_set() (%s) test failed. "
                                 "Aborting.\n", test_cases[cnt].name);
diff --git a/tests/test-gegl-gpu-texture-set.c b/tests/test-gegl-gpu-texture-set.c
index 1548ab0..6b810dd 100644
--- a/tests/test-gegl-gpu-texture-set.c
+++ b/tests/test-gegl-gpu-texture-set.c
@@ -20,6 +20,7 @@
 #include <babl/babl.h>
 
 #include "gegl.h"
+#include "gegl-utils.h"
 #include "gegl-gpu-texture.h"
 
 #define SUCCESS 0
@@ -55,7 +56,7 @@ main (gint    argc,
       gegl_gpu_texture_get (texture, NULL, components, NULL);
 
       for (cnt = 0; cnt < 4 * 50 * 50; cnt++)
-        if (components[cnt] != 1.0)
+        if (!GEGL_FLOAT_EQUAL (components[cnt], 1.0))
           {
             g_printerr ("The gegl_gpu_texture_set() test failed. Aborting.\n");
             retval = FAILURE;
diff --git a/tests/test-gegl-tile-cow-consistency.c b/tests/test-gegl-tile-cow-consistency.c
index 53f6ee8..17f0d55 100644
--- a/tests/test-gegl-tile-cow-consistency.c
+++ b/tests/test-gegl-tile-cow-consistency.c
@@ -20,6 +20,7 @@
 #include <babl/babl.h>
 
 #include "gegl.h"
+#include "gegl-utils.h"
 #include "gegl-gpu-texture.h"
 
 #include "../../gegl/buffer/gegl-tile.h"
@@ -65,7 +66,7 @@ main (gint    argc,
                             babl_format ("RGBA float"));
 
       for (cnt = 0; cnt < 4 * 50 * 50; cnt++)
-        if (components[cnt] != gpu_components[cnt])
+        if (!GEGL_FLOAT_EQUAL (components[cnt], gpu_components[cnt]))
           {
             g_printerr ("Test on gegl_tile_dup() GPU data/data consistency "
                         "failed. Aborting.\n");
diff --git a/tests/test-gegl-tile-lock-mode-gpu-write-then-gpu-read.c b/tests/test-gegl-tile-lock-mode-gpu-write-then-gpu-read.c
index 6af888d..cfac8b0 100644
--- a/tests/test-gegl-tile-lock-mode-gpu-write-then-gpu-read.c
+++ b/tests/test-gegl-tile-lock-mode-gpu-write-then-gpu-read.c
@@ -20,6 +20,7 @@
 #include <babl/babl.h>
 
 #include "gegl.h"
+#include "gegl-utils.h"
 #include "gegl-gpu-texture.h"
 
 #include "../../gegl/buffer/gegl-tile.h"
@@ -80,7 +81,7 @@ main (gint    argc,
                             babl_format ("RGBA float"));
 
       for (cnt = 0; cnt < 4 * 50 * 50; cnt++)
-        if (tile_components[cnt] != components[cnt])
+        if (!GEGL_FLOAT_EQUAL (tile_components[cnt], components[cnt]))
           {
             g_printerr ("Tile GPU texture inconsistent with original GPU "
                         "texture. Aborting.\n");
diff --git a/tests/test-gegl-tile-lock-mode-gpu-write-then-read.c b/tests/test-gegl-tile-lock-mode-gpu-write-then-read.c
index 98d6a56..07e9acb 100644
--- a/tests/test-gegl-tile-lock-mode-gpu-write-then-read.c
+++ b/tests/test-gegl-tile-lock-mode-gpu-write-then-read.c
@@ -20,6 +20,7 @@
 #include <babl/babl.h>
 
 #include "gegl.h"
+#include "gegl-utils.h"
 #include "gegl-gpu-texture.h"
 
 #include "../../gegl/buffer/gegl-tile.h"
@@ -76,7 +77,7 @@ main (gint    argc,
       tile_components = (gpointer) gegl_tile_get_data (tile);
 
       for (cnt = 0; cnt < 4 * 50 * 50; cnt++)
-        if (tile_components[cnt] != components[cnt])
+        if (!GEGL_FLOAT_EQUAL (tile_components[cnt], components[cnt]))
           {
             g_printerr ("Tile data inconsistent with original GPU texture. "
                         "Aborting.\n");
diff --git a/tests/test-gegl-tile-lock-mode-write-then-gpu-read.c b/tests/test-gegl-tile-lock-mode-write-then-gpu-read.c
index 577b280..4fa0371 100644
--- a/tests/test-gegl-tile-lock-mode-write-then-gpu-read.c
+++ b/tests/test-gegl-tile-lock-mode-write-then-gpu-read.c
@@ -20,6 +20,7 @@
 #include <babl/babl.h>
 
 #include "gegl.h"
+#include "gegl-utils.h"
 #include "gegl-gpu-texture.h"
 
 #include "../../gegl/buffer/gegl-tile.h"
@@ -79,7 +80,7 @@ main (gint    argc,
                             babl_format ("RGBA float"));
 
       for (cnt = 0; cnt < 4 * 50 * 50; cnt++)
-        if (tile_components[cnt] != components[cnt])
+        if (!GEGL_FLOAT_EQUAL (tile_components[cnt], components[cnt]))
           {
             g_printerr ("Tile GPU texture inconsistent with original image "
                         "data. Aborting.\n");
diff --git a/tests/test-gegl-tile-lock-mode-write-then-read.c b/tests/test-gegl-tile-lock-mode-write-then-read.c
index 7006563..da963a0 100644
--- a/tests/test-gegl-tile-lock-mode-write-then-read.c
+++ b/tests/test-gegl-tile-lock-mode-write-then-read.c
@@ -20,6 +20,7 @@
 #include <babl/babl.h>
 
 #include "gegl.h"
+#include "gegl-utils.h"
 #include "gegl-gpu-texture.h"
 
 #include "../../gegl/buffer/gegl-tile.h"
@@ -75,7 +76,7 @@ main (gint    argc,
       tile_components = (gpointer) gegl_tile_get_data (tile);
 
       for (cnt = 0; cnt < 4 * 50 * 50; cnt++)
-        if (tile_components[cnt] != components[cnt])
+        if (!GEGL_FLOAT_EQUAL (tile_components[cnt], components[cnt]))
           {
             g_printerr ("Tile data inconsistent with original image data. "
                         "Aborting.\n");



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