summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
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