[PATCH 1/2] unit/test-queue: Extend /queue/remove_all with NULL data checks

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

 



queue_remove_all should correctly handle NULL data.
---
 unit/test-queue.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/unit/test-queue.c b/unit/test-queue.c
index 15c79bd..12319b0 100644
--- a/unit/test-queue.c
+++ b/unit/test-queue.c
@@ -222,6 +222,11 @@ static bool match_int(const void *a, const void *b)
 	return i == j;
 }
 
+static bool match_ptr(const void *a, const void *b)
+{
+	return a == b;
+}
+
 static void test_remove_all(void)
 {
 	struct queue *queue;
@@ -234,6 +239,14 @@ static void test_remove_all(void)
 	g_assert(queue_remove_all(queue, match_int, INT_TO_PTR(10), NULL) == 1);
 	g_assert(queue_isempty(queue));
 
+	g_assert(queue_push_tail(queue, NULL));
+	g_assert(queue_remove_all(queue, match_ptr, NULL, NULL) == 1);
+	g_assert(queue_isempty(queue));
+
+	g_assert(queue_push_tail(queue, UINT_TO_PTR(0)));
+	g_assert(queue_remove_all(queue, match_int, UINT_TO_PTR(0), NULL) == 1);
+	g_assert(queue_isempty(queue));
+
 	queue_destroy(queue, NULL);
 }
 
-- 
1.9.1

--
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