Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove the old crufty navigation bars
[simgrid.git] / include / xbt / cunit.h
1 /* $Id$ */
2
3 /* cunit - A little C Unit facility                                         */
4
5 /* Copyright (c) 2005 Martin Quinson. All rights reserved.                  */
6
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. */
9
10 /* This is partially inspirated from the OSSP ts (Test Suite Library)       */
11
12 #ifndef _XBT_CUNIT_H_
13 #define _XBT_CUNIT_H_
14
15 #include "xbt/sysdep.h"    /* XBT_GNU_PRINTF */
16 #include "xbt/ex.h"
17
18 /* test suite object type */
19 typedef struct s_xbt_test_suite *xbt_test_suite_t;
20
21 /* test object type */
22 typedef struct s_xbt_test_unit *xbt_test_unit_t;
23
24 /* test callback function type */
25 typedef void (*ts_test_cb_t)(void);
26
27 /* test suite operations */
28 xbt_test_suite_t xbt_test_suite_new  (const char *name,const char *fmt, ...);
29 xbt_test_suite_t xbt_test_suite_by_name(const char *name,const char *fmt, ...);
30 void             xbt_test_suite_dump (xbt_test_suite_t suite);
31 void             xbt_test_suite_push (xbt_test_suite_t suite, 
32                                       ts_test_cb_t func, const char *fmt, ...);
33
34
35 int xbt_test_run  (void);
36
37 /* test operations */
38 void    _xbt_test_add(const char*file,int line, const char *fmt, ...)_XBT_GNUC_PRINTF(3,4);
39 #define xbt_test_add0(fmt)           _xbt_test_add(__FILE__,__LINE__,fmt)
40 #define xbt_test_add1(fmt,a)         _xbt_test_add(__FILE__,__LINE__,fmt,a)
41 #define xbt_test_add2(fmt,a,b)       _xbt_test_add(__FILE__,__LINE__,fmt,a,b)
42 #define xbt_test_add3(fmt,a,b,c)     _xbt_test_add(__FILE__,__LINE__,fmt,a,b,c)
43 #define xbt_test_add4(fmt,a,b,c,d)   _xbt_test_add(__FILE__,__LINE__,fmt,a,b,c,d)
44 #define xbt_test_add5(fmt,a,b,c,d,e) _xbt_test_add(__FILE__,__LINE__,fmt,a,b,c,d,e)
45
46 void    _xbt_test_fail(const char*file,int line, const char *fmt, ...) _XBT_GNUC_PRINTF(3,4);
47 #define xbt_test_fail0(fmt)           _xbt_test_fail(__FILE__, __LINE__, fmt)
48 #define xbt_test_fail1(fmt,a)         _xbt_test_fail(__FILE__, __LINE__, fmt,a)
49 #define xbt_test_fail2(fmt,a,b)       _xbt_test_fail(__FILE__, __LINE__, fmt,a,b)
50 #define xbt_test_fail3(fmt,a,b,c)     _xbt_test_fail(__FILE__, __LINE__, fmt,a,b,c)
51 #define xbt_test_fail4(fmt,a,b,c,d)   _xbt_test_fail(__FILE__, __LINE__, fmt,a,b,c,d)
52 #define xbt_test_fail5(fmt,a,b,c,d,e) _xbt_test_fail(__FILE__, __LINE__, fmt,a,b,c,d,e)
53
54 #define xbt_test_assert0(cond,fmt)           if(!(cond)) xbt_test_fail0(fmt)
55 #define xbt_test_assert1(cond,fmt,a)         if(!(cond)) xbt_test_fail1(fmt,a)
56 #define xbt_test_assert2(cond,fmt,a,b)       if(!(cond)) xbt_test_fail2(fmt,a,b)
57 #define xbt_test_assert3(cond,fmt,a,b,c)     if(!(cond)) xbt_test_fail3(fmt,a,b,c)
58 #define xbt_test_assert4(cond,fmt,a,b,c,d)   if(!(cond)) xbt_test_fail4(fmt,a,b,c,d)
59 #define xbt_test_assert5(cond,fmt,a,b,c,d,e) if(!(cond)) xbt_test_fail5(fmt,a,b,c,d,e)
60 #define xbt_test_assert(cond)                xbt_test_assert0(cond,#cond)
61
62 void    _xbt_test_log (const char*file,int line, const char *fmt, ...)_XBT_GNUC_PRINTF(3,4);
63 #define xbt_test_log0(fmt)           _xbt_test_log(__FILE__, __LINE__, fmt)
64 #define xbt_test_log1(fmt,a)         _xbt_test_log(__FILE__, __LINE__, fmt,a)
65 #define xbt_test_log2(fmt,a,b)       _xbt_test_log(__FILE__, __LINE__, fmt,a,b)
66 #define xbt_test_log3(fmt,a,b,c)     _xbt_test_log(__FILE__, __LINE__, fmt,a,b,c)
67 #define xbt_test_log4(fmt,a,b,c,d)   _xbt_test_log(__FILE__, __LINE__, fmt,a,b,c,d)
68 #define xbt_test_log5(fmt,a,b,c,d,e) _xbt_test_log(__FILE__, __LINE__, fmt,a,b,c,d,e)
69
70 void xbt_test_exception(xbt_ex_t e);
71
72 void xbt_test_expect_failure(void);
73 void xbt_test_skip(void);
74
75 /* test suite short-cut macros */
76 #define XBT_TEST_UNIT(name,func,title)    \
77     void func(void);  /*prototype*/       \
78     void func(void) 
79
80 #endif /* _TS_H_ */
81