]> git.llucax.com Git - software/mutest.git/blob - mutest.h
e0467e8849fbb67f10fc8e8b550cae22a1f08ce6
[software/mutest.git] / mutest.h
1
2 #include <stdio.h> // fprintf
3
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7
8 extern int mutest_failed_checks;
9 extern int mutest_passed_checks;
10 extern int mutest_case_failed;
11
12 #define mu_check(exp) \
13         do { \
14                 if (exp) ++mutest_passed_checks; \
15                 else { \
16                         ++mutest_failed_checks; \
17                         mutest_case_failed = 1; \
18                         fprintf(stderr, "%s:%d: mu_check(%s) failed, " \
19                                         "resuming test case\n", __FILE__, \
20                                         __LINE__, #exp); \
21                 } \
22         } while (0)
23
24 #define mu_ensure(exp) \
25         do { \
26                 if (exp) ++mutest_passed_checks; \
27                 else { \
28                         ++mutest_failed_checks; \
29                         mutest_case_failed = 1; \
30                         fprintf(stderr, "%s:%d: mu_ensure(%s) failed, " \
31                                         "aborting test case\n", __FILE__, \
32                                         __LINE__, #exp); \
33                         return; \
34                 } \
35         } while (0)
36
37 #ifdef __cplusplus
38 }
39 #endif
40