mc.ext: add View action for initrd.
[midnight-commander.git] / tests / mctest.h
blob2e038a2d824ccce181e11b449fa65db4bd620c1c
1 #ifndef MC__TEST
2 #define MC__TEST
4 #include <config.h>
5 #include <stdlib.h>
6 #include <check.h>
8 #include "lib/global.h"
10 /*** typedefs(not structures) and defined constants **********************************************/
12 #define mctest_add_parameterized_test(tc_core, test_func, test_data_source) {\
13 tcase_add_loop_test (tc_core, test_func, 0, G_N_ELEMENTS (test_data_source)); \
16 #define mctest_assert_str_eq(actual_result, etalon_result) { \
17 g_assert_cmpstr (actual_result, ==, etalon_result); \
20 #define mctest_assert_int_eq(actual_result, etalon_result) { \
21 ck_assert_int_eq (actual_result, etalon_result); \
24 #define mctest_assert_int_ne(actual_result, etalon_result) { \
25 ck_assert_int_ne (actual_result, etalon_result); \
28 #define mctest_assert_ptr_eq(actual_pointer, etalon_pointer) { \
29 ck_assert_msg ( actual_pointer == etalon_pointer, \
30 "%s(%p) pointer should be equal to %s(%p)\n", \
31 #actual_pointer, actual_pointer, #etalon_pointer , etalon_pointer \
32 );\
35 #define mctest_assert_ptr_ne(actual_pointer, etalon_pointer) { \
36 ck_assert_msg ( actual_pointer != etalon_pointer, \
37 "%s(%p) pointer should not be equal to %s(%p)\n", \
38 #actual_pointer, actual_pointer, #etalon_pointer , etalon_pointer \
39 );\
42 #define mctest_assert_null(actual_pointer) { \
43 ck_assert_msg( \
44 (void *) actual_pointer == NULL, \
45 "%s(%p) variable should be NULL", #actual_pointer, actual_pointer \
46 ); \
49 #define mctest_assert_not_null(actual_pointer) { \
50 ck_assert_msg( \
51 (void *) actual_pointer != NULL, \
52 "%s(nil) variable should not be NULL", #actual_pointer \
53 ); \
56 #define mctest_assert_true(actual_pointer) { \
57 ck_assert_msg( \
58 (int) actual_pointer != 0, \
59 "%s variable should be TRUE", #actual_pointer \
60 ); \
63 #define mctest_assert_false(actual_pointer) { \
64 ck_assert_msg( \
65 (int) actual_pointer == 0, \
66 "%s variable should be TRUE", #actual_pointer \
67 ); \
70 /**
71 * Define header for a parameterized test.
72 * Declare 'data' variable for access to the parameters in current iteration
74 #define START_PARAMETRIZED_TEST(name_test, struct_name) START_TEST (name_test) { const struct struct_name *data = &struct_name[_i];
76 /**
77 * Define footer for a parameterized test.
79 #define END_PARAMETRIZED_TEST } END_TEST
81 /*** enums ***************************************************************************************/
83 /*** structures declarations (and typedefs of structures)*****************************************/
85 /*** global variables defined in .c file *********************************************************/
87 /*** declarations of public functions ************************************************************/
89 /*** inline functions ****************************************************************************/
91 #endif /* MC__TEST */