~ubuntu-branches/ubuntu/hardy/sigscheme/hardy-proposed

« back to all changes in this revision

Viewing changes to test-c/README

  • Committer: Bazaar Package Importer
  • Author(s): NIIBE Yutaka
  • Date: 2007-01-29 15:31:24 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070129153124-j5fcqyrwcfbczma7
Tags: 0.7.4-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
This directory is existing for unit testing for C. See doc/test-c.txt for
2
 
further information.
 
1
Experimental unittest utilities for tests at the C level.
 
2
 
 
3
Using the testing utilities should be straightforward.  Generally, a
 
4
test 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. */
 
15
TST_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. */
 
32
TST_CASE(func, "eg 2")
 
33
{
 
34
    /* The body can be empty (not that it's useful though). */
 
35
}
 
36
 
 
37
Add the program name to Makefile.am with a -coll suffix attached to
 
38
the name.  The main() function will be generated automatically.  If
 
39
you absolutely must write main() yourself, define TST_HAVE_MAIN before
 
40
including sscm-test.h.  Tests will be executed in the order it appears
 
41
in the source file.
 
42
 
 
43
If collect.sh is not to be run on the source file, leave out the -coll
 
44
suffix.