[glib: 6/12] dataset: Rename `i` as `destroy_index` and move it out of `destroy_func()`, so that it can be checke




commit a437a97ffd8b398d5407baee2574ce9f9c013d70
Author: Peter Bloomfield <peterbloomfield bellsouth net>
Date:   Thu Jun 23 22:17:13 2022 +0000

    dataset: Rename `i` as `destroy_index` and move it out of `destroy_func()`, so that it can be checked to 
confirm that `destroy_func()` was called three times.

 glib/tests/dataset.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/glib/tests/dataset.c b/glib/tests/dataset.c
index 2897e61593..cfc7a69c99 100644
--- a/glib/tests/dataset.c
+++ b/glib/tests/dataset.c
@@ -294,13 +294,13 @@ test_datalist_id_remove_multiple (void)
   g_assert_cmpint (count, ==, 0);
 }
 
+static int destroy_index;
+
 static void
 destroy_func (gpointer data)
 {
-  static int i = 0;
-
-  i++;
-  g_assert_cmpint (GPOINTER_TO_INT (data), ==, i);
+  destroy_index++;
+  g_assert_cmpint (GPOINTER_TO_INT (data), ==, destroy_index);
 }
 
 static void
@@ -326,7 +326,10 @@ test_datalist_id_remove_multiple_destroy_order (void)
   g_datalist_id_set_data_full (&list, three, GINT_TO_POINTER (3), destroy_func);
   g_datalist_id_set_data_full (&list, one, GINT_TO_POINTER (1), destroy_func);
 
+  destroy_index = 0;
   g_datalist_id_remove_multiple (&list, keys, G_N_ELEMENTS (keys));
+  /* This verifies that destroy_func() was called three times: */
+  g_assert_cmpint (destroy_index, ==, 3);
 }
 
 int


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