Next: , Previous: Tutorial, Up: Tutorial



3.1 How to Write a Test

Test writing using Check is very simple. The file in which the checks are defined must include check.h as so:

     
     #include <check.h>

The basic unit test looks as follows:

     
     START_TEST (test_name)
     {
       /* unit test code */
     }
     END_TEST

The START_TEST/END_TEST pair are macros that setup basic structures to permit testing. It is a mistake to leave off the END_TEST marker; doing so produces all sorts of strange errors when the check is compiled.