-
Notifications
You must be signed in to change notification settings - Fork 0
/
EvilUnit_design.txt
24 lines (15 loc) · 1.61 KB
/
EvilUnit_design.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
This library is intended to reduce the labour involved in writing test cases for C.
1/ The implementation is C89. It compiles cleanly under gcc and clang, will check MSVC at some point.
2/ Tests will self-install. There is no need to write a function prototype elsewhere, or to register the test in a suite somewhere.
3/ Easy to use in existing projects. Specifically, no external dependencies and an easy compilation model.
The premise is to write a set of related test function using approximately familiar syntax, MODULE(foobar){...}. Each module is compiled to a single external function, called evilunit_node_something, which allows functions within the library to traverse the graph of test cases. Provided one file is marked "main", or "root", to provide a starting point, control can be applied to how the test modules are executed. At present, a depth first search from the root node creates a set of test modules which are executed leaf first, sequentially, avoiding running the same test twice.
There is a choice to be made between header-only and header + source.
Header + source:
Faster compilation
Wholly opaque datastructures
Header disappears entirely under the preprocessor
Header only:
Easier to integrate with build systems
Will emit a warning if #included, but the MODULE(){} construct is not used
As far as the implementation of this library is concerned, it is better to be header + source. As far as the clients are concerned, it is easier to have a single file on the include path.
Previously, this was header + source. Recently this has changed to header-only. The EvilUnit.c file contains self-test code only.