root/tests/mctest.h

/* [previous][next][first][last][top][bottom][index][help]  */

INCLUDED FROM


   1 #ifndef MC__TEST
   2 #define MC__TEST
   3 
   4 #include <config.h>
   5 #include <stdlib.h>
   6 #include <check.h>
   7 
   8 #include "lib/global.h"
   9 
  10 /*** typedefs(not structures) and defined constants **********************************************/
  11 
  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)); \
  14 }
  15 
  16 #define mctest_assert_str_eq(actual_result, etalon_result) { \
  17     g_assert_cmpstr (actual_result, ==, etalon_result); \
  18 }
  19 
  20 #define mctest_assert_int_eq(actual_result, etalon_result) { \
  21     ck_assert_int_eq (actual_result, etalon_result); \
  22 }
  23 
  24 #define mctest_assert_int_ne(actual_result, etalon_result) { \
  25     ck_assert_int_ne (actual_result, etalon_result); \
  26 }
  27 
  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     );\
  33 }
  34 
  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     );\
  40 }
  41 
  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     ); \
  47 }
  48 
  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     ); \
  54 }
  55 
  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     ); \
  61 }
  62 
  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     ); \
  68 }
  69 
  70 /**
  71  * Define header for a parameterized test.
  72  * Declare 'data' variable for access to the parameters in current iteration
  73  */
  74 #define START_PARAMETRIZED_TEST(name_test, struct_name) START_TEST (name_test) { const struct struct_name *data = &struct_name[_i];
  75 
  76 /**
  77  * Define footer for a parameterized test.
  78  */
  79 #define END_PARAMETRIZED_TEST } END_TEST
  80 
  81 /*** enums ***************************************************************************************/
  82 
  83 /*** structures declarations (and typedefs of structures)*****************************************/
  84 
  85 /*** global variables defined in .c file *********************************************************/
  86 
  87 /*** declarations of public functions ************************************************************/
  88 
  89 /*** inline functions ****************************************************************************/
  90 
  91 #endif /* MC__TEST */

/* [previous][next][first][last][top][bottom][index][help]  */