mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-02 17:26:17 +01:00
Convert tests/refcount/properties2.c to glib test framework
This commit is contained in:
parent
76fccc78c0
commit
ddadb89d7c
@ -98,7 +98,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
|
||||||
@ -108,7 +108,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);
|
||||||
}
|
}
|
||||||
@ -163,7 +163,7 @@ dummy_notify (GObject *object,
|
|||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
if (count % 10000 == 0)
|
if (count % 10000 == 0)
|
||||||
g_print (".");
|
g_test_message (".");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -175,28 +175,36 @@ my_test_do_property (GTest * test)
|
|||||||
g_object_set (test, "dummy", dummy + 1, NULL);
|
g_object_set (test, "dummy", dummy + 1, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static void
|
||||||
main (int argc, char **argv)
|
test_refcount_properties_2 (void)
|
||||||
{
|
{
|
||||||
gint i;
|
gint i;
|
||||||
GTest *test;
|
GTest *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));
|
|
||||||
|
|
||||||
test = g_object_new (G_TYPE_TEST, NULL);
|
test = g_object_new (G_TYPE_TEST, NULL);
|
||||||
|
|
||||||
g_signal_connect (test, "notify::dummy", G_CALLBACK (dummy_notify), NULL);
|
g_signal_connect (test, "notify::dummy", G_CALLBACK (dummy_notify), NULL);
|
||||||
|
g_assert_cmpint (count, ==, test->dummy);
|
||||||
|
|
||||||
g_assert (count == test->dummy);
|
for (i = 0; i < 1000000; i++)
|
||||||
|
{
|
||||||
for (i=0; i<1000000; i++) {
|
|
||||||
my_test_do_property (test);
|
my_test_do_property (test);
|
||||||
}
|
}
|
||||||
|
g_assert_cmpint (count, ==, test->dummy);
|
||||||
g_assert (count == test->dummy);
|
|
||||||
|
|
||||||
g_object_unref (test);
|
g_object_unref (test);
|
||||||
|
}
|
||||||
return 0;
|
|
||||||
|
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-2", test_refcount_properties_2);
|
||||||
|
|
||||||
|
return g_test_run ();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user