[glib/gtype-speedups: 2/2] Add a test for g_type_is_a




commit e80d2bc1cacde169ea5a051ee70d2528707f6e25
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri May 20 08:11:06 2022 -0400

    Add a test for g_type_is_a
    
    Check that the macro and function versions
    of g_type_is_a work the same.

 gobject/tests/type.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
---
diff --git a/gobject/tests/type.c b/gobject/tests/type.c
index 30e138a777..50cb2c92fb 100644
--- a/gobject/tests/type.c
+++ b/gobject/tests/type.c
@@ -201,6 +201,20 @@ test_next_base (void)
   g_assert (type == G_TYPE_INITIALLY_UNOWNED);
 }
 
+/* Test that the macro an function versions of g_type_is_a
+ * work the same
+ */
+static void
+test_is_a (void)
+{
+  g_assert_true (g_type_is_a (G_TYPE_OBJECT, G_TYPE_OBJECT));
+  g_assert_true ((g_type_is_a) (G_TYPE_OBJECT, G_TYPE_OBJECT));
+  g_assert_true (g_type_is_a (bar_get_type (), G_TYPE_OBJECT));
+  g_assert_true ((g_type_is_a) (bar_get_type (), G_TYPE_OBJECT));
+  g_assert_false (g_type_is_a (bar_get_type (), bibi_get_type ()));
+  g_assert_false ((g_type_is_a) (bar_get_type (), bibi_get_type ()));
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -210,6 +224,7 @@ main (int argc, char *argv[])
   g_test_add_func ("/type/interface-prerequisite", test_interface_prerequisite);
   g_test_add_func ("/type/interface-check", test_interface_check);
   g_test_add_func ("/type/next-base", test_next_base);
+  g_test_add_func ("/type/is-a", test_is_a);
 
   return g_test_run ();
 }


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