[mutter] cogl/tests: Fix warning about passing a double to fabs
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] cogl/tests: Fix warning about passing a double to fabs
- Date: Fri, 4 Mar 2022 23:38:48 +0000 (UTC)
commit 63cc69b342da77e375be2834bf9384f0e59142ae
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Fri Mar 4 20:46:48 2022 +0100
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>
cogl/tests/conform/test-color-hsl.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
---
diff --git a/cogl/tests/conform/test-color-hsl.c b/cogl/tests/conform/test-color-hsl.c
index 15f2fe84bf..fa3af53347 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");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]