summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2022-04-04 17:00:34 -0500
committersanine <sanine.not@pm.me>2022-04-04 17:00:34 -0500
commite61a3232f1384876044ab8c0328f42e60d450574 (patch)
tree0624c96438cde178f2a3ae9b087db833bca06aad
parentd7f946eecf27448c19f84ed69024840af56436ed (diff)
add enqueue/dequeue lily_mock_t macros
-rw-r--r--README.md42
-rw-r--r--lily-test.h9
2 files changed, 49 insertions, 2 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..4d73a7b
--- /dev/null
+++ b/README.md
@@ -0,0 +1,42 @@
+lily
+====
+
+**lily** is a testing library for C. It provides both basic assertions as well as mocking.
+
+To incorporate lily into a project, just copy `lily-test.h` and `lily-test.c` into your
+source code.
+
+
+usage
+-----
+
+The function `lily_init()` must be called exactly once before any other lily
+functions may be called.
+
+Tests are simply functions with the signature `void ()`. Each test can contain
+any of the following assertion messages:
+
+* `lily_assert_true(bool)`
+* `lily_assert_false(bool)`
+* `lily_assert_not_null(void *)`
+* `lily_assert_null(void *)`
+* `lily_assert_ptr_equal(void *, void *)`
+* `lily_assert_ptr_not_equal(void *, void *)`
+* `lily_assert_int_equal(int, int)`
+* `lily_assert_int_not_equal(int, int)`
+* `lily_assert_float_equal(float, float, float epsilon)`
+* `lily_assert_float_not_equal(float, float, float epsilon)`
+* `lily_assert_string_equal(char *, char *)`
+* `lily_assert_string_not_equal(char *, char *)`
+* `lily_assert_memory_equal(void *, void *, size_t size)`
+* `lily_assert_memory_not_equal(void *, void *, size_t size)`
+
+Tests are run via the macro `lily_run_test(test_func)`. A test suite is simply a `void ()`
+function that runs some tests. Suites can be called via the macro `lily_run_suite(suite_func)`.
+
+A small script, called `prepare-tests.sh` is provided. It will automatically scan
+the given source root for all files matching `*.test.c` and qenerate a header file,
+main function, and Makefile to run all of the functions matching `void ()` in those
+test files. (If you want a utility function or something, just make it `static`).
+This script relies on POSIX utilities -- sorry, Windows users. :l
+
diff --git a/lily-test.h b/lily-test.h
index bf0bbae..7a46cd9 100644
--- a/lily-test.h
+++ b/lily-test.h
@@ -154,15 +154,20 @@ typedef struct lily_mock_t {
lily_mock_t * lily_mock_create();
void lily_mock_destroy(lily_mock_t *m);
-#define lily_mock_call(m, args) \
+#define lily_mock_call(m, args) \
_lily_mock_call(m, args, LILY_NARGS(args))
void _lily_mock_call(lily_mock_t *m, struct lily_mock_arg_t *args, size_t n_args);
-#define lily_get_call(m, args, call_num) \
+#define lily_get_call(m, args, call_num) \
_lily_get_call(m, args, LILY_NARGS(args), call_num)
void _lily_get_call(lily_mock_t *m,
struct lily_mock_arg_t *args,
size_t n_args,
unsigned int call_num);
+#define lily_store_value(m, type, value) \
+ lily_enqueue(m->values, type, value)
+#define lily_get_value(m, type, ptr) \
+ lily_dequeue(m->values, type, ptr)
+
#endif