mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 08:00:42 -05:00
cogl/tests: Fix warning about passing a double to fabs
The warning was in a home baked g_assert_float_with_epsilon(). Change to use the glib one directly. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2319>
This commit is contained in:
parent
c9125aba73
commit
63cc69b342
@ -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");
|
||||
|
Loading…
Reference in New Issue
Block a user