[gobject-introspection] gimarshallingtests: Use g_assert_cmpfloat_with_epsilon



commit 49fa7c278a05228931b7b436b10b323c1ef6730e
Author: Iain Lane <iainl gnome org>
Date:   Thu Mar 12 17:56:56 2020 +0000

    gimarshallingtests: Use g_assert_cmpfloat_with_epsilon
    
    Comparing floats directly doesn't always work on all architectures.

 tests/gimarshallingtests.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/tests/gimarshallingtests.c b/tests/gimarshallingtests.c
index 44971506..53c17818 100644
--- a/tests/gimarshallingtests.c
+++ b/tests/gimarshallingtests.c
@@ -3167,13 +3167,13 @@ gi_marshalling_tests_ghashtable_double_in (GHashTable *hash_table)
   double *value;
 
   value = g_hash_table_lookup (hash_table, "-1");
-  g_assert_cmpfloat (*value, ==, -0.1);
+  g_assert_cmpfloat_with_epsilon (*value, -0.1, 0.01);
   value = g_hash_table_lookup (hash_table, "0");
   g_assert_cmpfloat (*value, ==, 0.0);
   value = g_hash_table_lookup (hash_table, "1");
-  g_assert_cmpfloat (*value, ==, 0.1);
+  g_assert_cmpfloat_with_epsilon (*value, 0.1, 0.01);
   value = g_hash_table_lookup (hash_table, "2");
-  g_assert_cmpfloat (*value, ==, 0.2);
+  g_assert_cmpfloat_with_epsilon (*value, 0.2, 0.01);
 }
 
 /**
@@ -3188,13 +3188,13 @@ gi_marshalling_tests_ghashtable_float_in (GHashTable *hash_table)
   float *value;
 
   value = g_hash_table_lookup (hash_table, "-1");
-  g_assert_cmpfloat (*value, ==, -0.1f);
+  g_assert_cmpfloat_with_epsilon (*value, -0.1f, 0.01f);
   value = g_hash_table_lookup (hash_table, "0");
   g_assert_cmpfloat (*value, ==, 0.0f);
   value = g_hash_table_lookup (hash_table, "1");
-  g_assert_cmpfloat (*value, ==, 0.1f);
+  g_assert_cmpfloat_with_epsilon (*value, 0.1f, 0.01f);
   value = g_hash_table_lookup (hash_table, "2");
-  g_assert_cmpfloat (*value, ==, 0.2f);
+  g_assert_cmpfloat_with_epsilon (*value, 0.2f, 0.01f);
 }
 
 /**


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]