summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzymon Janc <szymon.janc@tieto.com>2015-01-07 17:26:02 +0100
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2015-01-07 20:28:28 -0200
commitb68c03b95d0ec192226eecd352e0057ff365e504 (patch)
tree329e982053d83129bc9a89565e255e3d47beaebb
parent9d1efc47345d2e4b5b6191596c7702ed0c73f03a (diff)
downloadbluez-b68c03b95d0ec192226eecd352e0057ff365e504.tar.gz
unit/test-queue: Extend /queue/remove_all with NULL data checks
queue_remove_all should correctly handle NULL data.
-rw-r--r--unit/test-queue.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/unit/test-queue.c b/unit/test-queue.c
index 15c79bd18..12319b01f 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);
}