Adding Tests - gavinfielder/pft GitHub Wiki
Tests are located in unit_tests.c. They look like this:
You can add your own tests to unit_tests.c, following the same format. You do not need to do anything except write the function in this file and re-make. The new tests will be included in the test index and can be queried the same way.
Valid unit tests have the prototype
int foo(void)
and (normally) return the value returned by a call to the test
function, which has the prototype:
int test(const char *fmt, ...)
How it works
The Makefile creates two copies of the unit test, one that replaces test
with ft_printf
, and one that replaces test
with printf
. Running the test compares the output and return value of these two functions.
nocrash
tests
Tests that start with nocrash
are specially handled by tester. They will automatically pass as long as ft_printf does not crash.