[glib: 6/10] Convert tests/refcount/properties4.c to glib test framework




commit d97c1a148e65c1acdc3682ad279891973bab5371
Author: Emmanuel Fleury <emmanuel fleury gmail com>
Date:   Wed Mar 16 09:31:31 2022 +0100

    Convert tests/refcount/properties4.c to glib test framework

 tests/refcount/properties4.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)
---
diff --git a/tests/refcount/properties4.c b/tests/refcount/properties4.c
index d4bca94865..462f9e3cd5 100644
--- a/tests/refcount/properties4.c
+++ b/tests/refcount/properties4.c
@@ -143,19 +143,15 @@ my_badger_mama_notify (GObject    *object,
   MyBadger *self;
 
   self = MY_BADGER (object);
-
   self->mama_notify_count++;
 }
 
-int
-main (int argc, char **argv)
+static void
+test_refcount_properties_4 (void)
 {
   MyBadger * badger1, * badger2;
   gpointer test;
 
-  g_print ("START: %s\n", argv[0]);
-  g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL | g_log_set_always_fatal 
(G_LOG_FATAL_MASK));
-
   badger1 = g_object_new (MY_TYPE_BADGER, NULL);
   badger2 = g_object_new (MY_TYPE_BADGER, NULL);
 
@@ -163,11 +159,23 @@ main (int argc, char **argv)
   g_assert_cmpuint (badger1->mama_notify_count, ==, 1);
   g_assert_cmpuint (badger2->mama_notify_count, ==, 1);
   g_object_get (badger1, "mama", &test, NULL);
-  g_assert (test == badger2);
+  g_assert_cmpmem (test, sizeof (MyBadger), badger2, sizeof (MyBadger));
   g_object_unref (test);
 
   g_object_unref (badger1);
   g_object_unref (badger2);
+}
+
+int
+main (int argc, gchar *argv[])
+{
+  g_log_set_always_fatal (G_LOG_LEVEL_WARNING |
+                          G_LOG_LEVEL_CRITICAL |
+                          g_log_set_always_fatal (G_LOG_FATAL_MASK));
+
+  g_test_init (&argc, &argv, NULL);
+
+  g_test_add_func ("/gobject/refcount/properties-4", test_refcount_properties_4);
 
-  return 0;
+  return g_test_run ();
 }


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