[glib] Add tests for new GAsyncQueue api
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Add tests for new GAsyncQueue api
- Date: Mon, 29 Jun 2015 15:21:20 +0000 (UTC)
commit 26d87927109d0758775e5455d4c0a22c1b3f9f75
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Jun 22 11:35:06 2015 -0400
Add tests for new GAsyncQueue api
https://bugzilla.gnome.org/show_bug.cgi?id=751160
glib/tests/asyncqueue.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 48 insertions(+), 0 deletions(-)
---
diff --git a/glib/tests/asyncqueue.c b/glib/tests/asyncqueue.c
index 5ccbb23..4a81d23 100644
--- a/glib/tests/asyncqueue.c
+++ b/glib/tests/asyncqueue.c
@@ -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 ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]