[RFC BlueZ 2/2] unit/test-queue: Add /queue/foreach_vargs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx>

---
 unit/test-queue.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/unit/test-queue.c b/unit/test-queue.c
index 5cbe529..445568e 100644
--- a/unit/test-queue.c
+++ b/unit/test-queue.c
@@ -99,6 +99,36 @@ static void test_foreach_remove_all(void)
 	queue_destroy(queue, NULL);
 }
 
+static void foreach_vargs(void *data, va_list *ap)
+{
+	struct queue *queue;
+	unsigned int i;
+	char *s;
+
+	queue = va_arg(ap, struct queue *);
+	g_assert(queue != NULL);
+
+	i = va_arg(ap, unsigned int);
+	g_assert_cmpint(i, ==, 1);
+
+	s = va_arg(ap, char *);
+	g_assert_cmpstr(s, ==, "2");
+}
+
+static void test_foreach_vargs(void)
+{
+	struct queue *queue;
+
+	queue = queue_new();
+	g_assert(queue != NULL);
+
+	queue_push_tail(queue, UINT_TO_PTR(1));
+	queue_push_tail(queue, UINT_TO_PTR(2));
+
+	queue_foreach_vargs(queue, foreach_vargs, queue, 1, "2");
+	queue_destroy(queue, NULL);
+}
+
 int main(int argc, char *argv[])
 {
 	g_test_init(&argc, &argv, NULL);
@@ -106,6 +136,7 @@ int main(int argc, char *argv[])
 	g_test_add_func("/queue/basic", test_basic);
 	g_test_add_func("/queue/foreach_destroy", test_foreach_destroy);
 	g_test_add_func("/queue/foreach_remove_all", test_foreach_remove_all);
+	g_test_add_func("/queue/foreach_vargs", test_foreach_vargs);
 
 	return g_test_run();
 }
-- 
1.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux