mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-29 11:00:02 +01: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);
|
||||
}
|
||||
|
||||
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
|
||||
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/threads", test_async_queue_threads);
|
||||
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 ();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user