diff options
Diffstat (limited to 'tests/mock_queue.c')
-rw-r--r-- | tests/mock_queue.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/mock_queue.c b/tests/mock_queue.c index 4015c68..b7f852c 100644 --- a/tests/mock_queue.c +++ b/tests/mock_queue.c @@ -76,3 +76,45 @@ const char* test_LILY_NARGS() return 0; } + + +const char* test_lily_mock_call() +{ + lily_mock_t *m = lily_mock_create(); + + int n = 5; + const char *str = "hello, world!"; + lily_queue_t *q; + + struct lily_mock_arg_t args[] = + { { sizeof(int), &n }, + { sizeof(const char *), &str }, + { sizeof(lily_queue_t *), &q }, + }; + + lily_mock_call(m, args); + n = 16; + str = "hi there"; + lily_mock_call(m, args); + + if (m->n_calls != 2) return "incorrect number of calls registered"; + + int k; const char *s; lily_queue_t *p; + struct lily_mock_arg_t get_args[] = + { { sizeof(int), &k }, + { sizeof(const char *), &s }, + { sizeof(lily_queue_t *), &p }, + }; + lily_get_call(m, get_args, 0); + if (k != 5) return "incorrect int argument 0 registered"; + if (strcmp(s, "hello, world!") != 0) return "incorrect string argument 0 registered"; + if (p != q) return "incorrect pointer argument 0 registered"; + + lily_get_call(m, get_args, 1); + if (k != 16) return "incorrect int argument 1 registered"; + if (strcmp(s, "hi there") != 0) return "incorrect string argument 1 registered"; + if (p != q) return "incorrect pointer argument 1 registered"; + + lily_mock_destroy(m); + return 0; +} |