1 /* Miniature re-implementation of the "check" library.
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.
7 * This is *source* compatible, but not necessary *link* compatible.
21 /* Workaround for Microsoft's compiler and Tru64 Unix systems where the
22 C compiler has a working __func__, but the C++ compiler only has a
23 working __FUNCTION__. This could be fixed in configure.in, but it's
24 not worth it right now. */
25 #if defined (_MSC_VER) || (defined(__osf__) && defined(__cplusplus))
26 #define __func__ __FUNCTION__
29 /* ISO C90 does not support '__func__' predefined identifier */
30 #if defined(__STDC_VERSION__) && (__STDC_VERSION__ < 199901)
31 # define __func__ "(unknown)"
34 #define START_TEST(testname) static void testname(void) { \
35 _check_set_test_info(__func__, __FILE__, __LINE__); \
39 #define fail(msg) _fail_unless(0, __FILE__, __LINE__, msg)
41 typedef void (*tcase_setup_function)(void);
42 typedef void (*tcase_teardown_function)(void);
43 typedef void (*tcase_test_function)(void);
45 typedef struct SRunner SRunner;
46 typedef struct Suite Suite;
47 typedef struct TCase TCase;
62 tcase_setup_function setup;
63 tcase_teardown_function teardown;
64 tcase_test_function *tests;
71 /* Internal helper. */
72 void _check_set_test_info(char const *function,
73 char const *filename, int lineno);
77 * Prototypes for the actual implementation.
80 void _fail_unless(int condition, const char *file, int line, const char *msg);
81 Suite *suite_create(const char *name);
82 TCase *tcase_create(const char *name);
83 void suite_add_tcase(Suite *suite, TCase *tc);
84 void tcase_add_checked_fixture(TCase *,
86 tcase_teardown_function);
87 void tcase_add_test(TCase *tc, tcase_test_function test);
88 SRunner *srunner_create(Suite *suite);
89 void srunner_run_all(SRunner *runner, int verbosity);
90 int srunner_ntests_failed(SRunner *runner);
91 void srunner_free(SRunner *runner);