mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-26 12:12:10 +01:00
gobject/tests: Exercise a floating object reaching last-unref
This was previously exercised (probably by mistake) in gobject/tests/type.c, but without making any assertions about what happened, and the test would fail under G_ENABLE_DIAGNOSTIC if GLib was compiled with debug enabled. Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
parent
25d21edb32
commit
0bba27eea9
@ -336,6 +336,20 @@ test_initially_unowned (void)
|
|||||||
g_assert_cmpint (obj->ref_count, ==, 1);
|
g_assert_cmpint (obj->ref_count, ==, 1);
|
||||||
|
|
||||||
g_object_unref (obj);
|
g_object_unref (obj);
|
||||||
|
|
||||||
|
if (g_test_undefined ())
|
||||||
|
{
|
||||||
|
obj = g_object_new (G_TYPE_INITIALLY_UNOWNED, NULL);
|
||||||
|
|
||||||
|
#ifdef G_ENABLE_DEBUG
|
||||||
|
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
|
||||||
|
"A floating object GInitiallyUnowned * was finalized*");
|
||||||
|
#endif
|
||||||
|
g_object_unref (obj);
|
||||||
|
#ifdef G_ENABLE_DEBUG
|
||||||
|
g_test_assert_expected_messages ();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -945,6 +959,8 @@ main (int argc, char **argv)
|
|||||||
{
|
{
|
||||||
g_test_init (&argc, &argv, NULL);
|
g_test_init (&argc, &argv, NULL);
|
||||||
|
|
||||||
|
g_setenv ("G_ENABLE_DIAGNOSTIC", "1", TRUE);
|
||||||
|
|
||||||
g_test_add_func ("/type/fundamentals", test_fundamentals);
|
g_test_add_func ("/type/fundamentals", test_fundamentals);
|
||||||
g_test_add_func ("/type/qdata", test_type_qdata);
|
g_test_add_func ("/type/qdata", test_type_qdata);
|
||||||
g_test_add_func ("/type/query", test_type_query);
|
g_test_add_func ("/type/query", test_type_query);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user