diff options
author | sanine <sanine.not@pm.me> | 2021-09-28 22:38:02 -0500 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2021-09-28 22:38:02 -0500 |
commit | bedf73313c8f19ff1b19217d989b1886c8f809ae (patch) | |
tree | dcc4568d03837d1a3f35d62edf22c47451d62dfd /src/test/mock_queue_tests.c | |
parent | 1895d16f8ad5487db25650c628f4d9eaf8542e80 (diff) |
add mock queue
Diffstat (limited to 'src/test/mock_queue_tests.c')
-rw-r--r-- | src/test/mock_queue_tests.c | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/src/test/mock_queue_tests.c b/src/test/mock_queue_tests.c new file mode 100644 index 0000000..0e208e4 --- /dev/null +++ b/src/test/mock_queue_tests.c @@ -0,0 +1,81 @@ +#include "test/minunit.h" +#include "test/mock_queue.h" + +mu_test mock_queue_int(); +mu_test mock_queue_int_seq(); +mu_test mock_queue_pop_multi(); + + +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_test mock_queue_int() +{ + mock_queue(int, 5); + mu_assert_unequal(mock_queue_len(), 0); + mu_assert_equal(mock_front(int), 5); + + mock_pop(); + + mu_assert_equal(mock_queue_len(), 0); + + return 0; +} + + +mu_test mock_queue_int_seq() +{ + mock_queue(int, 2); + mock_queue(int, 1); + mock_queue(int, 3); + mock_queue(int, 4); + + mu_assert_unequal(mock_queue_len(), 0); + mu_assert_equal(mock_queue_len(), 4); + mu_assert_equal(mock_front(int), 2); + + mock_pop(); + + mu_assert_unequal(mock_queue_len(), 0); + mu_assert_equal(mock_queue_len(), 3); + mu_assert_equal(mock_front(int), 1); + + mock_pop(); + + mu_assert_unequal(mock_queue_len(), 0); + mu_assert_equal(mock_queue_len(), 2); + mu_assert_equal(mock_front(int), 3); + + mock_pop(); + + mu_assert_unequal(mock_queue_len(), 0); + mu_assert_equal(mock_queue_len(), 1); + mu_assert_equal(mock_front(int), 4); + + mock_pop(); + + mu_assert_equal(mock_queue_len(), 0); + + return 0; +} + + +mu_test mock_queue_pop_multi() +{ + mu_assert_equal(mock_queue_len(), 0); + + mock_pop(); + mock_pop(); + mock_pop(); + + mu_assert_equal(mock_queue_len(), 0); + return 0; +} |