bzr branch
http://gegoxaren.bato24.eu/bzr/simpletypesystem/trunk
|
32
by Gustav Hartvigsson
* Added some compile options to the root CMakeLists.txt |
1 |
#ifndef __H_TEST_MACROS__
|
|
34
by Gustav Hartvigsson
* Finnished test suite |
2 |
#define __H_TEST_MACROS__
|
3 |
||
|
32
by Gustav Hartvigsson
* Added some compile options to the root CMakeLists.txt |
4 |
#include <stdio.h> |
5 |
||
6 |
#ifndef RESET
|
|
|
33
by Gustav Hartvigsson
* made test_macros.h a lil' bit more portable |
7 |
/* Colour definitions for console prints */
|
8 |
#define RESET "\033[0m"
|
|
9 |
#define BLACK "\033[30m" /* Black */ |
|
10 |
#define RED "\033[31m" /* Red */ |
|
11 |
#define GREEN "\033[32m" /* Green */ |
|
12 |
#define YELLOW "\033[33m" /* Yellow */ |
|
13 |
#define BLUE "\033[34m" /* Blue */ |
|
14 |
#define MAGENTA "\033[35m" /* Magenta */ |
|
15 |
#define CYAN "\033[36m" /* Cyan */ |
|
16 |
#define WHITE "\033[37m" /* White */ |
|
17 |
#define BOLDBLACK "\033[1m\033[30m" /* Bold Black */ |
|
18 |
#define BOLDRED "\033[1m\033[31m" /* Bold Red */ |
|
19 |
#define BOLDGREEN "\033[1m\033[32m" /* Bold Green */ |
|
20 |
#define BOLDYELLOW "\033[1m\033[33m" /* Bold Yellow */ |
|
21 |
#define BOLDBLUE "\033[1m\033[34m" /* Bold Blue */ |
|
22 |
#define BOLDMAGENTA "\033[1m\033[35m" /* Bold Magenta */ |
|
23 |
#define BOLDCYAN "\033[1m\033[36m" /* Bold Cyan */ |
|
24 |
#define BOLDWHITE "\033[1m\033[37m" /* Bold White */ |
|
25 |
#endif
|
|
26 |
||
27 |
#define setup_unit() \
|
|
|
34
by Gustav Hartvigsson
* Finnished test suite |
28 |
unsigned int unit_retval = 0;
|
29 |
||
30 |
#define end_unit() \
|
|
31 |
return unit_retval;
|
|
32 |
||
33 |
#define setup_suite() \
|
|
34 |
int total_fails = 0; \
|
|
35 |
int test_suites_failed = 0; \
|
|
36 |
int tmp_val; \
|
|
37 |
||
38 |
#define end_suite() \
|
|
39 |
if (test_suites_failed > 0){ \
|
|
40 |
fprintf (stderr, RED "[TEST SUITE FAILED]\n"\
|
|
41 |
" Number of failed suits: %d\n"\
|
|
42 |
" Number of tests failed (total): %d\n",\
|
|
43 |
test_suites_failed, total_fails);\
|
|
44 |
}\
|
|
45 |
return total_fails + test_suites_failed;
|
|
46 |
||
47 |
#define test_fail(p, ...)\
|
|
|
32
by Gustav Hartvigsson
* Added some compile options to the root CMakeLists.txt |
48 |
fprintf (stderr, RED "[FAILED][%s:%d, %s] " p " \n" RESET,\
|
49 |
__FILE__, __LINE__, __func__ , ##__VA_ARGS__)
|
|
50 |
||
51 |
#define test_pass(p, ...)\
|
|
52 |
fprintf (stdout, GREEN "[PASS] " p " \n" RESET,\
|
|
53 |
##__VA_ARGS__)
|
|
54 |
||
55 |
#define test_case(cond, p) \
|
|
|
34
by Gustav Hartvigsson
* Finnished test suite |
56 |
if (cond) { \
|
|
32
by Gustav Hartvigsson
* Added some compile options to the root CMakeLists.txt |
57 |
test_pass(p); \
|
58 |
} else { \
|
|
59 |
test_fail(p); \
|
|
60 |
unit_retval++; \
|
|
|
34
by Gustav Hartvigsson
* Finnished test suite |
61 |
}
|
|
32
by Gustav Hartvigsson
* Added some compile options to the root CMakeLists.txt |
62 |
|
63 |
#define test_unit(fun, name) \
|
|
|
34
by Gustav Hartvigsson
* Finnished test suite |
64 |
tmp_val = fun; \
|
65 |
if (tmp_val > 0) { \
|
|
66 |
total_fails =+ tmp_val; \
|
|
67 |
test_suites_failed++; \
|
|
68 |
fprintf (stderr, RED "[TEST UNIT FAIL] " name "\n" RESET); \
|
|
69 |
} else { \
|
|
70 |
fprintf (stdout, GREEN "[TEST UNIT PASS] " name "\n" RESET); \
|
|
71 |
}
|
|
72 |
||
73 |
#endif /* __H_TEST__ */ |
|
|
32
by Gustav Hartvigsson
* Added some compile options to the root CMakeLists.txt |
74 |