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 *name,const char *fmt, ...);
28 xbt_test_suite_t xbt_test_suite_by_name(const char *name,const char *fmt, ...);
29 void xbt_test_suite_dump (xbt_test_suite_t suite);
30 void xbt_test_suite_push (xbt_test_suite_t suite,
31 ts_test_cb_t func, const char *fmt, ...);
33 int xbt_test_run (void);
37 void _xbt_test_add(xbt_test_unit_t u, const char*file,int line, const char *fmt, ...)_XBT_GNUC_PRINTF(4,5);
38 #define xbt_test_add0(fmt) _xbt_test_add(_unit,__FILE__,__LINE__,fmt)
39 #define xbt_test_add1(fmt,a) _xbt_test_add(_unit,__FILE__,__LINE__,fmt,a)
40 #define xbt_test_add2(fmt,a,b) _xbt_test_add(_unit,__FILE__,__LINE__,fmt,a,b)
41 #define xbt_test_add3(fmt,a,b,c) _xbt_test_add(_unit,__FILE__,__LINE__,fmt,a,b,c)
42 #define xbt_test_add4(fmt,a,b,c,d) _xbt_test_add(_unit,__FILE__,__LINE__,fmt,a,b,c,d)
43 #define xbt_test_add5(fmt,a,b,c,d,e) _xbt_test_add(_unit,__FILE__,__LINE__,fmt,a,b,c,d,e)
45 void _xbt_test_fail(xbt_test_unit_t u, const char*file,int line, const char *fmt, ...) _XBT_GNUC_PRINTF(4,5);
46 #define xbt_test_fail0(fmt) _xbt_test_fail(_unit, __FILE__, __LINE__, fmt)
47 #define xbt_test_fail1(fmt,a) _xbt_test_fail(_unit, __FILE__, __LINE__, fmt,a)
48 #define xbt_test_fail2(fmt,a,b) _xbt_test_fail(_unit, __FILE__, __LINE__, fmt,a,b)
49 #define xbt_test_fail3(fmt,a,b,c) _xbt_test_fail(_unit, __FILE__, __LINE__, fmt,a,b,c)
50 #define xbt_test_fail4(fmt,a,b,c,d) _xbt_test_fail(_unit, __FILE__, __LINE__, fmt,a,b,c,d)
51 #define xbt_test_fail5(fmt,a,b,c,d,e) _xbt_test_fail(_unit, __FILE__, __LINE__, fmt,a,b,c,d,e)
53 void _xbt_test_log (xbt_test_unit_t u, const char*file,int line, const char *fmt, ...)_XBT_GNUC_PRINTF(4,5);
54 #define xbt_test_log0(fmt) _xbt_test_log(_unit, __FILE__, __LINE__, fmt)
55 #define xbt_test_log1(fmt,a) _xbt_test_log(_unit, __FILE__, __LINE__, fmt,a)
56 #define xbt_test_log2(fmt,a,b) _xbt_test_log(_unit, __FILE__, __LINE__, fmt,a,b)
57 #define xbt_test_log3(fmt,a,b,c) _xbt_test_log(_unit, __FILE__, __LINE__, fmt,a,b,c)
58 #define xbt_test_log4(fmt,a,b,c,d) _xbt_test_log(_unit, __FILE__, __LINE__, fmt,a,b,c,d)
59 #define xbt_test_log5(fmt,a,b,c,d,e) _xbt_test_log(_unit, __FILE__, __LINE__, fmt,a,b,c,d,e)
61 void _xbt_test_expect_failure(xbt_test_unit_t unit);
62 #define xbt_test_expect_failure() _xbt_test_expect_failure(_unit)
64 void _xbt_test_skip(xbt_test_unit_t unit);
65 #define xbt_test_skip() _xbt_test_skip(_unit)
67 /* test suite short-cut macros */
68 #define XBT_TEST_UNIT(name,func,title) \
69 void func(xbt_test_unit_t _unit); /*prototype*/ \
70 void func(xbt_test_unit_t _unit)