After cloning, run sudo make install
to install the header.
You can run sudo make uninstall
to remove it later.
-
Add the following lines to your Makefile:
.PHONY: test test: test.c $(OBJ) @$(CC) $(CFLAGS) -DTEST -o _temp $^ @echo 'Running tests...' @./_temp @rm -f ./_temp
Modify the target name (
test
) and testing source file (test.c
), as well as the other values, as appropriate. -
#include
the headersimple_test.h
. Surround withextern "C" { ... }
if using C++. -
In your testing source file, define a function
void test_main(void)
from which you call all your test functions or invoke other subroutines to call them.
You can use the following testing functions.
Testing Function | Notes |
---|---|
assert_equal(a, b) |
requires that a and b are primitive-comparable. |
assert_true(x) |
requires that x is boolean-like. |
assert_false(x) |
requires that x is boolean-like. |