The test files contain collections of unit tests associated with a function. Each test file is named function-name.c, where function-name is the name of the function under testing with underscores replaced with dashes.
For example, the source file containing unit tests for the pdf_stm_new function would be called stm-new.c.
A minimal test file looks like this:
/*
* Include the check library.
*/
#include <check.h>
/*
* Test: FUNCTION_NAME_NNN
* Description:
* Description of the test. Can be of several lines long,
* indenting the text like this.
* Success conditions:
* A list of success conditions.
* Data files:
* A list of data files used in this test.
*/
START_TEST(FUNCTION_NAME_NNN)
{
/* Check a condition. One of several types of check
available in the check library.
*/
fail_if(0 == 1);
}
END_TEST
/*
* Provide this function to gather all the tests together.
*/
TCase* test_FUNCTION_NAME (void)
{
TCase* tc = tcase_create ("FUNCTION_NAME");
tcase_add_test(tc, FUNCTION_NAME_NNN);
return tc;
}
Note the test_FUNCTION_NAME function. It is the function called
by the test driver in order to perform all the tests implemented in
the test file.
Note also that the comments heading tests are written in a fixed format to allow the build-aux/generate-tsd.pl script to generate the bulk of the Test Specification Document from the comments.