diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/alpha_symmetric_transform.c | 3 | ||||
-rw-r--r-- | tests/babl_class_name.c | 3 | ||||
-rw-r--r-- | tests/cairo_cmyk_hack.c | 3 | ||||
-rw-r--r-- | tests/chromaticities.c | 3 | ||||
-rw-r--r-- | tests/cmyk.c | 3 | ||||
-rw-r--r-- | tests/common.inc | 24 | ||||
-rw-r--r-- | tests/concurrency-stress-test.c | 3 | ||||
-rw-r--r-- | tests/conversions.c | 5 | ||||
-rw-r--r-- | tests/extract.c | 3 | ||||
-rw-r--r-- | tests/float-to-8bit.c | 3 | ||||
-rw-r--r-- | tests/floatclamp.c | 3 | ||||
-rw-r--r-- | tests/format_with_space.c | 3 | ||||
-rw-r--r-- | tests/grayscale_to_rgb.c | 3 | ||||
-rw-r--r-- | tests/hsl.c | 3 | ||||
-rw-r--r-- | tests/hsva.c | 3 | ||||
-rw-r--r-- | tests/meson.build | 3 | ||||
-rw-r--r-- | tests/n_components.c | 3 | ||||
-rw-r--r-- | tests/n_components_cast.c | 3 | ||||
-rw-r--r-- | tests/nop.c | 3 | ||||
-rw-r--r-- | tests/palette-concurrency-stress-test.c | 3 | ||||
-rw-r--r-- | tests/palette.c | 3 | ||||
-rw-r--r-- | tests/rgb_to_bgr.c | 3 | ||||
-rw-r--r-- | tests/rgb_to_ycbcr.c | 3 | ||||
-rw-r--r-- | tests/sanity.c | 3 | ||||
-rw-r--r-- | tests/srgb_to_lab_u8.c | 3 | ||||
-rw-r--r-- | tests/transparent.c | 3 | ||||
-rw-r--r-- | tests/xyz_to_lab.c | 74 |
27 files changed, 110 insertions, 65 deletions
diff --git a/tests/alpha_symmetric_transform.c b/tests/alpha_symmetric_transform.c index a42709a..aff23ce 100644 --- a/tests/alpha_symmetric_transform.c +++ b/tests/alpha_symmetric_transform.c @@ -100,8 +100,7 @@ test (void) } int -main (int argc, - char **argv) +main (void) { babl_init (); if (test ()) diff --git a/tests/babl_class_name.c b/tests/babl_class_name.c index c0724f0..caec910 100644 --- a/tests/babl_class_name.c +++ b/tests/babl_class_name.c @@ -63,8 +63,7 @@ test (void) } int -main (int argc, - char **argv) +main (void) { babl_init (); if (test ()) diff --git a/tests/cairo_cmyk_hack.c b/tests/cairo_cmyk_hack.c index 1f308fe..f68cd9a 100644 --- a/tests/cairo_cmyk_hack.c +++ b/tests/cairo_cmyk_hack.c @@ -69,8 +69,7 @@ test (void) } int -main (int argc, - char **argv) +main (void) { babl_init (); if (test ()) diff --git a/tests/chromaticities.c b/tests/chromaticities.c index a57cead..963650c 100644 --- a/tests/chromaticities.c +++ b/tests/chromaticities.c @@ -66,8 +66,7 @@ test (void) } int -main (int argc, - char **argv) +main (void) { babl_init (); if (test ()) diff --git a/tests/cmyk.c b/tests/cmyk.c index 3b11e44..cc29963 100644 --- a/tests/cmyk.c +++ b/tests/cmyk.c @@ -23,8 +23,7 @@ int -main (int argc, - char **argv) +main (void) { int OK = 1; diff --git a/tests/common.inc b/tests/common.inc index bca5056..2016d04 100644 --- a/tests/common.inc +++ b/tests/common.inc @@ -1,26 +1,23 @@ - +#include <stdlib.h> #include <math.h> #include "babl/babl-introspect.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); \ + const Babl *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 ++) \ + for (size_t 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++) \ + for (size_t 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]); \ + printf (" %s failed #%li[%li] got %i expected %i\n", test_name, i, c, result[c], expected_pix[i][c]); \ OK = 0; \ babl_introspect((Babl *)fish); \ } \ @@ -29,23 +26,20 @@ #define CHECK_CONV_FLOAT(test_name, componenttype, max_error, src_fmt, dst_fmt, src_pix, expected_pix) \ { \ - const Babl *fish; \ - int i; \ - fish = babl_fish (src_fmt, dst_fmt); \ + const Babl *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 ++) \ + for (size_t 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++) \ + for (size_t c = 0; c < sizeof(expected_pix[i])/sizeof(expected_pix[i][0]); c++) \ if (fabs(result[c] - expected_pix[i][c]) > max_error) \ { \ - printf (" %s failed #%i[%i] got %lf expected %lf\n", test_name, i, c, result[c], expected_pix[i][c]); \ + printf (" %s failed #%li[%li] got %lf expected %lf\n", test_name, i, c, result[c], expected_pix[i][c]); \ OK = 0; \ babl_introspect((Babl *)fish); \ } \ diff --git a/tests/concurrency-stress-test.c b/tests/concurrency-stress-test.c index a02a519..bf0ffff 100644 --- a/tests/concurrency-stress-test.c +++ b/tests/concurrency-stress-test.c @@ -49,8 +49,7 @@ babl_fish_path_stress_test_thread_func (void *not_used) } int -main (int argc, - char **argv) +main (void) { pthread_t threads[N_THREADS]; int i; diff --git a/tests/conversions.c b/tests/conversions.c index 9503d04..d699b21 100644 --- a/tests/conversions.c +++ b/tests/conversions.c @@ -55,14 +55,13 @@ }; int -main (int argc, - char **argv) +main (void) { putenv ("BABL_DEBUG_CONVERSIONS" "=" "1"); putenv ("BABL_DEBUG_MISSING" "=" "1"); babl_init (); - for (int i = 0; i < sizeof (fishes)/sizeof(fishes[0]);i ++) + for (size_t i = 0; i < sizeof (fishes)/sizeof(fishes[0]);i ++) { babl_fish (babl_format (fishes[i].from_format), babl_format (fishes[i].to_format)); diff --git a/tests/extract.c b/tests/extract.c index ffd9f5c..06f143e 100644 --- a/tests/extract.c +++ b/tests/extract.c @@ -24,8 +24,7 @@ #include "common.inc" int -main (int argc, - char **argv) +main (void) { int OK = 1; babl_init (); diff --git a/tests/float-to-8bit.c b/tests/float-to-8bit.c index 1a3cafc..01d5997 100644 --- a/tests/float-to-8bit.c +++ b/tests/float-to-8bit.c @@ -26,8 +26,7 @@ int -main (int argc, - char **argv) +main (void) { int OK = 1; diff --git a/tests/floatclamp.c b/tests/floatclamp.c index 7960e13..7878e2e 100644 --- a/tests/floatclamp.c +++ b/tests/floatclamp.c @@ -26,8 +26,7 @@ int -main (int argc, - char **argv) +main (void) { int OK = 1; babl_init (); diff --git a/tests/format_with_space.c b/tests/format_with_space.c index 34f5332..c26384c 100644 --- a/tests/format_with_space.c +++ b/tests/format_with_space.c @@ -96,8 +96,7 @@ test3 (void) } int -main (int argc, - char **argv) +main (void) { babl_init (); if (test2 ()) diff --git a/tests/grayscale_to_rgb.c b/tests/grayscale_to_rgb.c index c3ec7c7..cd4063e 100644 --- a/tests/grayscale_to_rgb.c +++ b/tests/grayscale_to_rgb.c @@ -72,8 +72,7 @@ test (void) } int -main (int argc, - char **argv) +main (void) { babl_init (); if (test ()) diff --git a/tests/hsl.c b/tests/hsl.c index aaa1855..54659cf 100644 --- a/tests/hsl.c +++ b/tests/hsl.c @@ -23,8 +23,7 @@ int -main (int argc, - char **argv) +main (void) { int OK = 1; diff --git a/tests/hsva.c b/tests/hsva.c index 66b93b8..c2a224b 100644 --- a/tests/hsva.c +++ b/tests/hsva.c @@ -32,8 +32,7 @@ int -main (int argc, - char **argv) +main (void) { int OK = 1; diff --git a/tests/meson.build b/tests/meson.build index 56f5812..c8f0e51 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -25,6 +25,7 @@ test_names = [ 'transparent', 'alpha_symmetric_transform', 'types', + 'xyz_to_lab' ] if platform_unix test_names += [ @@ -41,7 +42,7 @@ foreach test_name : test_names test_name + '.c', include_directories: [rootInclude, bablInclude], link_with: babl, - dependencies: thread, + dependencies: [thread, lcms], export_dynamic: true, install: false, ) diff --git a/tests/n_components.c b/tests/n_components.c index afe5d25..9cb8935 100644 --- a/tests/n_components.c +++ b/tests/n_components.c @@ -105,8 +105,7 @@ test (void) } int -main (int argc, - char **argv) +main (void) { babl_init (); if (test ()) diff --git a/tests/n_components_cast.c b/tests/n_components_cast.c index 86c6437..f654aa7 100644 --- a/tests/n_components_cast.c +++ b/tests/n_components_cast.c @@ -24,8 +24,7 @@ #include "common.inc" int -main (int argc, - char **argv) +main (void) { int OK = 1; babl_init (); diff --git a/tests/nop.c b/tests/nop.c index 0ea6fe0..1d8bbd2 100644 --- a/tests/nop.c +++ b/tests/nop.c @@ -20,8 +20,7 @@ #include "babl.h" int -main (int argc, - char **argv) +main (void) { babl_init (); babl_exit (); diff --git a/tests/palette-concurrency-stress-test.c b/tests/palette-concurrency-stress-test.c index a42b15d..9dee768 100644 --- a/tests/palette-concurrency-stress-test.c +++ b/tests/palette-concurrency-stress-test.c @@ -52,8 +52,7 @@ thread_proc (void *data) } int -main (int argc, - char **argv) +main (void) { const Babl *pal; const Babl *pal_format; diff --git a/tests/palette.c b/tests/palette.c index 92651d0..3fd64c4 100644 --- a/tests/palette.c +++ b/tests/palette.c @@ -24,8 +24,7 @@ #include "common.inc" int -main (int argc, - char **argv) +main (void) { int OK = 1; babl_init (); diff --git a/tests/rgb_to_bgr.c b/tests/rgb_to_bgr.c index 4e63222..3759673 100644 --- a/tests/rgb_to_bgr.c +++ b/tests/rgb_to_bgr.c @@ -79,8 +79,7 @@ test (void) } int -main (int argc, - char **argv) +main (void) { babl_init (); if (test ()) diff --git a/tests/rgb_to_ycbcr.c b/tests/rgb_to_ycbcr.c index c02f743..6022211 100644 --- a/tests/rgb_to_ycbcr.c +++ b/tests/rgb_to_ycbcr.c @@ -86,8 +86,7 @@ test (void) } int -main (int argc, - char **argv) +main (void) { babl_init (); if (test ()) diff --git a/tests/sanity.c b/tests/sanity.c index 28158ee..b84c299 100644 --- a/tests/sanity.c +++ b/tests/sanity.c @@ -20,8 +20,7 @@ #include "babl-internal.h" int -main (int argc, - char **argv) +main (void) { babl_init (); if (!babl_sanity ()) diff --git a/tests/srgb_to_lab_u8.c b/tests/srgb_to_lab_u8.c index b99538f..f8b04fc 100644 --- a/tests/srgb_to_lab_u8.c +++ b/tests/srgb_to_lab_u8.c @@ -66,8 +66,7 @@ test (void) } int -main (int argc, - char **argv) +main (void) { babl_init (); if (test ()) diff --git a/tests/transparent.c b/tests/transparent.c index 7cbc6ea..dd66366 100644 --- a/tests/transparent.c +++ b/tests/transparent.c @@ -45,8 +45,7 @@ clear_fish_db (void) } int -main (int argc, - char **argv) +main (void) { int OK = 1; int i; diff --git a/tests/xyz_to_lab.c b/tests/xyz_to_lab.c new file mode 100644 index 0000000..c8e0b81 --- /dev/null +++ b/tests/xyz_to_lab.c @@ -0,0 +1,74 @@ +/* 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 <math.h> +#include <babl/babl.h> +#include <stdio.h> + +#define PIXELS 4 +#define TOLERANCE 0.05 + +float source_buf [PIXELS * 3] = +{ 0.950, 1.000, 1.089, + 1.000, 0.000, 0.000, + 0.000, 1.000, 0.000, + 0.000, 0.000, 1.000 +}; + +float reference_buf [PIXELS * 3] = +{ 100.00, -2.467186, -19.400648, + 0.0, 437.147125, 0.0, + 100.0, -431.034485, 172.4137, + 0.0, 0.0, -185.6406, +}; + +float destination_buf [PIXELS * 3]; + +static int +test (void) +{ + int i; + int OK = 1; + + babl_process (babl_fish ("CIE XYZ float", "CIE Lab float"), + source_buf, destination_buf, + PIXELS); + + for (i = 0; i < PIXELS * 3; i++) + { + if (fabs (1.0 * destination_buf[i] - reference_buf[i]) > TOLERANCE) + { + fprintf (stderr, "%2i (component: %2i%%3=%i, test no: %2i/3=%i) is %f should be %f\n", + i, i, i % 3, i, i / 3, destination_buf[i], reference_buf[i]); + OK = 0; + } + } + if (!OK) + return -1; + return 0; +} + +int +main (void) +{ + babl_init (); + if (test ()) + return -1; + babl_exit (); + return 0; +} |