summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2022-04-04 13:17:30 -0500
committersanine <sanine.not@pm.me>2022-04-04 13:17:30 -0500
commit29179fc15a1d085299601267fe0bc9c6be5dfa1c (patch)
tree1394a144bd266326e920501e8b9acaa20a126a74 /tests
parent4facafcf702ec54694451d5bdda4f1faff94718d (diff)
implement heterogenous queue test
Diffstat (limited to 'tests')
-rw-r--r--tests/main.c1
-rw-r--r--tests/mock_queue.c26
2 files changed, 26 insertions, 1 deletions
diff --git a/tests/main.c b/tests/main.c
index f8e272f..062e5f8 100644
--- a/tests/main.c
+++ b/tests/main.c
@@ -22,6 +22,7 @@ int main()
run_test(test_assert_int_not_equal);
run_test(test_mock_enqueue_dequeue_int);
+ run_test(test_mock_enqueue_dequeue_heterogenous);
return 0;
}
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 <stdio.h>
-#include <stdlib.h>
+#include <string.h>
#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;
+}