summaryrefslogtreecommitdiff
path: root/tests/mock_queue.c
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2022-04-04 16:42:05 -0500
committersanine <sanine.not@pm.me>2022-04-04 16:42:05 -0500
commitf133f0a424db19dd3263794e8fa71ea920ef3ea9 (patch)
tree178d3fc672acd38ff7c26aa2238a0e7507b81f0e /tests/mock_queue.c
parent2cef2d4e0bb490f8e5002e47368bac8e89dbeb88 (diff)
add lily_mock_t basic functionality
Diffstat (limited to 'tests/mock_queue.c')
-rw-r--r--tests/mock_queue.c42
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;
+}