diff options
author | sanine <sanine.not@pm.me> | 2022-04-04 12:39:36 -0500 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2022-04-04 12:39:36 -0500 |
commit | c4619e22d571bffa75ab033fceda7915c676f90d (patch) | |
tree | 0cd8adba7f52335c147d83847232b043b6f39666 /tests | |
parent | abe324281121925be29c98f32d19a187a7e3f53f (diff) |
add basic mock queue + test
Diffstat (limited to 'tests')
-rw-r--r-- | tests/main.c | 2 | ||||
-rw-r--r-- | tests/mock_queue.c | 37 | ||||
-rw-r--r-- | tests/tests.h | 4 |
3 files changed, 43 insertions, 0 deletions
diff --git a/tests/main.c b/tests/main.c index 3c94cf7..f8e272f 100644 --- a/tests/main.c +++ b/tests/main.c @@ -20,6 +20,8 @@ int main() run_test(test_assert_ptr_not_equal); run_test(test_assert_int_equal); run_test(test_assert_int_not_equal); + + run_test(test_mock_enqueue_dequeue_int); return 0; } diff --git a/tests/mock_queue.c b/tests/mock_queue.c new file mode 100644 index 0000000..e9527b2 --- /dev/null +++ b/tests/mock_queue.c @@ -0,0 +1,37 @@ +#include <stdio.h> +#include <stdlib.h> + +#include "lily-test.h" +#include "tests.h" + + +const char* test_mock_enqueue_dequeue_int() { + lily_mock_queue_t *q = lily_queue_create(); + + /* enqueue A259482, for no particular reason */ + lily_enqueue(q, int, 2); + lily_enqueue(q, int, 6); + lily_enqueue(q, int, 44); + int n = 2014; + lily_enqueue(q, int, n); + + lily_dequeue(q, int, &n); + if (n != 2) return "dequeued incorrect first value"; + lily_dequeue(q, int, &n); + + /* queue next value after already popping */ + lily_enqueue(q, long, 1651377); + + if (n != 6) return "dequeued incorrect second value"; + lily_dequeue(q, int, &n); + if (n != 44) return "dequeued incorrect third value"; + lily_dequeue(q, int, &n); + if (n != 2014) return "dequeued incorrect fourth value"; + long m; + lily_dequeue(q, long, &m); + if (m != 1651377) return "dequeued incorrect fifth value"; + + lily_queue_destroy(q); + + return 0; +} diff --git a/tests/tests.h b/tests/tests.h index 995beaf..266cc04 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -17,4 +17,8 @@ const char* test_assert_ptr_equal(); const char* test_assert_ptr_not_equal(); const char* test_assert_int_equal(); const char* test_assert_int_not_equal(); + +const char* test_mock_enqueue_dequeue_int(); +const char* test_mock_enqueue_dequeue_heterogenous(); + #endif |