(edit_buffer_write_file): refactoring: return number of written bytes.
[midnight-commander.git] / tests / mctest.h
blob4e28bdd156631be58171b377216f88fae8faf4cc
1 #ifndef MC__TEST
2 #define MC__TEST
4 #include <config.h>
5 #include <check.h>
7 #include "lib/global.h"
9 /*** typedefs(not structures) and defined constants **********************************************/
11 #define mctest_add_parameterized_test(tc_core, test_func, test_data_source) {\
12 tcase_add_loop_test (tc_core, test_func, 0, G_N_ELEMENTS (test_data_source)); \
15 #define mctest_assert_str_eq(actual_result, etalon_result) { \
16 g_assert_cmpstr (actual_result, ==, etalon_result); \
19 #define mctest_assert_int_eq(actual_result, etalon_result) { \
20 ck_assert_int_eq (actual_result, etalon_result); \
23 #define mctest_assert_int_ne(actual_result, etalon_result) { \
24 ck_assert_int_ne (actual_result, etalon_result); \
27 #define mctest_assert_ptr_eq(actual_pointer, etalon_pointer) { \
28 fail_unless ( actual_pointer == etalon_pointer, \
29 "%s(%p) pointer should be equal to %s(%p)\n", \
30 #actual_pointer, actual_pointer, #etalon_pointer , etalon_pointer \
31 );\
34 #define mctest_assert_ptr_ne(actual_pointer, etalon_pointer) { \
35 fail_unless ( actual_pointer != etalon_pointer, \
36 "%s(%p) pointer should not be equal to %s(%p)\n", \
37 #actual_pointer, actual_pointer, #etalon_pointer , etalon_pointer \
38 );\
41 #define mctest_assert_null(actual_pointer) { \
42 fail_unless( \
43 (void *) actual_pointer == NULL, \
44 "%s(%p) variable should be NULL", #actual_pointer, actual_pointer \
45 ); \
48 #define mctest_assert_not_null(actual_pointer) { \
49 fail_if( \
50 (void *) actual_pointer == NULL, \
51 "%s(nil) variable should not be NULL", #actual_pointer \
52 ); \
55 /**
56 * Define header for a parameterized test.
57 * Declare 'data' variable for access to the parameters in current iteration
59 #define START_PARAMETRIZED_TEST(name_test, struct_name) START_TEST (name_test) { const struct struct_name *data = &struct_name[_i];
61 /**
62 * Define footer for a parameterized test.
64 #define END_PARAMETRIZED_TEST } END_TEST
66 /*** enums ***************************************************************************************/
68 /*** structures declarations (and typedefs of structures)*****************************************/
70 /*** global variables defined in .c file *********************************************************/
72 /*** declarations of public functions ************************************************************/
74 /*** inline functions ****************************************************************************/
76 #endif /* MC__TEST */