[gobject-introspection/gnome-3-36] gimarshallingtests: Use g_assert_cmpfloat_with_epsilon
- From: Christoph Reiter <creiter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection/gnome-3-36] gimarshallingtests: Use g_assert_cmpfloat_with_epsilon
- Date: Sun, 5 Apr 2020 13:57:43 +0000 (UTC)
commit e809109017208e716c4c433f03db743846da4a43
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 92868016..cff2dcb0 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]