diff options
author | Szymon Janc <szymon.janc@tieto.com> | 2015-01-07 16:50:09 +0100 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2015-01-07 14:05:43 -0200 |
commit | 047c1828aa27e210a013717324e0a1aa64f1d0ca (patch) | |
tree | abb76b7fb2729edc91a219a073266677a6fad055 /unit/test-queue.c | |
parent | 1314a764ce3e5eabbfd03337bb6f4f750c32206b (diff) | |
download | bluez-047c1828aa27e210a013717324e0a1aa64f1d0ca.tar.gz |
unit/test-queue: Add /queue/remove_all test
This test verify that queue_remove_all propertly sets entries count.
Diffstat (limited to 'unit/test-queue.c')
-rw-r--r-- | unit/test-queue.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/unit/test-queue.c b/unit/test-queue.c index cb85605ac..15c79bd18 100644 --- a/unit/test-queue.c +++ b/unit/test-queue.c @@ -214,6 +214,29 @@ static void test_push_after(void) queue_destroy(queue, NULL); } +static bool match_int(const void *a, const void *b) +{ + int i = PTR_TO_INT(a); + int j = PTR_TO_INT(b); + + return i == j; +} + +static void test_remove_all(void) +{ + struct queue *queue; + + queue = queue_new(); + g_assert(queue != NULL); + + g_assert(queue_push_tail(queue, INT_TO_PTR(10))); + + g_assert(queue_remove_all(queue, match_int, INT_TO_PTR(10), NULL) == 1); + g_assert(queue_isempty(queue)); + + queue_destroy(queue, NULL); +} + int main(int argc, char *argv[]) { g_test_init(&argc, &argv, NULL); @@ -226,6 +249,7 @@ int main(int argc, char *argv[]) test_foreach_remove_backward); g_test_add_func("/queue/destroy_remove", test_destroy_remove); g_test_add_func("/queue/push_after", test_push_after); + g_test_add_func("/queue/remove_all", test_remove_all); return g_test_run(); } |