summaryrefslogtreecommitdiff
path: root/README.md
blob: 4d73a7b83b0a85feae7526afcea91aa44b28259b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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