From 29179fc15a1d085299601267fe0bc9c6be5dfa1c Mon Sep 17 00:00:00 2001 From: sanine Date: Mon, 4 Apr 2022 13:17:30 -0500 Subject: implement heterogenous queue test --- tests/mock_queue.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'tests/mock_queue.c') diff --git a/tests/mock_queue.c b/tests/mock_queue.c index e9527b2..269d462 100644 --- a/tests/mock_queue.c +++ b/tests/mock_queue.c @@ -1,5 +1,5 @@ #include -#include +#include #include "lily-test.h" #include "tests.h" @@ -35,3 +35,27 @@ const char* test_mock_enqueue_dequeue_int() { return 0; } + + +const char* test_mock_enqueue_dequeue_heterogenous() +{ + lily_mock_queue_t *q = lily_queue_create(); + + lily_enqueue(q, int, 2); + lily_enqueue(q, lily_mock_queue_t *, q); + lily_enqueue(q, const char *, "hello, world!"); + + int n; + lily_dequeue(q, int, &n); + if (n != 2) return "dequeued incorrect int value"; + lily_mock_queue_t *p; + lily_dequeue(q, lily_mock_queue_t *, &p); + if (p != q) return "dequeued incorrect pointer value"; + const char *str; + lily_dequeue(q, const char *, &str); + if (strcmp(str, "hello, world!") != 0) return "dequeued incorrect string value"; + + lily_queue_destroy(q); + + return 0; +} -- cgit v1.2.1