diff options
author | sanine <sanine.not@pm.me> | 2021-09-28 22:49:17 -0500 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2021-09-28 22:51:52 -0500 |
commit | d356c9bb873092e9d8ed53ee5f15a560accbf5bb (patch) | |
tree | 0be0d855bf0b5819e88276fa1fc2cc04f58f8c16 /src | |
parent | 0e8f26743214b903f66eb732e4a8c151213d61e1 (diff) |
add multiple data types test and move mock queue cleanup and init into tests_main.c
Diffstat (limited to 'src')
-rw-r--r-- | src/test/mock_queue_tests.c | 28 | ||||
-rw-r--r-- | src/test/test_main.c | 4 |
2 files changed, 31 insertions, 1 deletions
diff --git a/src/test/mock_queue_tests.c b/src/test/mock_queue_tests.c index 004444c..92d7cdf 100644 --- a/src/test/mock_queue_tests.c +++ b/src/test/mock_queue_tests.c @@ -1,19 +1,22 @@ #include "test/minunit.h" #include "test/mock_queue.h" +#include <stdbool.h> + mu_test mock_queue_int(); mu_test mock_queue_int_seq(); mu_test mock_queue_pop_multi(); mu_test mock_queue_clean_finish(); +mu_test mock_queue_push_multidata(); void mock_queue_tests() { - mock_queue_init(); mu_run_test("push and pop integer to mock queue", mock_queue_int); mu_run_test("push and pop integer sequence", mock_queue_int_seq); mu_run_test("pop multiple times with empty queue", mock_queue_pop_multi); mu_run_test("clean up mock queue", mock_queue_clean_finish); + mu_run_test("push and pop multiple data types", mock_queue_push_multidata); } @@ -99,3 +102,26 @@ mu_test mock_queue_clean_finish() return 0; } + + +mu_test mock_queue_push_multidata() +{ + mock_queue_cleanup(); + mu_assert_equal(mock_queue_len(), 0); + + mock_queue(const char *, "hello, world!"); + mock_queue(bool, true); + mock_queue(float, 4.20f); + + mu_assert_equal(mock_queue_len(), 3); + + mu_assert_streq(mock_front(const char *), "hello, world!"); + mock_pop(); + mu_assert_equal(mock_front(bool), true); + mock_pop(); + mu_assert_equal(mock_front(float), 4.20f); + mock_pop(); + + mu_assert_equal(mock_queue_len(), 0); + return 0; +} diff --git a/src/test/test_main.c b/src/test/test_main.c index a4e776a..a3763be 100644 --- a/src/test/test_main.c +++ b/src/test/test_main.c @@ -1,14 +1,18 @@ #include "minunit.h" #include "suites.h" +#include "mock_queue.h" int tests_run = 0; int tests_failed = 0; int main() { + mock_queue_init(); printf("~~~~~~~~ running tests ~~~~~~~~\n\n"); RUN_TESTS; printf("~~~~~~~~~ tests done ~~~~~~~~~~\n\n"); mu_tests_finished(); + + mock_queue_cleanup(); } |