tests: add a test for naive CMYK conversion
authorØyvind Kolås <pippin@gimp.org>
Sun, 3 May 2020 10:13:14 +0000 (12:13 +0200)
committerØyvind Kolås <pippin@gimp.org>
Sun, 3 May 2020 10:13:32 +0000 (12:13 +0200)
tests/cmyk.c [new file with mode: 0644]
tests/meson.build

diff --git a/tests/cmyk.c b/tests/cmyk.c
new file mode 100644 (file)
index 0000000..3b11e44
--- /dev/null
@@ -0,0 +1,56 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ *
+ * 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 <stdio.h>
+
+#include <babl/babl.h>
+
+#include "common.inc"
+
+
+int
+main (int    argc,
+      char **argv)
+{
+  int OK = 1;
+
+  float rgba[][4] = {{1.0     , 1.0     , 1.0     , 1.0},
+                     {0.0     , 1.0     , 0.0     , 1.0},
+                     {0.5     , 0.5     , 0.5     , 1.0},
+                     {0.0     , 1.0     , 1.0     , 1.0}};
+
+  float cmyk[][4] = {{0.0,       0.0  ,   0.0  , 0.0},
+                     {1.0,       0.0  ,   1.0  , 0.0},
+                     {0.0,       0.0  ,   0.0  , 0.5},
+                     {1.0,       0.0  ,   0.0  , 0.0}};
+
+  babl_init ();
+
+  CHECK_CONV_FLOAT ("rgba to cmyk ", float, 0.001,
+                    babl_format ("RGBA float"),
+                    babl_format ("CMYK float"),
+                    rgba, cmyk);
+
+  CHECK_CONV_FLOAT ("cmyk to rgba ", float, 0.001,
+                    babl_format ("CMYK float"),
+                    babl_format ("RGBA float"),
+                    cmyk, rgba);
+
+  babl_exit ();
+
+  return !OK;
+}
index dfe7d4541e664bf1405d437efeeabe7b4fbdfc58..a656618d50aa6661c5b156411c2daac00ba93132 100644 (file)
@@ -3,6 +3,7 @@ test_names = [
   'babl_class_name',
   'cairo_cmyk_hack',
   'cairo-RGB24',
+  'cmyk',
   'chromaticities',
   'extract',
   'floatclamp',