3 /* cunit - A little C Unit facility */
5 /* Copyright (c) 2005 Martin Quinson. All rights reserved. */
7 /* This program is free software; you can redistribute it and/or modify it
8 * under the terms of the license (GNU LGPL) which comes with this package. */
10 /* This is partially inspirated from the OSSP ts (Test Suite Library) */
15 #include "xbt/sysdep.h" /* XBT_GNU_PRINTF */
17 /* test suite object type */
18 typedef struct s_xbt_test_suite *xbt_test_suite_t;
20 /* test object type */
21 typedef struct s_xbt_test_unit *xbt_test_unit_t;
23 /* test callback function type */
24 typedef void (*ts_test_cb_t)(xbt_test_unit_t);
26 /* test suite operations */
27 xbt_test_suite_t xbt_test_suite_new (const char *fmt, ...);
28 void xbt_test_suite_dump (xbt_test_suite_t suite);
29 void xbt_test_suite_push (xbt_test_suite_t suite,
30 ts_test_cb_t func, const char *fmt, ...);
32 int xbt_test_run (void);
36 void _xbt_test(xbt_test_unit_t u, const char*file,int line, const char *fmt, ...)_XBT_GNUC_PRINTF(4,5);
37 #define xbt_test0(fmt) _xbt_test(_unit,__FILE__,__LINE__,fmt)
38 #define xbt_test1(fmt,a) _xbt_test(_unit,__FILE__,__LINE__,fmt,a)
39 #define xbt_test2(fmt,a,b) _xbt_test(_unit,__FILE__,__LINE__,fmt,a,b)
40 #define xbt_test3(fmt,a,b,c) _xbt_test(_unit,__FILE__,__LINE__,fmt,a,b,c)
41 #define xbt_test4(fmt,a,b,c,d) _xbt_test(_unit,__FILE__,__LINE__,fmt,a,b,c,d)
42 #define xbt_test5(fmt,a,b,c,d,e) _xbt_test(_unit,__FILE__,__LINE__,fmt,a,b,c,d,e)
44 void _xbt_test_fail(xbt_test_unit_t u, const char*file,int line, const char *fmt, ...) _XBT_GNUC_PRINTF(4,5);
45 #define xbt_test_fail0(fmt) _xbt_test_fail(_unit, __FILE__, __LINE__, fmt)
46 #define xbt_test_fail1(fmt,a) _xbt_test_fail(_unit, __FILE__, __LINE__, fmt,a)
47 #define xbt_test_fail2(fmt,a,b) _xbt_test_fail(_unit, __FILE__, __LINE__, fmt,a,b)
48 #define xbt_test_fail3(fmt,a,b,c) _xbt_test_fail(_unit, __FILE__, __LINE__, fmt,a,b,c)
49 #define xbt_test_fail4(fmt,a,b,c,d) _xbt_test_fail(_unit, __FILE__, __LINE__, fmt,a,b,c,d)
50 #define xbt_test_fail5(fmt,a,b,c,d,e) _xbt_test_fail(_unit, __FILE__, __LINE__, fmt,a,b,c,d,e)
52 void _xbt_test_log (xbt_test_unit_t u, const char*file,int line, const char *fmt, ...)_XBT_GNUC_PRINTF(4,5);
53 #define xbt_test_log0(fmt) _xbt_test_log(_unit, __FILE__, __LINE__, fmt)
54 #define xbt_test_log1(fmt,a) _xbt_test_log(_unit, __FILE__, __LINE__, fmt,a)
55 #define xbt_test_log2(fmt,a,b) _xbt_test_log(_unit, __FILE__, __LINE__, fmt,a,b)
56 #define xbt_test_log3(fmt,a,b,c) _xbt_test_log(_unit, __FILE__, __LINE__, fmt,a,b,c)
57 #define xbt_test_log4(fmt,a,b,c,d) _xbt_test_log(_unit, __FILE__, __LINE__, fmt,a,b,c,d)
58 #define xbt_test_log5(fmt,a,b,c,d,e) _xbt_test_log(_unit, __FILE__, __LINE__, fmt,a,b,c,d,e)
60 void _xbt_test_expect_failure(xbt_test_unit_t unit);
61 #define xbt_test_expect_failure() _xbt_test_expect_failure(_unit)
63 void _xbt_test_skip(xbt_test_unit_t unit);
64 #define xbt_test_skip() _xbt_test_skip(_unit)
66 /* test suite short-cut macros */
67 #define XBT_TEST_UNIT(name) \
68 static void name(xbt_test_unit_t _unit)