mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-01 05:13:06 +02:00
Add tests for new GAsyncQueue api
https://bugzilla.gnome.org/show_bug.cgi?id=751160
This commit is contained in:
parent
b662c6f09f
commit
26d8792710
@ -220,6 +220,52 @@ test_async_queue_timed (void)
|
|||||||
g_async_queue_unref (q);
|
g_async_queue_unref (q);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_async_queue_remove (void)
|
||||||
|
{
|
||||||
|
GAsyncQueue *q;
|
||||||
|
|
||||||
|
q = g_async_queue_new ();
|
||||||
|
|
||||||
|
g_async_queue_push (q, GINT_TO_POINTER (10));
|
||||||
|
g_async_queue_push (q, GINT_TO_POINTER (2));
|
||||||
|
g_async_queue_push (q, GINT_TO_POINTER (7));
|
||||||
|
g_async_queue_push (q, GINT_TO_POINTER (1));
|
||||||
|
|
||||||
|
g_async_queue_remove (q, GINT_TO_POINTER (7));
|
||||||
|
|
||||||
|
g_assert_cmpint (GPOINTER_TO_INT (g_async_queue_pop (q)), ==, 10);
|
||||||
|
g_assert_cmpint (GPOINTER_TO_INT (g_async_queue_pop (q)), ==, 2);
|
||||||
|
g_assert_cmpint (GPOINTER_TO_INT (g_async_queue_pop (q)), ==, 1);
|
||||||
|
|
||||||
|
g_assert (g_async_queue_try_pop (q) == NULL);
|
||||||
|
|
||||||
|
g_async_queue_unref (q);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_async_queue_push_front (void)
|
||||||
|
{
|
||||||
|
GAsyncQueue *q;
|
||||||
|
|
||||||
|
q = g_async_queue_new ();
|
||||||
|
|
||||||
|
g_async_queue_push (q, GINT_TO_POINTER (10));
|
||||||
|
g_async_queue_push (q, GINT_TO_POINTER (2));
|
||||||
|
g_async_queue_push (q, GINT_TO_POINTER (7));
|
||||||
|
|
||||||
|
g_async_queue_push_front (q, GINT_TO_POINTER (1));
|
||||||
|
|
||||||
|
g_assert_cmpint (GPOINTER_TO_INT (g_async_queue_pop (q)), ==, 1);
|
||||||
|
g_assert_cmpint (GPOINTER_TO_INT (g_async_queue_pop (q)), ==, 10);
|
||||||
|
g_assert_cmpint (GPOINTER_TO_INT (g_async_queue_pop (q)), ==, 2);
|
||||||
|
g_assert_cmpint (GPOINTER_TO_INT (g_async_queue_pop (q)), ==, 7);
|
||||||
|
|
||||||
|
g_assert (g_async_queue_try_pop (q) == NULL);
|
||||||
|
|
||||||
|
g_async_queue_unref (q);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@ -229,6 +275,8 @@ main (int argc, char *argv[])
|
|||||||
g_test_add_func ("/asyncqueue/destroy", test_async_queue_destroy);
|
g_test_add_func ("/asyncqueue/destroy", test_async_queue_destroy);
|
||||||
g_test_add_func ("/asyncqueue/threads", test_async_queue_threads);
|
g_test_add_func ("/asyncqueue/threads", test_async_queue_threads);
|
||||||
g_test_add_func ("/asyncqueue/timed", test_async_queue_timed);
|
g_test_add_func ("/asyncqueue/timed", test_async_queue_timed);
|
||||||
|
g_test_add_func ("/asyncqueue/remove", test_async_queue_remove);
|
||||||
|
g_test_add_func ("/asyncqueue/push_front", test_async_queue_push_front);
|
||||||
|
|
||||||
return g_test_run ();
|
return g_test_run ();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user