[babl] tests: split utility function out into common.inc



commit 42deed4d166571d5fcc8ce015281ceec1edf6047
Author: Ãyvind KolÃs <pippin gimp org>
Date:   Wed May 2 23:00:46 2012 +0200

    tests: split utility function out into common.inc

 tests/common.inc   |   24 ++++++++++++++++++++++++
 tests/extract.c    |   28 +---------------------------
 tests/floatclamp.c |   26 +-------------------------
 tests/palette.c    |   28 +---------------------------
 4 files changed, 27 insertions(+), 79 deletions(-)
---
diff --git a/tests/common.inc b/tests/common.inc
new file mode 100644
index 0000000..8d573fd
--- /dev/null
+++ b/tests/common.inc
@@ -0,0 +1,24 @@
+
+#define CHECK_CONV(test_name, componenttype, src_fmt, dst_fmt, src_pix, expected_pix) \
+  {       \
+  const Babl *fish;       \
+  int i;       \
+  fish = babl_fish (src_fmt, dst_fmt);       \
+  if (!fish)       \
+    {       \
+      printf ("  %s failed to make fish\n", test_name);       \
+      OK = 0;       \
+    }       \
+  for (i = 0; i < sizeof(src_pix)/sizeof(src_pix[0]); i ++)       \
+    {       \
+      int c;\
+      componenttype result[10];       \
+      babl_process (fish, src_pix[i], result, 1);       \
+      for (c = 0; c < sizeof(expected_pix[i])/sizeof(expected_pix[i][0]); c++) \
+      if (result[c] != expected_pix[i][c])       \
+        {       \
+          printf (" %s failed #%i[%i]  got %i expected %i\n", test_name, i, c, result[c], expected_pix[i][c]);       \
+          OK = 0;          \
+        }       \
+    }       \
+  }
diff --git a/tests/extract.c b/tests/extract.c
index 038c667..f27662b 100644
--- a/tests/extract.c
+++ b/tests/extract.c
@@ -21,33 +21,7 @@
 #include <stdio.h>
 #include <assert.h>
 #include "babl.h"
-
-
-#define CHECK_CONV(test_name, componenttype, src_fmt, dst_fmt, src_pix, expected_pix) \
-  {       \
-  const Babl *fish;       \
-  int i;       \
-  fish = babl_fish (src_fmt, dst_fmt);       \
-  if (!fish)       \
-    {       \
-      printf ("  %s failed to make fish\n", test_name);       \
-      OK = 0;       \
-    }       \
-  for (i = 0; i < sizeof(src_pix)/sizeof(src_pix[0]); i ++)       \
-    {       \
-      int c;\
-      componenttype result[10];       \
-      babl_process (fish, src_pix[i], result, 1);       \
-      for (c = 0; c < sizeof(expected_pix[i])/sizeof(expected_pix[i][0]); c++) \
-      if (result[c] != expected_pix[i][c])       \
-        {       \
-          printf (" %s failed #%i[%i]  got %i expected %i\n", test_name, i, c, result[c], expected_pix[i][c]);       \
-          OK = 0;          \
-        }       \
-    }       \
-  }
-
-#include <assert.h>
+#include "common.inc"
 
 int
 main (int    argc,
diff --git a/tests/floatclamp.c b/tests/floatclamp.c
index 617b440..4ba7992 100644
--- a/tests/floatclamp.c
+++ b/tests/floatclamp.c
@@ -22,32 +22,8 @@
 #include <assert.h>
 #include "babl.h"
 
+#include "common.inc"
 
-#define CHECK_CONV(test_name, componenttype, src_fmt, dst_fmt, src_pix, expected_pix) \
-  {       \
-  const Babl *fish;       \
-  int i;       \
-  fish = babl_fish (src_fmt, dst_fmt);       \
-  if (!fish)       \
-    {       \
-      printf ("  %s failed to make fish\n", test_name);       \
-      OK = 0;       \
-    }       \
-  for (i = 0; i < sizeof(src_pix)/sizeof(src_pix[0]); i ++)       \
-    {       \
-      int c;\
-      componenttype result[10];       \
-      babl_process (fish, src_pix[i], result, 1);       \
-      for (c = 0; c < sizeof(expected_pix[i])/sizeof(expected_pix[i][0]); c++) \
-      if (result[c] != expected_pix[i][c])       \
-        {       \
-          printf (" %s failed #%i[%i]  got %i expected %i\n", test_name, i, c, result[c], expected_pix[i][c]);       \
-          OK = 0;          \
-        }       \
-    }       \
-  }
-
-#include <assert.h>
 
 int
 main (int    argc,
diff --git a/tests/palette.c b/tests/palette.c
index 6ad517f..aaf98c8 100644
--- a/tests/palette.c
+++ b/tests/palette.c
@@ -21,33 +21,7 @@
 #include <stdio.h>
 #include <assert.h>
 #include "babl.h"
-
-
-#define CHECK_CONV(test_name, componenttype, src_fmt, dst_fmt, src_pix, expected_pix) \
-  {       \
-  const Babl *fish;       \
-  int i;       \
-  fish = babl_fish (src_fmt, dst_fmt);       \
-  if (!fish)       \
-    {       \
-      printf ("  %s failed to make fish\n", test_name);       \
-      OK = 0;       \
-    }       \
-  for (i = 0; i < sizeof(src_pix)/sizeof(src_pix[0]); i ++)       \
-    {       \
-      int c;\
-      componenttype result[10];       \
-      babl_process (fish, src_pix[i], result, 1);       \
-      for (c = 0; c < sizeof(expected_pix[i])/sizeof(expected_pix[i][0]); c++) \
-      if (result[c] != expected_pix[i][c])       \
-        {       \
-          printf (" %s failed #%i[%i]  got %i expected %i\n", test_name, i, c, result[c], expected_pix[i][c]);       \
-          OK = 0;          \
-        }       \
-    }       \
-  }
-
-#include <assert.h>
+#include "common.inc"
 
 int
 main (int    argc,



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