tests: add test that creates the base fishes expected by GIMP
authorØyvind Kolås <pippin@gimp.org>
Thu, 14 May 2020 15:55:05 +0000 (17:55 +0200)
committerØyvind Kolås <pippin@gimp.org>
Wed, 27 May 2020 02:46:33 +0000 (04:46 +0200)
tests/conversions.c [new file with mode: 0644]
tests/meson.build

diff --git a/tests/conversions.c b/tests/conversions.c
new file mode 100644 (file)
index 0000000..3074c4f
--- /dev/null
@@ -0,0 +1,72 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005, Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, see
+ * <https://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+#include "babl-internal.h"
+
+ static const struct 
+  { 
+    const char *from_format; 
+    const char *to_format; 
+  } 
+  fishes[] = 
+  { 
+    { "Y' u8",          "RaGaBaA float" }, 
+    { "Y u8",           "RaGaBaA float" }, 
+    { "R'G'B'A u8",     "RaGaBaA float" }, 
+    { "R'G'B'A float",  "R'G'B'A u8"    }, 
+    { "R'G'B'A float",  "R'G'B' u8"     }, 
+    { "R'G'B'A u8",     "RGBA float"    }, 
+    { "RGBA float",     "R'G'B'A u8"    }, 
+    { "RGBA float",     "R'G'B'A u8"    }, 
+    { "RGBA float",     "R'G'B'A float" }, 
+    { "Y' u8",          "R'G'B' u8"     }, 
+    { "Y u8",           "Y float"       }, 
+    { "R'G'B' u8",      "cairo-RGB24"   }, 
+    { "R'G'B' u8",      "R'G'B'A float" }, 
+    { "R'G'B' u8",      "R'G'B'A u8"    }, 
+    { "R'G'B'A u8",     "R'G'B'A float" }, 
+    { "R'G'B'A u8",     "cairo-ARGB32"  }, 
+    { "R'G'B'A double", "RGBA float"    }, 
+    { "R'G'B'A float",  "RGBA double"   }, 
+    { "R'G'B' u8",      "RGB float"     }, 
+    { "RGB float",      "R'G'B'A float" }, 
+    { "R'G'B' u8",      "RGBA float"    }, 
+    { "RaGaBaA float",  "R'G'B'A float" }, 
+    { "RaGaBaA float",  "RGBA float"    }, 
+    { "RGBA float",     "RaGaBaA float" }, 
+    { "R'G'B' u8",      "RaGaBaA float" }, 
+    { "cairo-ARGB32",   "R'G'B'A u8"    } 
+  };
+
+int
+main (int    argc,
+      char **argv)
+{
+  setenv ("BABL_DEBUG_MISSING", "1", 1);
+  babl_init ();
+  
+  for (int i = 0; i < sizeof (fishes)/sizeof(fishes[0]);i ++)
+  {
+    babl_fish (babl_format (fishes[i].from_format),
+               babl_format (fishes[i].to_format));
+  }
+
+  babl_exit ();
+  return 0;
+}
index a656618d50aa6661c5b156411c2daac00ba93132..4431ed81eb7e98d55421e69fd604eb22a291eb11 100644 (file)
@@ -5,6 +5,7 @@ test_names = [
   'cairo-RGB24',
   'cmyk',
   'chromaticities',
+  'conversions',
   'extract',
   'floatclamp',
   'float-to-8bit',