Debian Codegraph @

debian/patches/tests-conform-Use-epsilon-to-compare-floating-numbers.patch

raw
1 From: =?utf-8?b?Ik1hcmNvIFRyZXZpc2FuIChUcmV2acOxbyki?= <[email protected]>
2 Date: Wed, 8 Mar 2023 00:45:51 +0100
3 Subject: tests/conform: Use epsilon to compare floating numbers
4
5 These tests may fail in i386, so let's use some safer comparisons
6 ---
7 tests/conform/animator.c | 6 +++---
8 tests/conform/interval.c | 4 ++--
9 tests/conform/units.c | 2 +-
10 3 files changed, 6 insertions(+), 6 deletions(-)
11
12 diff --git a/tests/conform/animator.c b/tests/conform/animator.c
13 index 9711699..8530feb 100644
14 --- a/tests/conform/animator.c
15 +++ b/tests/conform/animator.c
16 @@ -51,7 +51,7 @@ animator_multi_properties (void)
17 }
18
19 g_assert (clutter_animator_key_get_object (key) != NULL);
20 - g_assert_cmpfloat (clutter_animator_key_get_progress (key), ==, 0.2);
21 + g_assert_cmpfloat_with_epsilon (clutter_animator_key_get_progress (key), 0.2, 0.00001);
22 g_assert_cmpstr (clutter_animator_key_get_property_name (key), ==, "x");
23
24 g_assert (clutter_animator_key_get_property_type (key) == G_TYPE_FLOAT);
25 @@ -86,7 +86,7 @@ animator_multi_properties (void)
26 }
27
28 g_assert (clutter_animator_key_get_object (key) != NULL);
29 - g_assert_cmpfloat (clutter_animator_key_get_progress (key), ==, 0.8);
30 + g_assert_cmpfloat_with_epsilon (clutter_animator_key_get_progress (key), 0.8, 0.00001);
31 g_assert_cmpstr (clutter_animator_key_get_property_name (key), ==, "y");
32
33 g_assert (clutter_animator_key_get_property_type (key) == G_TYPE_FLOAT);
34 @@ -148,7 +148,7 @@ animator_properties (void)
35 }
36
37 g_assert (clutter_animator_key_get_object (key) != NULL);
38 - g_assert_cmpfloat (clutter_animator_key_get_progress (key), ==, 0.2);
39 + g_assert_cmpfloat_with_epsilon (clutter_animator_key_get_progress (key), 0.2, 0.00001);
40 g_assert_cmpstr (clutter_animator_key_get_property_name (key), ==, "x");
41
42 g_assert (clutter_animator_key_get_property_type (key) == G_TYPE_FLOAT);
43 diff --git a/tests/conform/interval.c b/tests/conform/interval.c
44 index 5204378..2d73545 100644
45 --- a/tests/conform/interval.c
46 +++ b/tests/conform/interval.c
47 @@ -91,14 +91,14 @@ interval_from_script (void)
48 g_type_name (G_VALUE_TYPE (initial)),
49 g_value_get_float (initial));
50 g_assert (G_VALUE_HOLDS (initial, G_TYPE_FLOAT));
51 - g_assert_cmpfloat (g_value_get_float (initial), ==, 23.3f);
52 + g_assert_cmpfloat_with_epsilon (g_value_get_float (initial), 23.3f, 0.0001);
53 final = clutter_interval_peek_final_value (interval);
54 if (g_test_verbose ())
55 g_test_message ("\tfinal ['%s'] = '%.2f'",
56 g_type_name (G_VALUE_TYPE (final)),
57 g_value_get_float (final));
58 g_assert (G_VALUE_HOLDS (final, G_TYPE_FLOAT));
59 - g_assert_cmpfloat (g_value_get_float (final), ==, 42.2f);
60 + g_assert_cmpfloat_with_epsilon (g_value_get_float (final), 42.2f, 0.00001);
61
62 interval = CLUTTER_INTERVAL (clutter_script_get_object (script, "int-2"));
63 initial = clutter_interval_peek_initial_value (interval);
64 diff --git a/tests/conform/units.c b/tests/conform/units.c
65 index 06bfaf5..d320c12 100644
66 --- a/tests/conform/units.c
67 +++ b/tests/conform/units.c
68 @@ -94,7 +94,7 @@ units_string (void)
69
70 g_assert (clutter_units_from_string (&units, "5.1cm") == TRUE);
71 g_assert (clutter_units_get_unit_type (&units) == CLUTTER_UNIT_CM);
72 - g_assert_cmpfloat (clutter_units_get_unit_value (&units), ==, 5.1f);
73 + g_assert_cmpfloat_with_epsilon (clutter_units_get_unit_value (&units), 5.1f, 0.00001);
74
75 g_assert (clutter_units_from_string (&units, "5,mm") == FALSE);
76