Imported Debian version 1.0~trusty
[deb_vid.stab.git] / tests / testframework.h
CommitLineData
80f575fc
DM
1#ifndef __TESTFRAMEWORK_H
2#define __TESTFRAMEWORK_H
3
4#include <stdio.h>
5#include <features.h>
6
7int contains(char **list, int len, const char *str, const char* descr);
8void unittest_init();
9int unittest_summary();
10void unittest_help_mode();
11
12long timeOfDayinMS();
13
14
15#define test_bool(expr) \
16 ((expr) \
17 ? tests_success++ \
18 : test_fails (__STRING(expr), __FILE__, __LINE__, ___FUNCTION))
19
20#define UNIT(func) \
21 if(!help_mode){tests_init(); \
22 fprintf(stderr,"\033[1;34m*** UNIT TEST %s ***\033[0m\n",__STRING(func)); \
23 (func); \
24 fprintf(stderr,"---->\t"); \
25 if(test_summary()){ fprintf(stderr, "\t\t\033[1;32m PASSED\033[0m\n"); \
26 units_success++; } \
27 else { fprintf(stderr, "\t\t\033[1;31m FAILED\033[0m !!!!!\n"); \
28 units_failed++; } \
29 }
30
31#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
32# define ___FUNCTION __func__
33#else
34# define ___FUNCTION ((__const char *) 0)
35#endif
36
37
38// INTERNALS
39extern int units_success;
40extern int units_failed;
41extern int tests_success;
42extern int tests_failed;
43extern int help_mode;
44
45
46void tests_init();
47
48int test_summary();
49
50void test_fails (__const char *__assertion, __const char *__file,
51 unsigned int __line, __const char *__function);
52
53
54
55#endif