diff --git a/cogl/tests/conform/test-color-hsl.c b/cogl/tests/conform/test-color-hsl.c index 15f2fe84b..fa3af5334 100644 --- a/cogl/tests/conform/test-color-hsl.c +++ b/cogl/tests/conform/test-color-hsl.c @@ -6,11 +6,7 @@ #include "test-declarations.h" #include "test-utils.h" -#define cogl_assert_float(a, b) \ - do { \ - if (fabsf ((a) - (b)) >= 0.0001f) \ - g_assert_cmpfloat ((a), ==, (b)); \ - } while (0) +#define TEST_CASE_EPSILON 0.0001 void test_color_hsl (void) @@ -21,9 +17,9 @@ test_color_hsl (void) cogl_color_init_from_4ub(&color, 108, 198, 78, 255); cogl_color_to_hsl(&color, &hue, &saturation, &luminance); - cogl_assert_float(hue, 105.f); - cogl_assert_float(saturation, 0.512821); - cogl_assert_float(luminance, 0.541176); + g_assert_cmpfloat_with_epsilon (hue, 105.f, TEST_CASE_EPSILON); + g_assert_cmpfloat_with_epsilon (saturation, 0.512821, TEST_CASE_EPSILON); + g_assert_cmpfloat_with_epsilon (luminance, 0.541176, TEST_CASE_EPSILON); memset(&color, 0, sizeof (CoglColor)); cogl_color_init_from_hsl(&color, hue, saturation, luminance); @@ -36,10 +32,14 @@ test_color_hsl (void) memset(&color, 0, sizeof (CoglColor)); cogl_color_init_from_hsl(&color, hue, 0, luminance); - cogl_assert_float (cogl_color_get_red_float (&color), luminance); - cogl_assert_float (cogl_color_get_green_float (&color), luminance); - cogl_assert_float (cogl_color_get_blue_float (&color), luminance); - cogl_assert_float (cogl_color_get_alpha_float (&color), 1.0f); + g_assert_cmpfloat_with_epsilon (cogl_color_get_red_float (&color), luminance, + TEST_CASE_EPSILON); + g_assert_cmpfloat_with_epsilon (cogl_color_get_green_float (&color), luminance, + TEST_CASE_EPSILON); + g_assert_cmpfloat_with_epsilon (cogl_color_get_blue_float (&color), luminance, + TEST_CASE_EPSILON); + g_assert_cmpfloat_with_epsilon (cogl_color_get_alpha_float (&color), 1.0, + TEST_CASE_EPSILON); if (cogl_test_verbose ()) g_print ("OK\n");