mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-09-27 17:52:58 +02:00
Convert tests/refcount/objects2.c to glib test framework
This commit is contained in:
committed by
Philip Withnall
parent
62b5fe5991
commit
715ff4ea29
@@ -73,7 +73,7 @@ my_test_class_init (GTestClass * klass)
|
|||||||
static void
|
static void
|
||||||
my_test_init (GTest * test)
|
my_test_init (GTest * test)
|
||||||
{
|
{
|
||||||
g_print ("init %p\n", test);
|
g_test_message ("init %p\n", test);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -83,7 +83,7 @@ my_test_dispose (GObject * object)
|
|||||||
|
|
||||||
test = MY_TEST (object);
|
test = MY_TEST (object);
|
||||||
|
|
||||||
g_print ("dispose %p!\n", test);
|
g_test_message ("dispose %p!\n", test);
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
@@ -92,30 +92,40 @@ static void
|
|||||||
my_test_do_refcount (GTest * test)
|
my_test_do_refcount (GTest * test)
|
||||||
{
|
{
|
||||||
static guint i = 1;
|
static guint i = 1;
|
||||||
|
|
||||||
if (i++ % 100000 == 0)
|
if (i++ % 100000 == 0)
|
||||||
g_print (".");
|
g_test_message (".");
|
||||||
g_object_ref (test);
|
|
||||||
g_object_unref (test);
|
g_object_ref (test);
|
||||||
|
g_object_unref (test);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_refcount_object_advanced (void)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
GTest *test;
|
||||||
|
|
||||||
|
test = g_object_new (G_TYPE_TEST, NULL);
|
||||||
|
|
||||||
|
for (i = 0; i < 100000000; i++)
|
||||||
|
{
|
||||||
|
my_test_do_refcount (test);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_object_unref (test);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
gint i;
|
g_log_set_always_fatal (G_LOG_LEVEL_WARNING |
|
||||||
GTest *test;
|
G_LOG_LEVEL_CRITICAL |
|
||||||
|
g_log_set_always_fatal (G_LOG_FATAL_MASK));
|
||||||
|
|
||||||
g_print ("START: %s\n", argv[0]);
|
g_test_init (&argc, &argv, NULL);
|
||||||
g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL | g_log_set_always_fatal (G_LOG_FATAL_MASK));
|
|
||||||
|
|
||||||
test = g_object_new (G_TYPE_TEST, NULL);
|
g_test_add_func ("/gobject/refcount/object-advanced", test_refcount_object_advanced);
|
||||||
|
|
||||||
for (i=0; i<100000000; i++) {
|
return g_test_run ();
|
||||||
my_test_do_refcount (test);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_object_unref (test);
|
|
||||||
|
|
||||||
g_print ("\n");
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user