summaryrefslogtreecommitdiff
path: root/tests
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
parent2cef2d4e0bb490f8e5002e47368bac8e89dbeb88 (diff)
add lily_mock_t basic functionality
Diffstat (limited to 'tests')
-rw-r--r--tests/main.c1
-rw-r--r--tests/mock_queue.c42
-rw-r--r--tests/tests.h1
3 files changed, 44 insertions, 0 deletions
diff --git a/tests/main.c b/tests/main.c
index f4e634c..84c8c09 100644
--- a/tests/main.c
+++ b/tests/main.c
@@ -24,6 +24,7 @@ int main()
run_test(test_mock_enqueue_dequeue_int);
run_test(test_mock_enqueue_dequeue_heterogenous);
run_test(test_LILY_NARGS);
+ run_test(test_lily_mock_call);
return 0;
}
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;
+}
diff --git a/tests/tests.h b/tests/tests.h
index 39ad153..9584cac 100644
--- a/tests/tests.h
+++ b/tests/tests.h
@@ -21,5 +21,6 @@ const char* test_assert_int_not_equal();
const char* test_mock_enqueue_dequeue_int();
const char* test_mock_enqueue_dequeue_heterogenous();
const char* test_LILY_NARGS();
+const char* test_lily_mock_call();
#endif