root/tests/mctest.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. mctest_run_all

   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_ptr_eq(actual_pointer, etalon_pointer) { \
  21     ck_assert_msg ( actual_pointer == etalon_pointer, \
  22         "%s(%p) pointer should be equal to %s(%p)\n", \
  23         #actual_pointer, actual_pointer, #etalon_pointer , etalon_pointer \
  24     );\
  25 }
  26 
  27 #define mctest_assert_ptr_ne(actual_pointer, etalon_pointer) { \
  28     ck_assert_msg ( actual_pointer != etalon_pointer, \
  29         "%s(%p) pointer should not be equal to %s(%p)\n", \
  30         #actual_pointer, actual_pointer, #etalon_pointer , etalon_pointer \
  31     );\
  32 }
  33 
  34 #define mctest_assert_null(actual_pointer) { \
  35     ck_assert_msg( \
  36         (void *) actual_pointer == NULL, \
  37         "%s(%p) variable should be NULL", #actual_pointer, actual_pointer \
  38     ); \
  39 }
  40 
  41 #define mctest_assert_not_null(actual_pointer) { \
  42     ck_assert_msg( \
  43         (void *) actual_pointer != NULL, \
  44         "%s(nil) variable should not be NULL", #actual_pointer \
  45     ); \
  46 }
  47 
  48 #define mctest_assert_true(actual_pointer) { \
  49     ck_assert_msg( \
  50         (int) actual_pointer != 0, \
  51         "%s variable should be TRUE", #actual_pointer \
  52     ); \
  53 }
  54 
  55 #define mctest_assert_false(actual_pointer) { \
  56     ck_assert_msg( \
  57         (int) actual_pointer == 0, \
  58         "%s variable should be FALSE", #actual_pointer \
  59     ); \
  60 }
  61 
  62 /**
  63  * Define header for a parameterized test.
  64  * Declare 'data' variable for access to the parameters in current iteration
  65  */
  66 #define START_PARAMETRIZED_TEST(name_test, struct_name) START_TEST (name_test) { const struct struct_name *data = &struct_name[_i];
  67 
  68 /**
  69  * Define footer for a parameterized test.
  70  */
  71 #define END_PARAMETRIZED_TEST } END_TEST
  72 
  73 /*** enums ***************************************************************************************/
  74 
  75 /*** structures declarations (and typedefs of structures)*****************************************/
  76 
  77 /*** global variables defined in .c file *********************************************************/
  78 
  79 /*** declarations of public functions ************************************************************/
  80 
  81 /*** inline functions ****************************************************************************/
  82 
  83 static inline int
  84 mctest_run_all (TCase * tc_core)
     /* [previous][next][first][last][top][bottom][index][help]  */
  85 {
  86     Suite *s;
  87     SRunner *sr;
  88     int number_failed;
  89 
  90     s = suite_create (TEST_SUITE_NAME);
  91     suite_add_tcase (s, tc_core);
  92     sr = srunner_create (s);
  93     srunner_set_log (sr, "-");
  94     srunner_run_all (sr, CK_ENV);
  95     number_failed = srunner_ntests_failed (sr);
  96     srunner_free (sr);
  97 
  98     return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
  99 }
 100 
 101 #endif /* MC__TEST */

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