From b834bab635d762cf5d9f7b6c0e6795de3f4cbeb8 Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Wed, 13 Dec 2017 20:04:06 +0100 Subject: [PATCH] Add more tests. --- tests/test-mprioqueue.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/test-mprioqueue.c b/tests/test-mprioqueue.c index a8a2d25a..fb699073 100644 --- a/tests/test-mprioqueue.c +++ b/tests/test-mprioqueue.c @@ -43,7 +43,33 @@ static void test1(void) int_pqueue_clear(p); } +static void test2(void) +{ + int_pqueue_t p; + int_pqueue_init(p); + for(int i = -100; i < 100; i++) { + int_pqueue_push(p, i); + } + assert (int_pqueue_size(p) == 200); + for(int i = -200; i < -100; i++) { + int_pqueue_push(p, i); + } + assert (int_pqueue_size(p) == 300); + for(int i = 100; i < 200; i++) { + int_pqueue_push(p, i); + } + assert (int_pqueue_size(p) == 400); + for(int i = -200; i < 200; i++) { + int x; + int_pqueue_pop(&x, p); + assert (x == i); + } + + int_pqueue_clear(p); +} + int main(void) { test1(); + test2(); }