README
1Experimental unittest utilities for tests at the C level.
2
3Using the testing utilities should be straightforward. Generally, a
4test suite looks like this:
5
6#include "sscm-test.h"
7
8#if 0
9/* Some testing-specific utilities are found in this file. */
10#include "utils.c"
11#endif
12
13
14/* Test cases are declared like this. */
15TST_CASE("example")
16{
17 /* TST_COND (condition, brief explanation); Optionally enclose in
18 * TST_ASSERT() if carrying on upon failure is undesirable. */
19 TST_COND(1, "context");
20
21 /* TST_EQ_<type> (expected, actual, brief explanation);
22 * <type> can be one of INT, PTR, STR, FPTR, or OBJ.
23 * For now, equality testers can't be put inside TST_ASSERT(). */
24 TST_EQ_INT(6, 5 + 1, "context 2");
25}
26
27/* The function name is optional. Specifying one can aid in setting
28 * breakpoints in a debugger, but always doing so is a pain
29 * (especially since failed tests report the line number). If
30 * omitted, the function name will be tst_<n> where <n> is the number
31 * of tests preceding this one + 1. */
32TST_CASE(func, "eg 2")
33{
34 /* The body can be empty (not that it's useful though). */
35}
36
37Add the program name to Makefile.am with a -coll suffix attached to
38the name. The main() function will be generated automatically. If
39you absolutely must write main() yourself, define TST_HAVE_MAIN before
40including sscm-test.h. Tests will be executed in the order it appears
41in the source file.
42
43If collect.sh is not to be run on the source file, leave out the -coll
44suffix.
45