source: trunk/poppler/expat-1.95.8/tests/minicheck.h @ 14

Last change on this file since 14 was 2, checked in by Eugene Romanenko, 16 years ago

First import

File size: 1.7 KB
Line 
1/* Miniature re-implementation of the "check" library.
2 *
3 * This is intended to support just enough of check to run the Expat
4 * tests.  This interface is based entirely on the portion of the
5 * check library being used.
6 *
7 * This is *source* compatible, but not necessary *link* compatible.
8 */
9
10#define CK_NOFORK 0
11#define CK_FORK   1
12
13#define CK_SILENT  0
14#define CK_NORMAL  1
15#define CK_VERBOSE 2
16
17#define START_TEST(testname) static void testname(void) {
18#define END_TEST }
19
20#define fail(msg)  _fail_unless(0, __FILE__, __LINE__, msg)
21
22typedef void (*tcase_setup_function)(void);
23typedef void (*tcase_teardown_function)(void);
24typedef void (*tcase_test_function)(void);
25
26typedef struct SRunner SRunner;
27typedef struct Suite Suite;
28typedef struct TCase TCase;
29
30struct SRunner {
31    Suite *suite;
32    int forking;
33    int nchecks;
34    int nfailures;
35};
36
37struct Suite {
38    char *name;
39    TCase *tests;
40};
41
42struct TCase {
43    char *name;
44    tcase_setup_function setup;
45    tcase_teardown_function teardown;
46    tcase_test_function *tests;
47    int ntests;
48    int allocated;
49    TCase *next_tcase;
50};
51
52
53/*
54 * Prototypes for the actual implementation.
55 */
56
57void _fail_unless(int condition, const char *file, int line, char *msg);
58Suite *suite_create(char *name);
59TCase *tcase_create(char *name);
60void suite_add_tcase(Suite *suite, TCase *tc);
61void tcase_add_checked_fixture(TCase *,
62                               tcase_setup_function,
63                               tcase_teardown_function);
64void tcase_add_test(TCase *tc, tcase_test_function test);
65SRunner *srunner_create(Suite *suite);
66void srunner_set_fork_status(SRunner *runner, int forking);
67void srunner_run_all(SRunner *runner, int verbosity);
68int srunner_ntests_failed(SRunner *runner);
69void srunner_free(SRunner *runner);
Note: See TracBrowser for help on using the repository browser.