From: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx> This tests queue_destroy from queue_foreach callback. --- v2: Fix patch 4/5: queue_find cannot be used for entries nodes. unit/test-queue.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/unit/test-queue.c b/unit/test-queue.c index 7c6d2ad..55273e3 100644 --- a/unit/test-queue.c +++ b/unit/test-queue.c @@ -58,11 +58,32 @@ static void test_basic(void) queue_destroy(queue, NULL); } +static void foreach_destroy(void *data, void *user_data) +{ + struct queue *queue = user_data; + + queue_destroy(queue, NULL); +} + +static void test_foreach_destroy(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(queue, foreach_destroy, queue); +} + int main(int argc, char *argv[]) { g_test_init(&argc, &argv, NULL); g_test_add_func("/queue/basic", test_basic); + g_test_add_func("/queue/foreach_destroy", test_foreach_destroy); return g_test_run(); } -- 1.9.0 -- 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