[glib: 7/12] glib/tests/dataset: Use existing code
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 7/12] glib/tests/dataset: Use existing code
- Date: Thu, 7 Jul 2022 11:52:20 +0000 (UTC)
commit e95a6bdd7dbcf0d4732b4b1ccdb33ebd840e7b59
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Thu Jun 23 20:52:59 2022 -0400
glib/tests/dataset: Use existing code
`destroy_index` duplicates `destroy_count`, and `foreach_func()`
essentially duplicates `notify()`.
glib/tests/dataset.c | 33 ++++++++++-----------------------
1 file changed, 10 insertions(+), 23 deletions(-)
---
diff --git a/glib/tests/dataset.c b/glib/tests/dataset.c
index cfc7a69c99..7f7db13dc7 100644
--- a/glib/tests/dataset.c
+++ b/glib/tests/dataset.c
@@ -250,16 +250,6 @@ test_datalist_id (void)
g_datalist_clear (&list);
}
-static void
-foreach_func (GQuark key_id,
- gpointer data,
- gpointer user_data)
-{
- int *count = user_data;
-
- (*count)++;
-}
-
static void
test_datalist_id_remove_multiple (void)
{
@@ -274,7 +264,6 @@ test_datalist_id_remove_multiple (void)
two,
three,
};
- int count;
g_test_bug ("https://gitlab.gnome.org/GNOME/glib/issues/2672");
@@ -283,24 +272,22 @@ test_datalist_id_remove_multiple (void)
g_datalist_id_set_data (&list, two, GINT_TO_POINTER (2));
g_datalist_id_set_data (&list, three, GINT_TO_POINTER (3));
- count = 0;
- g_datalist_foreach (&list, foreach_func, &count);
- g_assert_cmpint (count, ==, 3);
+ destroy_count = 0;
+ g_datalist_foreach (&list, (GDataForeachFunc) notify, NULL);
+ g_assert_cmpint (destroy_count, ==, 3);
g_datalist_id_remove_multiple (&list, keys, G_N_ELEMENTS (keys));
- count = 0;
- g_datalist_foreach (&list, foreach_func, &count);
- g_assert_cmpint (count, ==, 0);
+ destroy_count = 0;
+ g_datalist_foreach (&list, (GDataForeachFunc) notify, NULL);
+ g_assert_cmpint (destroy_count, ==, 0);
}
-static int destroy_index;
-
static void
destroy_func (gpointer data)
{
- destroy_index++;
- g_assert_cmpint (GPOINTER_TO_INT (data), ==, destroy_index);
+ destroy_count++;
+ g_assert_cmpint (GPOINTER_TO_INT (data), ==, destroy_count);
}
static void
@@ -326,10 +313,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;
+ destroy_count = 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);
+ g_assert_cmpint (destroy_count, ==, 3);
}
int
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]