1 /* ALWAYS INCLUDE FIRST, so that platform.h is included first as well! */
2 
3 
4 #ifndef CFENGINE_TEST_H
5 #define CFENGINE_TEST_H
6 
7 
8 #include <platform.h>
9 
10 #include <stdarg.h>
11 #include <stddef.h>
12 #include <setjmp.h>
13 #include <cmockery.h>
14 #include <stdio.h>
15 
16 
17 /* Use this define for specific overrides inside all our source tree. */
18 #define CFENGINE_TEST
19 
20 
21 #define PRINT_TEST_BANNER()                                             \
22     printf("==================================================\n");     \
23     printf("Starting test: %s\n", __FILE__);                            \
24     printf("==================================================\n")
25 
26 
27 char *file_read_string(FILE *in);
28 
29 void assert_file_equal(FILE *a, FILE *b);
30 
31 #define assert_double_close(a, b) _assert_double_close(a, b, __FILE__, __LINE__)
32 void _assert_double_close(double left, double right, const char *const file, const int line);
33 
34 void test_progress(void);
35 void test_progress_end(void);
36 
37 // like assert_string_equal, but better with respect to pointers:
38 // if a and b are NULL, returns true
39 // if a or b is NULL print error using assert_int
40 // if a and b are not NULL, use assert_string
41 #define assert_string_int_equal(a, b)\
42 {\
43     const char* x = a;\
44     const char* y = b;\
45     if (x!=y)\
46     {\
47         if (x==NULL||y==NULL)\
48         {\
49             assert_int_equal(x, y);\
50         }\
51         else\
52         {\
53             assert_string_equal(x, y);\
54         }\
55     }\
56 }\
57 
58 #endif
59