1 #ifndef TESTS_H
2 #define TESTS_H
3 
4 #include <stdarg.h>
5 #include <stddef.h>
6 #include <setjmp.h>
7 #include <assert.h>
8 #include <wchar.h>
9 #include <locale.h>
10 #include <string.h>
11 #include <stdio.h>
12 
13 #define WHEN(...)
14 #define THEN(...)
15 #define SCENARIO(...)
16 
17 #if !defined(FT_CONGIG_DISABLE_WCHAR)
18 #define FT_HAVE_WCHAR
19 #endif
20 
21 struct test_case {
22     char name [128];
23     void (*test)(void);
24 };
25 
26 /*
27  *  Test utility funcitons
28  */
29 
30 #define assert_true(args) assert(args)
31 
32 #define d_assert_str_equal(description, str1, str2) \
33     if (strcmp(str1, str2) != 0) \
34     { \
35         fprintf(stderr, "%s:%d(%s):Abort! %s failed. Not equals strings:\n",__FILE__,__LINE__, __func__, description); \
36         fprintf(stderr, "Left string(len = %d):\n%s\n", (int)strlen(str1), str1); \
37         fprintf(stderr, "Right string(len = %d):\n%s\n", (int)strlen(str2), str2); \
38         exit(EXIT_FAILURE); \
39     }
40 
41 #define assert_str_equal(str1, str2) \
42     d_assert_str_equal("Test", str1, str2)
43 
44 #define assert_wcs_equal(str1, str2) \
45     if (wcscmp(str1, str2) != 0) \
46     { \
47         fprintf(stderr, "%s:%d(%s):Abort! Not equals strings:\n",__FILE__,__LINE__, __func__); \
48         setlocale(LC_CTYPE, ""); \
49         fwprintf(stdout, L"Left string(len = %d):\n%ls\n", (int)wcslen(str1), str1); \
50         fwprintf(stdout, L"Right string(len = %d):\n%ls\n", (int)wcslen(str2), str2); \
51         fflush(stdout); \
52         exit(EXIT_FAILURE); \
53     }
54 
55 #define assert_string_equal(str1, str2) assert_str_equal(str1.c_str(), str2.c_str())
56 
57 
58 
59 #ifdef __cplusplus
60 extern "C" {
61 #endif
62 void run_test_suite(const char *test_suite_name, int n_tests, struct test_case test_suite[]);
63 #ifdef __cplusplus
64 }
65 #endif
66 
67 
68 #endif // TESTS_H
69